From 4545942db5f7f2fb943fdce328462f092e5e4ecf Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 13 Jan 2024 18:09:10 -0500 Subject: [PATCH] feat: add support for tv shows (#46) --- README.rst | 2 +- src/themerr/gui.py | 34 ++++++++++++++++++++++++++++------ tests/unit/test_gui.py | 35 +++++++++++++++++------------------ 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/README.rst b/README.rst index 211bf81..63f395f 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ LizardByte has the full documentation hosted on `Read the Docs Optional[str]: database_type = 'movies' elif self.is_movie_set(): database_type = 'movie_collections' + elif self.is_tv_shows(): + database_type = 'tv_shows' + elif self.is_episodes(): + database_type = 'tv_shows' + elif self.is_seasons(): + database_type = 'tv_shows' if database_type: youtube_url = self.find_youtube_url( @@ -284,6 +302,10 @@ def find_youtube_url(self, kodi_id: str, db_type: str) -> Optional[str]: """ split_id = kodi_id.split('_') db = self._kodi_db_map[split_id[0]] + + if db_type not in self._supported_dbs.keys() or db not in self._supported_dbs[db_type]: + return None + db_id = split_id[1] self.log.debug(f"{db.upper()}_ID: {db_id}") diff --git a/tests/unit/test_gui.py b/tests/unit/test_gui.py index 7e419c3..6e2eff5 100644 --- a/tests/unit/test_gui.py +++ b/tests/unit/test_gui.py @@ -14,7 +14,18 @@ @pytest.fixture( scope='function', params=[ - 'tmdb_10378', + # (kodi_id, db_type, condition) + ('tmdb_9761', 'movies', 'Container.Content(movies)'), # Elephants Dream + ('tmdb_20529', 'movies', 'Container.Content(movies)'), # Sita Sings the Blues + ('tmdb_10378', 'movies', 'Container.Content(movies)'), # Big Buck Bunny + ('tmdb_45745', 'movies', 'Container.Content(movies)'), # Sintel + ('tmdb_645', 'movie_collections', 'ListItem.IsCollection'), # James Bond Collection + ('tmdb_1399', 'tv_shows', 'Container.Content(tvshows)'), # Game of Thrones + ('tmdb_48866', 'tv_shows', 'Container.Content(tvshows)'), # The 100 + ('tmdb_1399', 'tv_shows', 'Container.Content(Seasons)'), # Game of Thrones + ('tmdb_48866', 'tv_shows', 'Container.Content(Seasons)'), # The 100 + ('tmdb_1399', 'tv_shows', 'Container.Content(Episodes)'), # Game of Thrones + ('tmdb_48866', 'tv_shows', 'Container.Content(Episodes)'), # The 100 ], ) def kodi_id(request): @@ -77,24 +88,12 @@ def test_pre_checks_all_passing(window_obj): assert window_obj.pre_checks() is True -def test_process_kodi_id_movies(kodi_id, mock_xbmc_get_cond_visibility, window_obj): - condition = 'Container.Content(movies)' - env_var = f'_KODI_GET_COND_VISIBILITY_{condition}' - os.environ[env_var] = '1' - - youtube_url = window_obj.process_kodi_id(kodi_id=kodi_id) - assert youtube_url - - del os.environ[env_var] - - -def test_process_kodi_id_movie_collection(mock_xbmc_get_cond_visibility, window_obj): - _kodi_id = 'tmdb_645' - condition = 'ListItem.IsCollection' +def test_process_kodi_id(kodi_id, mock_xbmc_get_cond_visibility, window_obj): + condition = kodi_id[2] env_var = f'_KODI_GET_COND_VISIBILITY_{condition}' os.environ[env_var] = '1' - youtube_url = window_obj.process_kodi_id(kodi_id=_kodi_id) + youtube_url = window_obj.process_kodi_id(kodi_id=kodi_id[0]) assert youtube_url del os.environ[env_var] @@ -102,8 +101,8 @@ def test_process_kodi_id_movie_collection(mock_xbmc_get_cond_visibility, window_ def test_find_youtube_url(kodi_id, window_obj): youtube_url = window_obj.find_youtube_url( - kodi_id=kodi_id, - db_type='movies', + kodi_id=kodi_id[0], + db_type=kodi_id[1], ) assert youtube_url