From 1b8bb0049f590d22c3604f8f78fed225e5cb98fc Mon Sep 17 00:00:00 2001 From: 9Mad-Max5 Date: Sat, 6 Jan 2024 16:51:41 +0100 Subject: [PATCH 1/6] added get histroy --- trakt/sync.py | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/trakt/sync.py b/trakt/sync.py index 4af3a3d9..0193ab28 100644 --- a/trakt/sync.py +++ b/trakt/sync.py @@ -9,7 +9,7 @@ from trakt.utils import slugify, timestamp __author__ = 'Jon Nappi' -__all__ = ['Scrobbler', 'comment', 'rate', 'add_to_history', 'get_collection', +__all__ = ['Scrobbler', 'comment', 'rate', 'get_history', 'add_to_history', 'get_collection', 'get_watchlist', 'add_to_watchlist', 'remove_from_history', 'remove_from_watchlist', 'add_to_collection', 'remove_from_collection', 'search', 'search_by_id', 'checkin_media', @@ -374,38 +374,22 @@ def get_watchlist(list_type=None, sort=None): yield results -@deprecated("This method returns watchlist, not watched list. " - "This will be fixed in PyTrakt 4.x to return watched list") +# @deprecated("This method returns watchlist, not watched list. " +# "This will be fixed in PyTrakt 4.x to return watched list") @get -def get_watched(list_type=None, extended=None): - """Return all movies or shows a user has watched sorted by most plays. - - :param list_type: Optional Filter by a specific type. - Possible values: movies, shows, seasons or episodes. - :param extended: Optional value for requesting extended information. +def get_history(media): """ - valid_type = ('movies', 'shows', 'seasons', 'episodes') - - if list_type and list_type not in valid_type: - raise ValueError('list_type must be one of {}'.format(valid_type)) - - uri = 'sync/watched' - if list_type: - uri += '/{}'.format(list_type) + Retrieve a :class:`Movie`, :class:`TVShow`, or :class:`TVEpisode + from your history. - if list_type == 'shows' and extended: - uri += '?extended={extended}'.format(extended=extended) + :param media: Supports both the PyTrakt :class:`Movie`, + :class:`TVShow`, etc. But also supports passing custom json structures. + """ - data = yield uri - results = [] - for d in data: - if 'movie' in d: - from trakt.movies import Movie - results.append(Movie(**d.pop('movie'))) - elif 'show' in d: - from trakt.tv import TVShow - results.append(TVShow(**d.pop('show'))) + uri = 'sync/history' + uri += f'/{media.media_type}/{media.ids["ids"]["trakt"]}' + results = yield uri yield results From c8279240d0caadf2f5ca2179afb8bf2dc65533f7 Mon Sep 17 00:00:00 2001 From: 9Mad-Max5 Date: Tue, 9 Jan 2024 00:20:22 +0100 Subject: [PATCH 2/6] adjusted gitignore and added studios --- .gitignore | 2 ++ trakt/tv.py | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 25388c58..c15a9fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ nosetests.xml # Virtual environments venv +*.log +*.json \ No newline at end of file diff --git a/trakt/tv.py b/trakt/tv.py index 91db5b58..381a0e06 100644 --- a/trakt/tv.py +++ b/trakt/tv.py @@ -18,7 +18,7 @@ __all__ = ['dismiss_recommendation', 'get_recommended_shows', 'genres', 'popular_shows', 'trending_shows', 'updated_shows', 'recommended_shows', 'played_shows', 'watched_shows', - 'collected_shows', 'anticipated_shows', 'TVShow', 'TVEpisode', + 'collected_shows', 'anticipated_shows', 'studios', 'TVShow', 'TVEpisode', 'TVSeason', 'Translation'] @@ -201,6 +201,20 @@ def anticipated_shows(page=1, limit=10, extended=None): data = yield uri yield [TVShow(**show['show']) for show in data] +@get +def studios(tvshow): + """ + Check :class:`TVShow`' for published studios + as well the title can be passed directly. + """ + if isinstance(tvshow, TVShow): + title = tvshow.slug + + uri = f'shows/{title}/studios' + + data = yield uri + yield data + class TVShow(IdsMixin): """A Class representing a TV Show object.""" @@ -341,7 +355,7 @@ def progress(self): The next_episode will be the next episode the user should collect, if there are no upcoming episodes it will be set to null. """ - return self._progress('collection') + return self._progress('watched') @get def collection_progress(self, **kwargs): From 7ba3e668f608474747f895aaaab4c9d7034db2cb Mon Sep 17 00:00:00 2001 From: 9Mad-Max5 Date: Tue, 9 Jan 2024 19:53:45 +0100 Subject: [PATCH 3/6] roll back gitignore changes --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index c15a9fbb..25388c58 100644 --- a/.gitignore +++ b/.gitignore @@ -40,5 +40,3 @@ nosetests.xml # Virtual environments venv -*.log -*.json \ No newline at end of file From 02d4855c6799f886815604852f7d41f704e90ce9 Mon Sep 17 00:00:00 2001 From: 9Mad-Max5 Date: Tue, 9 Jan 2024 22:57:33 +0100 Subject: [PATCH 4/6] Bring back the removed parts --- trakt/sync.py | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/trakt/sync.py b/trakt/sync.py index 0193ab28..15584c87 100644 --- a/trakt/sync.py +++ b/trakt/sync.py @@ -9,7 +9,7 @@ from trakt.utils import slugify, timestamp __author__ = 'Jon Nappi' -__all__ = ['Scrobbler', 'comment', 'rate', 'get_history', 'add_to_history', 'get_collection', +__all__ = ['Scrobbler', 'comment', 'rate', 'get_watched', 'get_history', 'add_to_history', 'get_collection', 'get_watchlist', 'add_to_watchlist', 'remove_from_history', 'remove_from_watchlist', 'add_to_collection', 'remove_from_collection', 'search', 'search_by_id', 'checkin_media', @@ -374,8 +374,41 @@ def get_watchlist(list_type=None, sort=None): yield results -# @deprecated("This method returns watchlist, not watched list. " -# "This will be fixed in PyTrakt 4.x to return watched list") +@deprecated("This method returns watchlist, not watched list. " + "This will be fixed in PyTrakt 4.x to return watched list") +@get +def get_watched(list_type=None, extended=None): + """Return all movies or shows a user has watched sorted by most plays. + + :param list_type: Optional Filter by a specific type. + Possible values: movies, shows, seasons or episodes. + :param extended: Optional value for requesting extended information. + """ + valid_type = ('movies', 'shows', 'seasons', 'episodes') + + if list_type and list_type not in valid_type: + raise ValueError('list_type must be one of {}'.format(valid_type)) + + uri = 'sync/watched' + if list_type: + uri += '/{}'.format(list_type) + + if list_type == 'shows' and extended: + uri += '?extended={extended}'.format(extended=extended) + + data = yield uri + results = [] + for d in data: + if 'movie' in d: + from trakt.movies import Movie + results.append(Movie(**d.pop('movie'))) + elif 'show' in d: + from trakt.tv import TVShow + results.append(TVShow(**d.pop('show'))) + + yield results + + @get def get_history(media): """ @@ -387,7 +420,7 @@ def get_history(media): """ uri = 'sync/history' - uri += f'/{media.media_type}/{media.ids["ids"]["trakt"]}' + uri += f'/{media.media_type}/{media.trakt}' results = yield uri yield results From 63e2609509004b17fe4aa69f2eb97c3189634d71 Mon Sep 17 00:00:00 2001 From: 9Mad-Max5 Date: Tue, 9 Jan 2024 23:26:16 +0100 Subject: [PATCH 5/6] back to normal --- trakt/sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trakt/sync.py b/trakt/sync.py index 15584c87..3537beb2 100644 --- a/trakt/sync.py +++ b/trakt/sync.py @@ -9,7 +9,7 @@ from trakt.utils import slugify, timestamp __author__ = 'Jon Nappi' -__all__ = ['Scrobbler', 'comment', 'rate', 'get_watched', 'get_history', 'add_to_history', 'get_collection', +__all__ = ['Scrobbler', 'comment', 'rate', 'get_history', 'add_to_history', 'get_collection', 'get_watchlist', 'add_to_watchlist', 'remove_from_history', 'remove_from_watchlist', 'add_to_collection', 'remove_from_collection', 'search', 'search_by_id', 'checkin_media', From f5a152fadf636e98669fd6ffb66f2aac789db8d1 Mon Sep 17 00:00:00 2001 From: 9Mad-Max5 Date: Mon, 15 Jan 2024 12:58:29 +0100 Subject: [PATCH 6/6] set version to alpha to directly install it --- trakt/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trakt/__version__.py b/trakt/__version__.py index 4f7facb8..e1f88202 100644 --- a/trakt/__version__.py +++ b/trakt/__version__.py @@ -1 +1 @@ -__version__ = "Unknown" +__version__ = "alpha"