Advertisement
PlowmanPlow

Plex - Update Collections

Dec 3rd, 2018
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. from plexapi.server import PlexServer
  2. import requests
  3. import sys
  4.  
  5. if len(sys.argv) != 3:
  6.     print("Input Error! Usage: updatecoll.py {/path/to/videos/folder/} {CollectionName}")
  7.     sys.exit(1)
  8.  
  9. PLEX_URL = 'http://localhost:32400'
  10. PLEX_TOKEN = 'TokenGoesHere'
  11. LIBRARY_NAME = 'Movies'
  12. PATH_FOLDER = sys.argv[1]
  13. COLLECTION_NAME = sys.argv[2]
  14.  
  15. plex = PlexServer(PLEX_URL, PLEX_TOKEN)
  16.  
  17. for video in plex.library.section(LIBRARY_NAME).all():
  18.     for part in video.iterParts():
  19.         if part.file[0:len(PATH_FOLDER)] == PATH_FOLDER:
  20.             hasCollection = False
  21.             for tag in video.collections:
  22.                 if tag.tag == COLLECTION_NAME:
  23.                     hasCollection = True
  24.             if hasCollection == True:
  25.                 continue
  26.             video.addCollection(COLLECTION_NAME)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement