Esempio n. 1
0
 def categories_showcase(self, args):
     url = args.get(SHOWCASE_URL)[0]
     selected_nav_id = args.get(SHOWCASE_NAV_ID, None)
     et = util.get_url_as_xml_soup_cache(get_url(url))
     navigation_items = et.findall('.//navigation/navigationItem')
     xbmc.log('ESPN3 Found %s items' % len(navigation_items), xbmc.LOGDEBUG)
     if selected_nav_id is None and len(navigation_items) > 0:
         for navigation_item in navigation_items:
             name = navigation_item.find('./title').text
             nav_id = navigation_item.get('id')
             menu_item = navigation_item.find('.//twoLineMenuItem')
             if menu_item is None:
                 menu_item = navigation_item.find('.//twoLineEnhancedMenuItem')
             if menu_item is not None and not menu_item.get('id') == 'no-event':
                 addDir(name,
                        dict(SHOWCASE_URL=url, SHOWCASE_NAV_ID=nav_id, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)), defaultfanart)
     elif len(navigation_items) > 0:
         for navigation_item in navigation_items:
             if navigation_item.get('id') == selected_nav_id[0]:
                 xbmc.log('ESPN3 Found nav item %s' % selected_nav_id[0], xbmc.LOGDEBUG)
                 self.process_item_list(navigation_item.findall('.//twoLineMenuItem'))
                 self.process_item_list(navigation_item.findall('.//twoLineEnhancedMenuItem'))
                 xbmcplugin.setContent(pluginhandle, 'episodes')
     else: # If there are no navigation items then just dump all of the menu entries
         xbmc.log('ESPN3: Dumping all menu items', xbmc.LOGDEBUG)
         self.process_item_list(et.findall('.//twoLineMenuItem'))
         self.process_item_list(et.findall('.//twoLineEnhancedMenuItem'))
         xbmcplugin.setContent(pluginhandle, 'episodes')
     xbmcplugin.endOfDirectory(pluginhandle)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 def category_shelf(self, args):
     featured_url = base64.b64decode('aHR0cDovL2VzcG4uZ28uY29tL3dhdGNoZXNwbi9hcHBsZXR2L2ZlYXR1cmVk')
     et = util.get_url_as_xml_soup_cache(get_url(featured_url))
     for shelf in et.findall('.//shelf'):
         name = shelf.get('id')
         if name == args.get(SHELF_ID)[0]:
             self.process_item_list(shelf.findall('.//sixteenByNinePoster'))
     xbmcplugin.setContent(pluginhandle, 'episodes')
     xbmcplugin.endOfDirectory(pluginhandle)
Esempio n. 5
0
 def category_channels(self, args):
     channels_url = base64.b64decode('aHR0cDovL2VzcG4uZ28uY29tL3dhdGNoZXNwbi9hcHBsZXR2L2NoYW5uZWxz')
     et = util.get_url_as_xml_soup_cache(get_url(channels_url))
     for channel in et.findall('.//oneLineMenuItem'):
         name = channel.get('accessibilityLabel')
         image = channel.find('.//image').text
         url = util.parse_url_from_method(channel.get('onSelect'))
         addDir(name,
                dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)),
                image, image)
     xbmcplugin.setContent(pluginhandle, 'episodes')
     xbmcplugin.endOfDirectory(pluginhandle, updateListing=False)
Esempio n. 6
0
 def category_sports(self, args):
     sports_url = base64.b64decode('aHR0cDovL2VzcG4uZ28uY29tL3dhdGNoZXNwbi9hcHBsZXR2L3Nwb3J0cw==')
     et = util.get_url_as_xml_soup_cache(get_url(sports_url))
     images = et.findall('.//image')
     sports = et.findall('.//oneLineMenuItem')
     for i in range(0, min(len(images), len(sports))):
         sport = sports[i]
         image = images[i]
         name = sport.get('accessibilityLabel')
         image = image.text
         url = util.parse_url_from_method(sport.get('onSelect'))
         addDir(name,
                dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)),
                image, image)
     xbmcplugin.endOfDirectory(pluginhandle, updateListing=False)
Esempio n. 7
0
 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)
Esempio n. 8
0
 def featured_menu(self, args):
     featured_url = base64.b64decode('aHR0cDovL2VzcG4uZ28uY29tL3dhdGNoZXNwbi9hcHBsZXR2L2ZlYXR1cmVk')
     et = util.get_url_as_xml_soup_cache(get_url(featured_url))
     for showcase in et.findall('.//showcase/items/showcasePoster'):
         name = showcase.get('accessibilityLabel')
         image = showcase.find('./image').get('src')
         url = util.parse_url_from_method(showcase.get('onPlay'))
         addDir(name,
                dict(SHOWCASE_URL=url, MODE=self.make_mode(CATEGORY_SHOWCASE_MODE)),
                image, image)
     collections = et.findall('.//collectionDivider')
     shelfs = et.findall('.//shelf')
     for i in range(0, len(collections)):
         collection_divider = collections[i]
         shelf = shelfs[i]
         title = collection_divider.find('title').text
         name = shelf.get('id')
         addDir(title,
                dict(SHELF_ID=name, MODE=self.make_mode(CATEGORY_SHELF_MODE)),
                defaultlive)
     xbmcplugin.endOfDirectory(pluginhandle)
Esempio n. 9
0
def get_events(url):
    soup = util.get_url_as_xml_soup_cache(url)
    return soup.findall('.//event')
Esempio n. 10
0
def get_live_events(network_names=None):
    if network_names is None:
        network_names = []
    soup = util.get_url_as_xml_soup_cache(player_config.get_live_event_url())
    return soup.findall('.//event')
Esempio n. 11
0
 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_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)
Esempio n. 12
0
def get_config_soup():
    return util.get_url_as_xml_soup_cache(PLAYER_CONFIG_URL, PLAYER_CONFIG_FILE, TIME_DIFFERENCE)
Esempio n. 13
0
def get_config_soup():
    return util.get_url_as_xml_soup_cache(PLAYER_CONFIG_URL,
                                          PLAYER_CONFIG_FILE, TIME_DIFFERENCE)
Esempio n. 14
0
def get_events(url):
    soup = util.get_url_as_xml_soup_cache(url)
    return soup.findall('.//event')
Esempio n. 15
0
def get_live_events(network_names = []):
    soup = util.get_url_as_xml_soup_cache(player_config.get_live_event_url())
    return soup.findall('.//event')