diff --git a/.gitignore b/.gitignore index 219a946..9aa29f4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ env/ *.json .cache/ .prevplaying +.idea diff --git a/PseudoChannel.py b/PseudoChannel.py index 4b41649..07a7690 100644 --- a/PseudoChannel.py +++ b/PseudoChannel.py @@ -28,7 +28,6 @@ from src import Episode from src import Music from src import Video from src import PseudoDailyScheduleController -from src import GoogleCalendar from src import PseudoChannelCommercial import pseudo_config as config @@ -40,7 +39,6 @@ class PseudoChannel(): PLEX = PlexServer(config.baseurl, config.token) MEDIA = [] GKEY = config.gkey - USING_GOOGLE_CALENDAR = config.useGoogleCalendar USING_COMMERCIAL_INJECTION = config.useCommercialInjection DAILY_UPDATE_TIME = config.dailyUpdateTime APP_TIME_FORMAT_STR = '%I:%M:%S %p' @@ -327,7 +325,7 @@ class PseudoChannel(): * ''' timeset=[datetime.time(h,m).strftime("%H:%M") for h,m in itertools.product(xrange(0,24),xrange(0,60,int(self.TIME_GAP)))] - print timeset + #print timeset for time in timeset: theTimeSetInterval = datetime.datetime.strptime(time, '%H:%M') tempTimeTwoStr = datetime.datetime.strptime(time1, self.APP_TIME_FORMAT_STR).strftime('%H:%M') @@ -669,14 +667,6 @@ if __name__ == '__main__': parser.add_argument('-xml', '--xml', action='store_true', help='Update the local database with the pseudo_schedule.xml.') - ''' - * - * Update Schedule based on Google Cal: "python PseudoChannel.py -gc" - * - ''' - parser.add_argument('-gc', '--google_calendar', - action='store_true', - help='Update the local database with entries in the google calendar.') parser.add_argument('-g', '--generate_schedule', action='store_true', help='Generate the daily schedule.') @@ -729,8 +719,6 @@ if __name__ == '__main__': pseudo_channel.update_db() if args.xml: pseudo_channel.update_schedule() - if args.google_calendar: - pseudo_channel.update_schedule_from_google_calendar() if args.generate_schedule: try: pseudo_channel.generate_daily_schedule() @@ -871,12 +859,6 @@ if __name__ == '__main__': ), pseudo_channel.APP_TIME_FORMAT_STR ).strftime('%H:%M') - if pseudo_channel.USING_GOOGLE_CALENDAR: - schedule.every().day.at(daily_update_time).do( - pseudo_channel.update_schedule_from_google_calendar - ).tag('daily-update-gc') - else: - pass def go_generate_daily_sched(): @@ -884,6 +866,9 @@ if __name__ == '__main__': pseudo_channel.save_daily_schedule_as_json() schedule.clear('daily-tasks') + + sleep(1) + try: pseudo_channel.generate_daily_schedule() except: diff --git a/pseudo_config.py b/pseudo_config.py index 9ef622b..dd4d5db 100644 --- a/pseudo_config.py +++ b/pseudo_config.py @@ -70,20 +70,12 @@ useDailyOverlapCache = True dailyUpdateTime = "12:00 AM" -"""---""" -useGoogleCalendar = False - """When to delete / remake the pseudo-channel.log - right at midnight, (i.e. 'friday') """ rotateLog = "friday" """Debug mode will give you more output in your terminal to help problem solve issues.""" debug_mode = True - - - - - """ ##### Do not edit below this line--------------------------------------------------------------- diff --git a/requirements.txt b/requirements.txt index 81dec23..e2e798b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ amqp==2.2.1 billiard==3.5.0.3 certifi==2017.7.27.1 chardet==3.0.4 -google-api-python-client==1.6.2 httplib2==0.10.3 idna==2.5 kombu==4.1.0 diff --git a/src/GoogleCalendar.py b/src/GoogleCalendar.py deleted file mode 100644 index d5c82ed..0000000 --- a/src/GoogleCalendar.py +++ /dev/null @@ -1,104 +0,0 @@ -from __future__ import print_function -import httplib2 -import os - -from apiclient import discovery -from oauth2client import client -from oauth2client import tools -from oauth2client.file import Storage - -import os.path as path -import sys - -import datetime - -"""try: - import argparse - flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() -except ImportError: - flags = None""" - - -class GoogleCalendar(): - - # If modifying these scopes, delete your previously saved credentials - # at ~/.credentials/calendar-python-quickstart.json - two_up = path.abspath(path.join(__file__ ,"../../../")) - home_dir = os.path.expanduser('~') - credential_dir = os.path.join(home_dir, 'client_secret.json') - SCOPES = 'https://www.googleapis.com/auth/calendar.readonly' - CLIENT_SECRET_FILE = credential_dir - APPLICATION_NAME = 'Google Calendar API Python Quickstart' - - KEY = '' - - def __init__(self, key): - - self.KEY = key - - def get_credentials(self): - """Gets valid user credentials from storage. - - If nothing has been stored, or if the stored credentials are invalid, - the OAuth2 flow is completed to obtain the new credentials. - - Returns: - Credentials, the obtained credential. - """ - home_dir = os.path.expanduser('~') - credential_dir = os.path.join(home_dir, '.credentials') - if not os.path.exists(credential_dir): - os.makedirs(credential_dir) - credential_path = os.path.join(credential_dir, - 'calendar-python-quickstart.json') - - store = Storage(credential_path) - credentials = store.get() - - if not credentials or credentials.invalid: - flow = client.flow_from_clientsecrets(self.CLIENT_SECRET_FILE, self.SCOPES) - flow.user_agent = self.APPLICATION_NAME - if flags: - credentials = tools.run_flow(flow, store, flags) - else: # Needed only for compatibility with Python 2.6 - credentials = tools.run(flow, store) - print('Storing credentials to ' + credential_path) - return credentials - - def get_entries(self): - """Shows basic usage of the Google Calendar API. - - Creates a Google Calendar API service object and outputs a list of the next - 10 events on the user's calendar. - """ - credentials = self.get_credentials() - http = credentials.authorize(httplib2.Http()) - service = discovery.build('calendar', 'v3', http=http) - - now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time - - end = (datetime.datetime.utcnow() + datetime.timedelta(hours=24)) - - end = end.isoformat() + 'Z' # 'Z' indicates UTC time - - #print(now) - - #print(end) - - print('##### Getting the upcoming calendar events') - eventsResult = service.events().list( - calendarId=self.KEY, timeMin=now, timeMax=end, maxResults=250, singleEvents=True, - orderBy='startTime').execute() - events = eventsResult.get('items', []) - - if not events: - print('No upcoming events found.') - for event in events: - #start = event['start'].get('dateTime', event['start'].get('date')) - #print(start, event['summary']) - pass - return events - - -if __name__ == '__main__': - pass \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py index 027281c..2752e6c 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6,5 +6,4 @@ from Media import Media from Music import Music from Video import Video from PseudoDailyScheduleController import PseudoDailyScheduleController -from GoogleCalendar import GoogleCalendar from PseudoChannelCommercial import PseudoChannelCommercial \ No newline at end of file