def test_get_category_programs(self): params = {'category': 'Programs'} responses.add(responses.GET, config.CONFIG_URL, body=self.VIDEO_CONFIG_JSON, status=200) observed = comm.get_category(params) self.assertEqual(18, len(observed)) self.assertEqual('Genres', observed[0].get_title())
def test_get_category_channel(self): params = { 'item_type': 'Channel', 'obj_type': 'Series', 'feed_id': 'SBS2', 'title': 'SBS VICELAND' } responses.add(responses.GET, config.CONFIG_URL, body=self.VIDEO_CONFIG_JSON, status=200) observed = comm.get_category(params) self.assertEqual(3, len(observed)) self.assertEqual('From Last Night', observed[0].get_title()) self.assertIn('SBS2', observed[0].feed_url)
def test_get_category_film_genre(self): params = { 'item_type': 'FilmGenre', 'obj_type': 'Series', 'thumb': 'https://foo.bar/drama.jpg', 'title': 'Drama' } responses.add(responses.GET, config.CONFIG_URL, body=self.VIDEO_CONFIG_JSON, status=200) observed = comm.get_category(params) self.assertEqual(3, len(observed)) self.assertEqual('Recently Added', observed[0].get_title()) self.assertIn('Drama', observed[0].feed_url)
def make_category_list(params): utils.log("Making category list") try: categories = comm.get_category(params) ok = True for c in categories: url = '{0}?{1}'.format(sys.argv[0], c.make_kodi_url()) thumb = c.get_thumb() listitem = comm.create_listitem(label=c.get_list_title()) listitem.setArt({'thumb': thumb, 'icon': thumb}) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok) xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes') except Exception: utils.handle_error('Unable to build categories list')