Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from plexapi.server import PlexServer
- import requests
- import sys
- if len(sys.argv) != 3:
- print("Input Error! Usage: updatecoll.py {/path/to/videos/folder/} {CollectionName}")
- sys.exit(1)
- PLEX_URL = 'http://localhost:32400'
- PLEX_TOKEN = 'TokenGoesHere'
- LIBRARY_NAME = 'Movies'
- PATH_FOLDER = sys.argv[1]
- COLLECTION_NAME = sys.argv[2]
- plex = PlexServer(PLEX_URL, PLEX_TOKEN)
- for video in plex.library.section(LIBRARY_NAME).all():
- for part in video.iterParts():
- if part.file[0:len(PATH_FOLDER)] == PATH_FOLDER:
- hasCollection = False
- for tag in video.collections:
- if tag.tag == COLLECTION_NAME:
- hasCollection = True
- if hasCollection == True:
- continue
- video.addCollection(COLLECTION_NAME)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement