python-plexapi
python-plexapi copied to clipboard
download() on a file with multiple Media options clobbers itself
Describe the Bug
When a downloadable item (e.g. Episode) is available in multiple quality/encoding options, calling download() is supposed to download all of them. However, if keep_original_filenames=False (the default), each Media item gets downloaded to the same friendly name, with subsequent downloads overwriting the previous ones. All the data is transferred, but only one remains on the file system after the function returns.
If keep_original_filenames=True, all files are downloaded because the target filenames are (likely to be) different.
Code Snippets
episode = series.onDeck()
files = episode.download()
assert len(files) == len(episode.media)
Expected Behavior
One or both of:
- Only one media is downloaded, and I can select which one it is
- Maybe by passing arguments into
.download()? - Maybe by using
episode.media[0].download(), which doesn't currently exist?
- Maybe by passing arguments into
- All media options are downloaded with different names.
Additional Context
Appending something like "[4K-20Mbps]" or "[1080p-8Mbps]" to the friendly name when a discriminator is needed would be a nice touch, but even "-0", "-1", etc. would keep the overwrite from happening.
Operating System and Version
Ubuntu 22.04 on WSL
Plex Media Server Version
1.31.2.6783
Python Version
3.10.6
PlexAPI Version
4.15.0
My ideas since the current download method just loops over all parts.
- Move the logic in the
download()method toMediaPartto allow downloading a single part. - Add a
download()method toMediathat calls the method inMediaPartto downloads all parts in that media. Add part discriminators (maybe-ptXto follow Plex's convention?) where necessary. - Update the base
download()method that calls the method inMediato download all parts in all media. Add media discriminators (maybe resolution and bitrate to match Plex's version dialogue?) where necessary (this would need to work in conjuntion with the part discriminator).