From 469b3a726ae5b6e20f633b174579488c8e31422a Mon Sep 17 00:00:00 2001 From: TheHumanRobot <75536101+TheHumanRobot@users.noreply.github.com> Date: Tue, 4 Jan 2022 07:24:24 -0500 Subject: [PATCH] Update PrerollUpdate.py --- PrerollUpdate.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/PrerollUpdate.py b/PrerollUpdate.py index 4eebe45..d03ad18 100644 --- a/PrerollUpdate.py +++ b/PrerollUpdate.py @@ -17,15 +17,16 @@ import shutil import pathlib from configparser import * -def update(): - f = open(str('data.json')) +def update(): + os.chdir('/') + f = open(str('./data.json')) data = json.load(f) + print('pre-roll updated') - - if data['Freq'][0] == 'Monthly': + if data['Freq'] == 'Monthly': Date = datetime.date.today() Date = Date.strftime("%b") session = requests.Session() @@ -41,7 +42,7 @@ def update(): plex.settings.get('cinemaTrailersPrerollID').set(prerolls) plex.settings.save() print('Pre-roll updated') - if data['Freq'][0] == 'Weekly': + if data['Freq'] == 'Weekly': Date = datetime.date.today() Date = Date.strftime("%Y-%m-%d") if data['WeekStart'] <= Date <= data['WeekEnd']: @@ -69,19 +70,15 @@ def update(): session.verify = False requests.packages.urllib3.disable_warnings() plex = PlexServer(data['URL'], data['Token'], session, timeout=None) - print(Date) - print(data[Date]) if data[Date] is None: Path = data['Default'] - print(Path) else: Path = data[Date] - print(Path) prerolls = Path plex.settings.get('cinemaTrailersPrerollID').set(prerolls) plex.settings.save() print('Pre-roll updated') - if data['Freq'][0] == 'Holiday': + if data['Freq'] == 'Holiday': Date = datetime.date.today() ThanksgivingDay = 22 + (10 - datetime.date(Date.year, 11, 1).weekday()) % 7 # Valentines Day @@ -118,7 +115,7 @@ def update(): plex.settings.get('cinemaTrailersPrerollID').set(prerolls) plex.settings.save() print('Pre-roll updated') - if data['Freq'][0] == 'Custom': + if data['Freq'] == 'Custom': Date = datetime.date.today() Date = Date.strftime("%Y-%m-%d") if data['Start1'] <= Date <= data['End1']: @@ -213,3 +210,5 @@ def update(): print('Pre-roll updated') # Closing file f.close() +if __name__ == '__main__': + update()