Updated PrerollUpdate.py

Added a custom date section to store up to 10 custom pre roll dates. Moved from storing data in the PySimpleGUI settings to a JSON file for more flexibility.
main
TheHumanRobot 3 years ago committed by GitHub
parent a40c693486
commit 0de89d7cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,10 +18,9 @@ import pathlib
from configparser import * from configparser import *
def update(): def update():
with open('config.yml', 'r') as file:
doc = yaml.load(file, Loader=yaml.SafeLoader)
# Opening JSON file f = open(str('data.json'))
f = open(str(doc["Plex"]["Path"]))
data = json.load(f) data = json.load(f)
@ -115,5 +114,98 @@ def update():
plex.settings.get('cinemaTrailersPrerollID').set(prerolls) plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save() plex.settings.save()
print('Pre-roll updated') print('Pre-roll updated')
# Closing file if data['Freq'][0] == 'Custom':
Date = datetime.date.today()
Date = Date.strftime("%Y-%m-%d")
if data['Start1'] <= Date <= data['End1']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path1']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start2'] <= Date <= data['End2']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path2']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start3'] <= Date <= data['End3']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path3']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start4'] <= Date <= data['End4']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path4']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start5'] <= Date <= data['End5']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path5']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start6'] <= Date <= data['End6']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path6']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start7'] <= Date <= data['End7']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path7']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start8'] <= Date <= data['End8']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path8']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start9'] <= Date <= data['End9']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path9']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
elif data['Start10'] <= Date <= data['End10']:
session = requests.Session()
session.verify = False
requests.packages.urllib3.disable_warnings()
plex = PlexServer(data['URL'], data['Token'], session, timeout=None)
prerolls = data['Path10']
plex.settings.get('cinemaTrailersPrerollID').set(prerolls)
plex.settings.save()
print('Pre-roll updated')
# Closing file
f.close() f.close()

Loading…
Cancel
Save