def make_matches_list(params): """ Build match listing for Kodi """ try: listing = [] matches = comm.list_matches(params) for m in matches: li = xbmcgui.ListItem(label=str(m.title)) url = '{0}?action=listmatches{1}'.format(_url, m.make_kodi_url()) is_folder = False li.setProperty('IsPlayable', 'true') li.setInfo('video', {'plot': m.title, 'plotoutline': m.title}) li.setArt({'icon': m.thumb, 'thumb': m.thumb}) listing.append((url, li, is_folder)) if params['category'] == 'livematches': upcoming = comm.get_upcoming() for event in upcoming: thumb = os.path.join(addon_path, 'resources', 'soon.jpg') li = xbmcgui.ListItem(event.title) li.setArt({'icon': thumb, 'thumb': thumb}) url = '{0}?action=listmatches{1}'.format( _url, event.make_kodi_url()) is_folder = False listing.append((url, li, is_folder)) xbmcplugin.addSortMethod( _handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addDirectoryItems(_handle, listing, len(listing)) xbmcplugin.endOfDirectory(_handle) except Exception: utils.handle_error('Unable to display matches')
def test_get_upcoming(self): responses.add(responses.GET, config.SCORE_URL, body=self.SCORE_XML, status=200) listing = comm.get_upcoming() self.assertEqual(3, len(listing)) self.assertIn('Roosters', listing[0].title)
def test_get_upcoming(self): responses.add(responses.GET, config.SCORE_URL.format(mode='INTERNATIONAL'), body=self.SCORE_INTERNATIONAL_XML, status=200) responses.add(responses.GET, config.SCORE_URL.format(mode='SUPER_NETBALL'), body=self.SCORE_SUPER_XML, status=200) observed = comm.get_upcoming() # convert to and from to remove xml shebang expected = ('[COLOR red]Upcoming:[/COLOR] {0} v {1} - ' '[COLOR yellow]{2}[/COLOR]').format( 'Melbourne Vixens', 'Queensland Firebirds', 'Saturday 2 May @ 4:00 PM') self.assertEqual(expected, observed[0].title)
def list_matches(params, live=False): """ """ try: handle = int(sys.argv[1]) plugin_url = sys.argv[0] listing = [] if not live: matches = comm.list_matches(params) else: matches = comm.get_live_matches() for m in matches: li = xbmcgui.ListItem(label=str(m.title)) li.setArt({'thumb': m.thumb, 'icon': m.thumb}) url = '{0}?action=listmatches{1}'.format(plugin_url, m.make_kodi_url()) is_folder = False li.setProperty('IsPlayable', 'true') li.setInfo('video', {'plot': m.desc, 'plotoutline': m.desc}) listing.append((url, li, is_folder)) if live: upcoming = comm.get_upcoming() for event in upcoming: thumb = os.path.join(addonPath, 'resources', 'soon.jpg') li = xbmcgui.ListItem(event.title) li.setArt({'icon': thumb, 'thumb': thumb}) url = '{0}?action=listmatches{1}'.format( plugin_url, event.make_kodi_url()) is_folder = False listing.append((url, li, is_folder)) xbmcplugin.addSortMethod( handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addDirectoryItems(handle, listing, len(listing)) xbmcplugin.endOfDirectory(handle) except Exception: utils.handle_error('Unable to fetch match list') raise