def __init__(self, _kodi): ''' Initializes TV-guide object ''' self._kodi = _kodi self._favorites = favorites.Favorites(_kodi) self._proxies = _kodi.get_proxies() install_opener(build_opener(ProxyHandler(self._proxies))) self._showfanart = _kodi.get_setting('showfanart', 'true') == 'true'
def __init__(self, _kodi): ''' Initialize searchtes, relies on XBMC vfs ''' self._kodi = _kodi self._favorites = favorites.Favorites(_kodi) self._apihelper = vrtapihelper.VRTApiHelper(_kodi, self._favorites) self._search_history = _kodi.get_userdata_path( ) + 'search_history.json'
class TestSearch(unittest.TestCase): _favorites = favorites.Favorites(addon.kodi) _apihelper = vrtapihelper.VRTApiHelper(addon.kodi, _favorites) def test_search_journaal(self): ''' Test for journaal ''' search_items, sort, ascending, content = self._apihelper.get_search_items( 'journaal', page=1) # Test we get a non-empty search result self.assertEqual(len(search_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_search_journaal_page2(self): ''' Test for journaal ''' search_items, sort, ascending, content = self._apihelper.get_search_items( 'journaal', page=2) # Test we get a non-empty search result self.assertEqual(len(search_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_search_journaal_page3(self): ''' Test for journaal ''' search_items, sort, ascending, content = self._apihelper.get_search_items( 'journaal', page=3) # Test we get a non-empty search result self.assertEqual(len(search_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_search_weer(self): ''' Test for journaal ''' search_items, sort, ascending, content = self._apihelper.get_search_items( 'weer', page=1) # Test we get a non-empty search result self.assertEqual(len(search_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes')
class TestFavorites(unittest.TestCase): _favorites = favorites.Favorites(addon.kodi) def test_follow_unfollow(self): programs = [ { 'program_title': 'Winteruur', 'program': 'winteruur' }, { 'program_title': 'De Campus Cup', 'program': 'de-campus-cup' }, { 'program_title': 'Terug naar Siberiƫ', 'program': 'terug-naar-siberie' }, { 'program_title': '22/3 - 1 jaar later - het onderzoek', 'program': '22-3-1-jaar-later---het-onderzoek' }, { 'program_title': 'Belle & Sebastian', 'program': 'belle---sebastian' }, ] for program_item in programs: program_title = program_item.get('program_title') program = program_item.get('program') self._favorites.follow(program=program, title=program_title) self.assertTrue(self._favorites.is_favorite(program)) self._favorites.unfollow(program=program, title=program_title) self.assertFalse(self._favorites.is_favorite(program)) self._favorites.follow(program=program, title=program_title) self.assertTrue(self._favorites.is_favorite(program)) def test_programs(self): programs = self._favorites.programs() self.assertTrue(programs) print(programs) def test_titles(self): titles = self._favorites.titles() self.assertTrue(titles) print(sorted(titles))
def Search(url): keyword = utils._get_keyboard(heading="Searching for...") if (not keyword): return False, 0 try: response = utils.getHtml(url + keyword) except: utils.notify('Model not found - try again') return None match = re.compile("p_signupargs: 'smid%3D([^']+)'", re.DOTALL | re.IGNORECASE).findall(response) if match: utils.notify('Found ' + keyword + ' adding to favorites now') img = "http://m1.nsimg.net/media/snap/" + match[0] + ".jpg" performerID = match[0] name = keyword favorites.Favorites('add', 'Playvid', name, performerID, img)
def favorites_refresh(): ''' The API interface to refresh the favorites cache ''' from resources.lib import favorites favorites.Favorites(kodi).get_favorites(ttl=0)
def unfollow(program, title): ''' The API interface to unfollow a program used by the context menu ''' from resources.lib import favorites favorites.Favorites(kodi).unfollow(program=program, title=title)
pornkinox.Search(url, keyword) elif mode == 474: pornkinox.Categories(url) elif mode == 475: camsoda.Main() elif mode == 476: camsoda.List(url) elif mode == 478: camsoda.Playvid(url, name) elif mode == 479: camsoda.clean_database(True) elif mode == 480: naked.Main() elif mode == 481: naked.List(url) elif mode == 482: naked.Playvid(url, name) elif mode == 483: naked.clean_database(True) elif mode == 900: favorites.Favorites(fav, favmode, name, url, img) elif mode == 901: favorites.List() elif mode == 902: utils.newSearch(url, channel) elif mode == 903: utils.clearSearch() xbmcplugin.endOfDirectory(utils.addon_handle)
class TestVRTPlayer(unittest.TestCase): _favorites = favorites.Favorites(addon.kodi) _apihelper = vrtapihelper.VRTApiHelper(addon.kodi, _favorites) _vrtplayer = vrtplayer.VRTPlayer(addon.kodi) def test_show_videos_single_episode_shows_videos(self): program = 'marathonradio' episode_items, sort, ascending, content = self._apihelper.get_episode_items(program=program) self.assertTrue(episode_items, msg=program) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') self._vrtplayer.show_episodes(program) # self.assertTrue(self._kodi.show_listing.called) def test_show_videos_single_season_shows_videos(self): program = 'het-weer' episode_items, sort, ascending, content = self._apihelper.get_episode_items(program=program) self.assertTrue(episode_items, msg=program) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') self._vrtplayer.show_episodes(program) # self.assertTrue(self._kodi.show_listing.called) def test_show_videos_multiple_seasons_shows_videos(self): program = 'pano' episode_items, sort, ascending, content = self._apihelper.get_episode_items(program=program) self.assertTrue(episode_items) self.assertEqual(sort, 'label') self.assertFalse(ascending) self.assertEqual(content, 'seasons') self._vrtplayer.show_episodes(program) # self.assertTrue(self._kodi.show_listing.called) def test_show_videos_specific_seasons_shows_videos(self): program = 'thuis' episode_items, sort, ascending, content = self._apihelper.get_episode_items(program=program) self.assertTrue(episode_items, msg=program) self.assertEqual(sort, 'label') self.assertFalse(ascending) self.assertEqual(content, 'seasons') self._vrtplayer.show_episodes(program) # self.assertTrue(self._kodi.show_listing.called) def test_categories_scraping(self): ''' Test to ensure our hardcoded categories conforms to scraped categories ''' # Remove thumbnails from scraped categories first categories_scraped = [dict(id=c['id'], name=c['name']) for c in self._apihelper.get_categories()] categories_stored = [dict(id=c['id'], name=c['name']) for c in CATEGORIES] self.assertEqual(categories_scraped, categories_stored) def test_random_tvshow_episodes(self): ''' Rest episode from a random tvshow in a random category ''' categories = self._apihelper.get_categories() self.assertTrue(categories) category = random.choice(categories) tvshow_items = self._apihelper.get_tvshow_items(category['id']) self.assertTrue(tvshow_items, msg=category['id']) tvshow = random.choice(tvshow_items) if tvshow.path.startswith('plugin://plugin.video.vrt.nu/programs/'): # When random program has episodes episode_items, sort, ascending, content = self._apihelper.get_episode_items(tvshow.path.split('/')[4].replace('.relevant', '')) self.assertTrue(episode_items, msg=tvshow.path.split('/')[4]) self.assertTrue(sort in ['dateadded', 'episode', 'label', 'unsorted']) self.assertTrue(ascending is True or ascending is False) self.assertTrue(content in ['episodes', 'seasons'], "Content for '%s' is '%s'" % (tvshow.title, content)) elif tvshow.path.startswith('plugin://plugin.video.vrt.nu/play/id/'): # When random program is playable item pass else: self.fail('We did not expect this, either we find episodes or it is a playable item') def test_categories(self): ''' Test to ensure our hardcoded categories conforms to scraped categories ''' category_items = self._apihelper.get_category_items() self.assertEqual(len(category_items), 17) def test_featured(self): ''' Test to ensure our hardcoded categories conforms to scraped categories ''' featured_items = self._apihelper.get_featured_items() self.assertEqual(len(featured_items), 7)
class ApiHelperTests(unittest.TestCase): _favorites = favorites.Favorites(addon.kodi) _apihelper = vrtapihelper.VRTApiHelper(addon.kodi, _favorites) def test_get_api_data_single_season(self): title_items, sort, ascending, content = self._apihelper.get_episode_items( program='het-journaal') self.assertTrue(120 <= len(title_items) <= 140, 'We got %s items instead.' % len(title_items)) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_get_api_data_multiple_seasons(self): title_items, sort, ascending, content = self._apihelper.get_episode_items( program='thuis') self.assertTrue(len(title_items) < 5) self.assertEqual(sort, 'label') self.assertFalse(ascending) self.assertEqual(content, 'seasons') def test_get_api_data_specific_season(self): title_items, sort, ascending, content = self._apihelper.get_episode_items( program='pano') self.assertEqual(len(title_items), 4) self.assertEqual(sort, 'label') self.assertFalse(ascending) self.assertEqual(content, 'seasons') def test_get_api_data_specific_season_without_broadcastdate(self): title_items, sort, ascending, content = self._apihelper.get_episode_items( program='postbus-x') self.assertEqual(len(title_items), 3) self.assertEqual(sort, 'label') self.assertTrue(ascending) self.assertEqual(content, 'seasons') def test_get_recent_episodes(self): ''' Test items, sort and order ''' episode_items, sort, ascending, content = self._apihelper.get_episode_items( page=1, variety='recent') self.assertEqual(len(episode_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_get_recent_episodes_page1(self): ''' Test items, sort and order ''' episode_items, sort, ascending, content = self._apihelper.get_episode_items( page=2, variety='recent') self.assertEqual(len(episode_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_get_recent_episodes_page2(self): ''' Test items, sort and order ''' episode_items, sort, ascending, content = self._apihelper.get_episode_items( page=3, variety='recent') self.assertEqual(len(episode_items), 50) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_get_offline_episodes(self): ''' Test items, sort and order ''' episode_items, sort, ascending, content = self._apihelper.get_episode_items( page=1, variety='offline') self.assertTrue(episode_items) self.assertEqual(sort, 'dateadded') self.assertFalse(ascending) self.assertEqual(content, 'episodes') def test_get_tvshows(self): ''' Test items, sort and order ''' category = 'nieuws-en-actua' tvshow_items = self._apihelper.get_tvshow_items(category=category) self.assertTrue(tvshow_items) def test_tvshows(self): ''' Test A-Z tvshow listing and CHANNELS list ''' tvshow_items = self._apihelper.get_tvshow_items(category=None) # Test we get a non-empty A-Z listing back self.assertTrue(tvshow_items) # Test every brand is a known channel studio name bogus_brands = ['lang-zullen-we-lezen', 'VRT'] channel_studios = [c.get('studio') for c in CHANNELS] + bogus_brands for tvshow in tvshow_items: self.assertTrue( tvshow.info_dict['studio'] in channel_studios, '%s | %s | %s' % (tvshow.title, tvshow.info_dict['studio'], channel_studios)) def test_get_latest_episode(self): video = self._apihelper.get_latest_episode(program='het-journaal') self.assertTrue(len(video) == 2) self.assertTrue(video.get('video_id') is not None) self.assertTrue(video.get('publication_id') is not None)
def __init__(self, _kodi): ''' Initialise object ''' self._kodi = _kodi self._favorites = favorites.Favorites(_kodi) self._apihelper = vrtapihelper.VRTApiHelper(_kodi, self._favorites)