# Plexapi download filename

**URL:** <https://forums.plex.tv/t/plexapi-download-filename/774478>\
**Category:** Dev/API Corner\
**Tags:** server-windows, downloads\
**Created:** [February 3, 2022, 4:36pm UTC](https://forums.plex.tv/t/plexapi-download-filename/774478 "2022-02-03T16:36:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmruiz](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jmruiz](https://forums.plex.tv/u/jmruiz)\
**Post date:** [February 3, 2022, 4:36pm UTC](https://forums.plex.tv/t/plexapi-download-filename/774478/1 "2022-02-03T16:36:54Z")

</div>

Hi,  
does anyone know how to deal with the plexapi download method when the file has characters not allowed by the filesystem in a filename (i.e., “:” in Windows)?  
I’ve tried using the keep\_original\_filename True and False but in both cases the pattern is filled with the title of the film, containig those chars. Is there anyway to force a filename for the downloaded file?  
Thanks!

---

<div class="post-metadata">

**Author:** ![jmruiz](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jmruiz](https://forums.plex.tv/u/jmruiz)\
**Post date:** [February 10, 2022, 8:11pm UTC](https://forums.plex.tv/t/plexapi-download-filename/774478/2 "2022-02-10T20:11:53Z")

</div>

Hi,  
I provide solution, just in case anyone finds the same problem.  
Just edit video.py in {python}{lib}\site-packages\plexapi  
Insert line containig **name=name.replace(’:’, ‘.’)**.

```
def download(self, savepath=None, keep_original_name=False, **kwargs):
    """ Download video files to specified directory.

        Parameters:
            savepath (str): Defaults to current working dir.
            keep_original_name (bool): True to keep the original file name otherwise
                a friendlier is generated.
            **kwargs: Additional options passed into :func:`~plexapi.base.PlexObject.getStreamURL`.
    """
    filepaths = []
    locations = [i for i in self.iterParts() if i]
    for location in locations:
        name = location.file
        if not keep_original_name:
            title = self.title.replace(' ', '.')
            name = '%s.%s' % (title, location.container)
        if kwargs is not None:
            url = self.getStreamURL(**kwargs)
        else:
            self._server.url('%s?download=1' % location.key)

        name=name.replace(':', '.')

        filepath = utils.download(url, self._server._token, filename=name,
                                  savepath=savepath, session=self._server._session)
        if filepath:
            filepaths.append(filepath)
    return filepaths
```

---

<div class="post-metadata">

**Author:** ![SwiftPanda16](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/swiftpanda16/32/81839_2.png) [@SwiftPanda16](https://forums.plex.tv/u/SwiftPanda16)\
**Post date:** [February 11, 2022, 4:37am UTC](https://forums.plex.tv/t/plexapi-download-filename/774478/3 "2022-02-11T04:37:40Z")

</div>

You are using an ancient version or lf PlexAPI.

I sanitized filenames 4 months ago in version 4.8.0.

> <https://github.com/pkkid/python-plexapi/pull/847>
>
> \## Description
> 
> \* Cleanup all download methods for audio, photos, and videos.
> …
> \* Sanitizes the download filename.
> \* Also adds the \`subfolder\` option to download shows into season folders, artists into album folders, and photos into photo album folders.
> 
> Fixes #293
> Closes #448
> Closes #579
> 
> \## Type of change
> 
> Please delete options that are not relevant.
> 
> \- \[x\] Bug fix (non-breaking change which fixes an issue)
> \- \[x\] New feature (non-breaking change which adds functionality)
> \- \[\] Breaking change (fix or feature that would cause existing functionality to not work as expected)
> \- \[x\] This change requires a documentation update
> 
> 
> \## Checklist:
> 
> \- \[x\] My code follows the style guidelines of this project
> \- \[x\] I have performed a self-review of my own code
> \- \[x\] I have commented my code, particularly in hard-to-understand areas
> \- \[x\] I have added or updated the docstring for new or existing methods
> \- \[x\] I have added tests when applicable

> **[Release 4.8.0 · pkkid/python-plexapi](https://github.com/pkkid/python-plexapi/releases/tag/4.8.0)**
>
> Breaking Changes
> 
> \#845 - Update server transcodeImage method
> \#855 - Change LibrarySection.reload() to reload in-place
> 
> New Features
> 
> \#849 - Add methods for accepting and cancelling friend invites
> \#...

---

<div class="post-metadata">

**Author:** ![jmruiz](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jmruiz](https://forums.plex.tv/u/jmruiz)\
**Post date:** [December 1, 2022, 10:29am UTC](https://forums.plex.tv/t/plexapi-download-filename/774478/4 "2022-12-01T10:29:06Z")

</div>

Thanks!
