def root_menu(self, args): include_premium = adobe_activate_api.is_authenticated() channel_list = events.get_channel_list(include_premium) curdate = datetime.utcnow() upcoming = int(selfAddon.getSetting('upcoming')) + 1 days = (curdate + timedelta(days=upcoming)).strftime("%Y%m%d") addDir( translation(30029), dict(ESPN_URL=events.get_live_events_url(channel_list), MODE=self.make_mode(LIVE_EVENTS_MODE)), defaultlive) addDir( translation(30030), dict(ESPN_URL=events.get_upcoming_events_url(channel_list) + '&endDate=' + days + '&startDate=' + curdate.strftime("%Y%m%d"), MODE=self.make_mode(LIST_SPORTS_MODE)), defaultupcoming) enddate = '&endDate=' + (curdate + timedelta(days=1)).strftime("%Y%m%d") replays1 = [5, 10, 15, 20, 25] replays1 = replays1[int(selfAddon.getSetting('replays1'))] start1 = (curdate - timedelta(days=replays1)).strftime("%Y%m%d") replays2 = [10, 20, 30, 40, 50] replays2 = replays2[int(selfAddon.getSetting('replays2'))] start2 = (curdate - timedelta(days=replays2)).strftime("%Y%m%d") replays3 = [30, 60, 90, 120] replays3 = replays3[int(selfAddon.getSetting('replays3'))] start3 = (curdate - timedelta(days=replays3)).strftime("%Y%m%d") replays4 = [60, 90, 120, 240] replays4 = replays4[int(selfAddon.getSetting('replays4'))] start4 = (curdate - timedelta(days=replays4)).strftime("%Y%m%d") startAll = (curdate - timedelta(days=365)).strftime("%Y%m%d") addDir( translation(30031) + str(replays1) + ' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + start1, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir( translation(30031) + str(replays2) + ' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + start2, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir( translation(30031) + str(replays3) + ' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + start3, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir( translation(30031) + str(replays3) + '-' + str(replays4) + ' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + '&endDate=' + start3 + '&startDate=' + start4, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir( translation(30032), dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + startAll, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) xbmcplugin.endOfDirectory(pluginhandle)
def root_menu(self, args): # Roku config url = base64.b64decode( 'aHR0cDovL2Fzc2V0cy5lc3BuLmdvLmNvbS9wcm9kL2Fzc2V0cy93YXRjaGVzcG4vcm9rdS9jb25maWcuanNvbg==') json_data = util.get_url_as_json_cache(get_url(url)) for group in json_data['config']['featured']['groups']: if group['visibility'] == 'not authenticated': # This represents the duplicate Browse by Sport continue extra = '' if group['visibility'] == 'authenticated': if not adobe_activate_api.is_authenticated(): extra = '*' if len(group['contents']) > 1: extra += group['name'] + ' - ' for content in group['contents']: addDir(extra + content['name'], dict(URL=content['href'], MODE=self.make_mode(URL_MODE)), defaultlive) xbmcplugin.endOfDirectory(pluginhandle)
def root_menu(self, args): include_premium = adobe_activate_api.is_authenticated() channel_list = events.get_channel_list(include_premium) curdate = datetime.utcnow() upcoming = int(selfAddon.getSetting('upcoming'))+1 days = (curdate+timedelta(days=upcoming)).strftime("%Y%m%d") addDir(translation(30029), dict(ESPN_URL=events.get_live_events_url(channel_list), MODE=self.make_mode(LIVE_EVENTS_MODE)), defaultlive) addDir(translation(30030), dict(ESPN_URL=events.get_upcoming_events_url(channel_list) + '&endDate=' + days + '&startDate=' + curdate.strftime("%Y%m%d"), MODE=self.make_mode(LIST_SPORTS_MODE)), defaultupcoming) enddate = '&endDate='+ (curdate+timedelta(days=1)).strftime("%Y%m%d") replays1 = [5,10,15,20,25] replays1 = replays1[int(selfAddon.getSetting('replays1'))] start1 = (curdate-timedelta(days=replays1)).strftime("%Y%m%d") replays2 = [10,20,30,40,50] replays2 = replays2[int(selfAddon.getSetting('replays2'))] start2 = (curdate-timedelta(days=replays2)).strftime("%Y%m%d") replays3 = [30,60,90,120] replays3 = replays3[int(selfAddon.getSetting('replays3'))] start3 = (curdate-timedelta(days=replays3)).strftime("%Y%m%d") replays4 = [60,90,120,240] replays4 = replays4[int(selfAddon.getSetting('replays4'))] start4 = (curdate-timedelta(days=replays4)).strftime("%Y%m%d") startAll = (curdate-timedelta(days=365)).strftime("%Y%m%d") addDir(translation(30031) + str(replays1) +' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + start1, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir(translation(30031) + str(replays2) +' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + start2, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir(translation(30031) + str(replays3) +' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + start3, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir(translation(30031) + str(replays3) +'-' + str(replays4) +' Days', dict(ESPN_URL=events.get_replay_events_url(channel_list) + '&endDate=' + start3 + '&startDate=' + start4, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) addDir(translation(30032), dict(ESPN_URL=events.get_replay_events_url(channel_list) + enddate + '&startDate=' + startAll, MODE=self.make_mode(LIST_SPORTS_MODE)), defaultreplay) xbmcplugin.endOfDirectory(pluginhandle)
def index_item(args): if args['type'] == 'over': return sport = args['sport'] ename = args['eventName'] sport2 = args['subcategory'] if 'subcategory' in args else sport if sport <> sport2 and len(sport2) > 0: sport += ' (' + sport2 + ')' starttime = args['starttime'] if 'starttime' in args else None length = int(args['duration']) xbmc.log(TAG + 'startime %s' % starttime, xbmc.LOGDEBUG) xbmc.log(TAG + 'type %s' % args['type'], xbmc.LOGDEBUG) if starttime is not None: now = time.time() etime = time.strftime("%I:%M %p", starttime) if 'replay' in args['type']: etime_local = starttime if etime_local.tm_hour == 0 and etime_local.tm_min == 0: etime = time.strftime("%m/%d/%Y", starttime) else: etime = time.strftime("%m/%d %I:%M %p", starttime) if selfAddon.getSetting('NoColors') == 'true': ename = etime + ' ' + ename else: ename = '[COLOR=FFB700EB]' + etime + '[/COLOR] ' + ename elif args['type'] == 'live': starttime_time = time.mktime(starttime) length -= (time.time() - starttime_time) if selfAddon.getSetting('NoColors') == 'true': ename = ename + ' ' + etime else: ename += ' [COLOR=FFB700EB]' + etime + '[/COLOR]' else: now_time = time.localtime(now) if now_time.tm_year == starttime.tm_year and \ now_time.tm_mon == starttime.tm_mon and \ now_time.tm_mday == starttime.tm_mday: etime = time.strftime("%I:%M %p", starttime) else: etime = time.strftime("%m/%d %I:%M %p", starttime) if selfAddon.getSetting('NoColors') == 'true': ename = etime + ' ' + ename else: ename = '[COLOR=FFB700EB]' + etime + '[/COLOR] ' + ename aired = time.strftime("%Y-%m-%d", starttime) else: aired = 0 network_id = args['networkId'] if 'networkId' in args else '' if network_id == 'longhorn': channel_color = 'BF5700' elif network_id == 'sec' or network_id == 'secplus': channel_color = '004C8D' elif network_id == 'accextra': channel_color = '013ca6' else: channel_color = 'CC0000' if 'networkName' in args: network = args['networkName'] else: network = network_id xbmc.log(TAG + 'network_id ' + network_id, xbmc.LOGDEBUG) if network_id in NETWORK_ID_TO_NETWORK_NAME: network = translation(NETWORK_ID_TO_NETWORK_NAME[network_id]) blackout = args['blackout'] if 'blackout' in args else False blackout_text = '' if blackout: blackout_text = translation(30580) if len(blackout_text) > 0: ename = blackout_text + ' ' + ename if len(network) > 0: if selfAddon.getSetting('NoColors') == 'true': ename = network + ' ' + ename else: ename = '[COLOR=FF%s]%s[/COLOR] ' % (channel_color, network) + ename description = args['description'] requires_auth = does_requires_auth(network_id) if requires_auth and not adobe_activate_api.is_authenticated(): ename = '*' + ename xbmc.log(TAG + 'Duration %s' % length, xbmc.LOGDEBUG) mpaa = args['parentalRating'] if 'parentRating' in args else 'U' infoLabels = {'title': ename, 'genre': sport, 'duration': length, 'studio': network, 'mpaa': mpaa, 'plot': description, 'aired': aired, 'premiered': aired} authurl = dict() if args['type'] == 'upcoming': authurl[MODE] = UPCOMING_MODE else: adobeRSS = args['adobeRSS'] if 'adobeRSS' in args else None guid = args['guid'] if 'guid' in args else None if adobeRSS is None and guid is None: authurl[PLAYBACK_URL] = args['sessionUrl'] authurl[MODE] = PLAY_ITEM_MODE else: authurl[MODE] = PLAY_TV_MODE authurl[EVENT_ID] = args['eventId'] authurl[SESSION_URL] = args['sessionUrl'] authurl[NETWORK_NAME] = args['networkId'] if 'adobeRSS' in args: authurl[ADOBE_RSS] = args['adobeRSS'].encode('iso-8859-1') else: authurl[EVENT_NAME] = args['eventName'].encode('iso-8859-1') authurl[EVENT_GUID] = args['guid'].encode('iso-8859-1') authurl[EVENT_PARENTAL_RATING] = mpaa authurl[CHANNEL_RESOURCE_ID] = args['channelResourceId'] fanart = args['imageHref'] if include_item(network_id): addLink(ename, authurl, fanart, fanart, infoLabels=infoLabels) else: xbmc.log(TAG + 'Skipping %s' % args['networkId'], xbmc.LOGDEBUG)