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_list_matches_highlights(self): for mode in ['SUPER_NETBALL', 'INTERNATIONAL']: responses.add(responses.GET, config.LONGLIST_URL.format(mode=mode), body=self.TAGGEDLIST_HIGHLIGHTS_XML, status=200) observed = comm.list_matches({'category': 'MatchHighlights'}) self.assertEqual(200, len(observed)) # 100 * 2 self.assertEqual('1647215383533280406', observed[8].video_id)
def test_list_matches_replays(self): for mode in ['SUPER_NETBALL', 'INTERNATIONAL']: responses.add(responses.GET, config.TAGGEDLIST_REPLAY_URL.format(mode=mode), body=self.TAGGEDLIST_REPLAY_XML, status=200) observed = comm.list_matches({'category': 'Match Replays'}) self.assertEqual(400, len(observed)) # 200 * 2 self.assertEqual('1647221321927449747', observed[8].video_id)
def test_list_matches(self): responses.add(responses.GET, config.VIDEO_URL, body=self.MATCH_XML, status=200) listing = comm.list_matches({}) self.assertEqual(4, len(listing)) self.assertEqual('Full', listing[0].title[:4])
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