-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_studio_writers.py
executable file
·62 lines (60 loc) · 1.57 KB
/
list_studio_writers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
#
# import modules
#
import sys
import os
import configparser
from pprint import pprint
from plexapi.server import PlexServer
#
# Sanity check CLI arguments and assign them to readable variable names
#
if len(sys.argv) != 2:
print(f"Usage: {os.path.basename(__file__)} <studio name>")
sys.exit(1)
studioName = sys.argv[1]
# print(f"Studio: {studioName}")
#
# Color support
#
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
#
# set default variables
#
config = configparser.ConfigParser()
config.read(os.getenv('HOME')+'/.plexconfig.ini')
plexHost = config['default']['plexHost']
plexPort = config['default']['plexPort']
plexSection = config['default']['plexSection']
plexToken = config['default']['plexToken']
plexSectionName = config['default']['plexSectionName']
baseurl = f"http://{plexHost}:{plexPort}"
#
# Connect to server
#
plex = PlexServer(baseurl, plexToken)
#
# Select section
#
plexSection = plex.library.section(plexSectionName)
writerGlobalSet = set()
results = plexSection.search(studio__exact=studioName, sort="titleSort")
for video in results:
for thisWriter in video.writers:
writerGlobalSet.add(f"{thisWriter}")
if len(writerGlobalSet) == 0:
print(f"{bcolors.FAIL}No writers found!{bcolors.ENDC}")
else:
# print(f"{bcolors.OKGREEN}{len(writerGlobalSet)} writers found.{bcolors.ENDC}")
for writerName in sorted(writerGlobalSet):
print(writerName)