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!
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
You are using an ancient version or lf PlexAPI.
I sanitized filenames 4 months ago in version 4.8.0.
Thanks!