python-plexapi icon indicating copy to clipboard operation
python-plexapi copied to clipboard

Lists even when it is not needed

Open gianfelicevincenzo opened this issue 1 year ago • 1 comments

What is your feature request?

Why does it return a list even when it is clear that there should always be only one element there? For example in the code below, if I reference the media movie object containing one movie at a time (via the for loop) I would expect direct access to the resolution, for example, with movie.media.videoResolution and not indexing with movie.media[ 0].videoResolution

As it should be

Single Movie direct access without indexing

Code Snippets

movies=plex.library.section('Film')
for movie in movies.search():
   if movie.media[0].videoResolution == '4k' or movie.media[0].parts[0].videoProfile == 'high':
      try:
         movie.optimize(deviceProfile='Universal TV', videoQuality=sync.VIDEO_QUALITY_10_MBPS_1080p, locationID=plex.library.section('Film')._locations()[0])
         print(movie.title, movie.media[0].videoResolution, movie.media[0].parts[0].videoProfile)
      except:
         continue

gianfelicevincenzo avatar Jun 15 '24 18:06 gianfelicevincenzo

You can have multiple versions (media) per movie.

https://support.plex.tv/articles/200381043-multi-version-movies/

And multiple parts per version.

https://support.plex.tv/articles/naming-and-organizing-your-movie-media-files/#toc-3

JonnyWong16 avatar Jun 15 '24 21:06 JonnyWong16