def check_error(session_json): status = session_json['status'] if not status == 'success': dialog = xbmcgui.Dialog() dialog.ok(translation(30037), translation(30500) % session_json['message']) return True return False
def root_menu(self, args): self.trending_mode(args) addDir(translation(30680), dict(MODE=self.make_mode(FEATURED)), defaultlive) addDir(translation(30550), dict(MODE=self.make_mode(CATEGORY_SPORTS_MODE)), defaultlive) addDir(translation(30560), dict(MODE=self.make_mode(CATEGORY_CHANNELS_MODE)), defaultlive) xbmcplugin.endOfDirectory(pluginhandle)
def index_legacy_live_events(self, args): espn_url = args.get(ESPN_URL)[0] chosen_sport = args.get(SPORT, None) if chosen_sport is not None: chosen_sport = chosen_sport[0] chosen_network = args.get(NETWORK_ID, None) if chosen_network is not None: chosen_network = chosen_network[0] live = 'action=live' in espn_url upcoming = 'action=upcoming' in espn_url replay = 'action=replay' in espn_url if live: data = events.get_events(espn_url) else: data = util.get_url_as_xml_soup_cache(espn_url).findall(".//event") num_espn3 = 0 num_secplus = 0 num_events = 0 for event in data: sport = event.find('sportDisplayValue').text.encode('utf-8') if chosen_sport <> sport and chosen_sport is not None: continue networkid = event.find('networkId').text if chosen_network <> networkid and chosen_network is not None: continue if networkid == ESPN3_ID and chosen_network is None and live: num_espn3 = num_espn3 + 1 elif networkid == SECPLUS_ID and chosen_network is None and live: num_secplus = num_secplus + 1 else: num_events = num_events + 1 self.index_event(event, live, upcoming, replay, chosen_sport) # Don't show ESPN3 folder if there are no premium events if num_events == 0: for event in data: sport = event.find('sportDisplayValue').text.encode('utf-8') if chosen_sport <> sport and chosen_sport is not None: continue self.index_event(event, live, upcoming, replay, chosen_sport) # Dir for ESPN3/SECPlus elif chosen_network is None: if num_espn3 > 0: translation_number = 30191 if num_espn3 == 1 else 30190 if selfAddon.getSetting('NoColors') == 'true': name = translation(translation_number) % num_espn3 else: name = '[COLOR=FFCC0000]' + (translation(translation_number) % num_espn3) + '[/COLOR]' addDir(name, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), NETWORK_ID=ESPN3_ID), defaultlive) if num_secplus > 0: translation_number = 30201 if num_espn3 == 1 else 30200 if selfAddon.getSetting('NoColors') == 'true': name = translation(translation_number) % num_secplus else: name = '[COLOR=FFCC0000]' + (translation(translation_number) % num_secplus) + '[/COLOR]' addDir(name, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), NETWORK_ID=SECPLUS_ID), defaultlive)
def root_menu(self, args): # TVOS home url = base64.b64decode( 'aHR0cDovL3dhdGNoLnByb2R1Y3QuYXBpLmVzcG4uY29tL2FwaS9wcm9kdWN0L3YxL3R2b3Mvd2F0Y2hlc3BuL2hvbWU=') self.parse_json(args, url) addDir(translation(30550), dict(MODE=self.make_mode(SPORTS)), defaultlive) addDir(translation(30560), dict(MODE=self.make_mode(CHANNELS)), defaultlive) xbmcplugin.endOfDirectory(pluginhandle)
def root_menu(self, args): # TVOS home url = base64.b64decode( 'aHR0cDovL3dhdGNoLnByb2R1Y3QuYXBpLmVzcG4uY29tL2FwaS9wcm9kdWN0L3YxL3R2b3Mvd2F0Y2hlc3BuL2hvbWU=' ) self.parse_json(args, url) addDir(translation(30550), dict(MODE=self.make_mode(SPORTS)), defaultlive) addDir(translation(30560), dict(MODE=self.make_mode(CHANNELS)), defaultlive) xbmcplugin.endOfDirectory(pluginhandle)
def list_sports(self, args): espn_url = args.get(ESPN_URL)[0] if 'action=replay' in espn_url: image = defaultreplay elif 'action=upcoming' in espn_url: image = defaultupcoming else: image = defaultimage addDir(translation(30034), dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE)), image) sports = [] sport_elements = util.get_url_as_xml_cache( espn_url, encoding='ISO-8859-1').findall('.//sportDisplayValue') for sport in sport_elements: sport = sport.text.encode('utf-8') if sport not in sports: sports.append(sport) for sport in sports: addDir( sport, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), SPORT=sport), image) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE) 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 process_item_list(self, item_list): stashes = list() for item in item_list: stash_element = item.find('./stash/json') if item.get('id').startswith('loadMore'): method_info = util.parse_method_call(item.get('onSelect')) if method_info[0] == 'espn.page.loadMore': label = item.find('./label') label2 = item.find('./label2') menu_label = '' if label is not None: menu_label = label.text if label2 is not None: menu_label = menu_label + ' ' + label2.text if label is None and label2 is None: menu_label = translation(30570) url = method_info[3] nav_id = method_info[2] url = url + '&navigationItemId=' + nav_id xbmc.log(TAG + 'Load more url %s' % url, xbmc.LOGDEBUG) addDir( menu_label, dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)), defaultimage) elif not item.get('id') == 'no-event': if stash_element is None: # Assume goes to another onPlay with a url name = item.get('accessibilityLabel') image = item.find('./image').get('src') url = util.parse_url_from_method(item.get('onPlay')) addDir( name, dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)), image, image) else: stash = stash_element.text.encode('ISO-8859-1') xbmc.log(TAG + 'Stash Data %s' % (stash), xbmc.LOGDEBUG) # Some of the json is baddly formatted stash = re.sub(r'\s+"', '"', stash) stash_json = json.loads(stash) #, 'utf-8') stash_json['internal_item'] = item stashes.append(stash_json) xbmc.log(TAG + ' sorting %s items' % len(stashes), xbmc.LOGDEBUG) stashes.sort(cmp=compare_appletv) for stash_json in stashes: if stash_json['type'] == 'upcoming': self.index_tv_shelf(stash_json, True) elif 'sessionUrl' in stash_json: self.index_tv_shelf(stash_json, False) else: self.index_item_shelf(stash_json)
def process_item_list(self, item_list): stashes = list() for item in item_list: stash_element = item.find('./stash/json') if item.get('id').startswith('loadMore'): method_info = util.parse_method_call(item.get('onSelect')) if method_info[0] == 'espn.page.loadMore': label = item.find('./label') label2 = item.find('./label2') menu_label = '' if label is not None: menu_label = label.text if label2 is not None: menu_label = menu_label + ' ' + label2.text if label is None and label2 is None: menu_label = translation(30570) url = method_info[3] nav_id = method_info[2] url = url + '&navigationItemId=' + nav_id xbmc.log(TAG + 'Load more url %s' % url, xbmc.LOGDEBUG) addDir(menu_label, dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)), defaultimage) elif not item.get('id') == 'no-event': if stash_element is None: # Assume goes to another onPlay with a url name = item.get('accessibilityLabel') image = item.find('./image').get('src') url = util.parse_url_from_method(item.get('onPlay')) addDir(name, dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)), image, image) else: stash = stash_element.text.encode('ISO-8859-1') xbmc.log(TAG + 'Stash Data %s' % (stash), xbmc.LOGDEBUG) # Some of the json is baddly formatted stash = re.sub(r'\s+"', '"', stash) stash_json = json.loads(stash) #, 'utf-8') stash_json['internal_item'] = item stashes.append(stash_json) xbmc.log(TAG + ' sorting %s items' % len(stashes), xbmc.LOGDEBUG) stashes.sort(cmp=compare_appletv) for stash_json in stashes: if stash_json['type'] == 'upcoming': self.index_tv_shelf(stash_json, True) elif 'sessionUrl' in stash_json: self.index_tv_shelf(stash_json, False) else: self.index_item_shelf(stash_json)
def list_sports(self, args): espn_url = args.get(ESPN_URL)[0] if 'action=replay' in espn_url: image = defaultreplay elif 'action=upcoming' in espn_url: image = defaultupcoming else: image = defaultimage addDir(translation(30034), dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE)), image) sports = [] sport_elements = util.get_url_as_xml_soup_cache(espn_url).findall('.//sportDisplayValue') for sport in sport_elements: sport = sport.text.encode('utf-8') if sport not in sports: sports.append(sport) for sport in sports: addDir(sport, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), SPORT=sport), image) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE) 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)
def index_legacy_live_events(self, args): espn_url = args.get(ESPN_URL)[0] chosen_sport = args.get(SPORT, None) if chosen_sport is not None: chosen_sport = chosen_sport[0] chosen_network = args.get(NETWORK_ID, None) if chosen_network is not None: chosen_network = chosen_network[0] live = 'action=live' in espn_url upcoming = 'action=upcoming' in espn_url replay = 'action=replay' in espn_url if live: data = events.get_events(espn_url) else: data = util.get_url_as_xml_cache( espn_url, encoding='ISO-8859-1').findall(".//event") num_espn3 = 0 num_secplus = 0 num_accextra = 0 num_events = 0 for event in data: sport = event.find('sportDisplayValue').text.encode('utf-8') if chosen_sport <> sport and chosen_sport is not None: continue networkid = event.find('networkId').text if chosen_network <> networkid and chosen_network is not None: continue if networkid == ESPN3_ID and chosen_network is None and live: num_espn3 += 1 elif networkid == SECPLUS_ID and chosen_network is None and live: num_secplus += 1 elif networkid == ACC_EXTRA_ID and chosen_network is None and live: num_accextra += 1 else: num_events += 1 self.index_event(event, live, upcoming, replay, chosen_sport) # Don't show ESPN3 folder if there are no premium events if num_events == 0: for event in data: sport = event.find('sportDisplayValue').text.encode('utf-8') if chosen_sport <> sport and chosen_sport is not None: continue self.index_event(event, live, upcoming, replay, chosen_sport) # Dir for ESPN3/SECPlus/ACC Extra elif chosen_network is None: if num_espn3 > 0 and selfAddon.getSetting('ShowEspn3') == 'true': translation_number = 30191 if num_espn3 == 1 else 30190 if selfAddon.getSetting('NoColors') == 'true': name = translation(translation_number) % num_espn3 else: name = '[COLOR=FFCC0000]' + ( translation(translation_number) % num_espn3) + '[/COLOR]' addDir( name, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), NETWORK_ID=ESPN3_ID), defaultlive) if num_secplus > 0 and selfAddon.getSetting( 'ShowSecPlus') == 'true': translation_number = 30201 if num_secplus == 1 else 30200 if selfAddon.getSetting('NoColors') == 'true': name = translation(translation_number) % num_secplus else: name = '[COLOR=FF004C8D]' + ( translation(translation_number) % num_secplus) + '[/COLOR]' addDir( name, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), NETWORK_ID=SECPLUS_ID), defaultlive) if num_accextra > 0 and selfAddon.getSetting( 'ShowAccExtra') == 'true': translation_number = 30203 if num_accextra == 1 else 30202 if selfAddon.getSetting('NoColors') == 'true': name = translation(translation_number) % num_accextra else: name = '[COLOR=FF013ca6]' + ( translation(translation_number) % num_accextra) + '[/COLOR]' addDir( name, dict(ESPN_URL=espn_url, MODE=self.make_mode(LIVE_EVENTS_MODE), NETWORK_ID=ACC_EXTRA_ID), defaultlive)