Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trakt recommended shows #9080

Merged
merged 5 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ext | **`subliminal`** | [2.1.0](https://pypi.org/project/subliminal/2.1.0/) | *
ext | **`tmdbsimple`** | [2.7.0](https://pypi.org/project/tmdbsimple/2.7.0/) | **`medusa`** | -
ext | **`tornado`** | [6.1](https://pypi.org/project/tornado/6.1/) | **`medusa`**, `tornroutes` | -
ext | **`tornroutes`** | [0.5.1](https://pypi.org/project/tornroutes/0.5.1/) | **`medusa`** | -
ext | **`trakt`** | [2.14.1](https://pypi.org/project/trakt/2.14.1/) | **`medusa`** | -
ext | **`trakt`** | p0psicles/[8de5bfb](https://github.com/p0psicles/PyTrakt/tree/8de5bfb04b3d5ee54e4a3b25db0e4c341cc31384) | **`medusa`** | -
ext | `trans` | [2.1.0](https://pypi.org/project/trans/2.1.0/) | `imdbpie` | File: `trans.py`
ext | `ttl-cache` | [1.6](https://pypi.org/project/ttl-cache/1.6/) | **`medusa`** | File: `ttl_cache.py`
ext | **`tvdbapiv2`** | pymedusa/[bf1272c](https://github.com/pymedusa/tvdbv2/tree/bf1272c9264c280c3048e89a1920e2bf5f386284) | **`medusa`** | -
Expand Down
27 changes: 17 additions & 10 deletions ext/trakt/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pprint import pformat
from trakt.core import get
from trakt.movies import Movie
from trakt.tv import TVEpisode
from trakt.utils import now, airs_date
from trakt.tv import TVEpisode, TVShow
from trakt.utils import extract_ids, now, airs_date

__author__ = 'Jon Nappi'
__all__ = ['Calendar', 'PremiereCalendar', 'MyPremiereCalendar',
Expand Down Expand Up @@ -66,14 +66,21 @@ def _get(self):
def _build(self, data):
"""Build the calendar"""
self._calendar = []
for episode in data:
show = episode.get('show', {}).get('title')
season = episode.get('episode', {}).get('season')
ep = episode.get('episode', {}).get('number')
e_data = {'airs_at': airs_date(episode.get('first_aired')),
'ids': episode.get('episode').get('ids'),
'title': episode.get('episode', {}).get('title')}
self._calendar.append(TVEpisode(show, season, ep, **e_data))
for cal_item in data:
show_data = cal_item.get('show', {})
episode = cal_item.get('episode', {})
first_aired = cal_item.get('first_aired')
season = episode.get('season')
ep_num = episode.get('number')
extract_ids(show_data)
show_data.update(show_data)
e_data = {
'airs_at': airs_date(first_aired),
'ids': episode.get('ids'),
'title': show_data.get('title'),
'show_data': TVShow(**show_data)
}
self._calendar.append(TVEpisode(show_data['trakt'], season, ep_num, **e_data))
self._calendar = sorted(self._calendar, key=lambda x: x.airs_at)


Expand Down
2 changes: 1 addition & 1 deletion ext/trakt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'init', 'BASE_URL', 'CLIENT_ID', 'CLIENT_SECRET', 'DEVICE_AUTH',
'REDIRECT_URI', 'HEADERS', 'CONFIG_PATH', 'OAUTH_TOKEN',
'OAUTH_REFRESH', 'PIN_AUTH', 'OAUTH_AUTH', 'AUTH_METHOD',
'APPLICATION_ID', 'get_device_code', 'get_device_token']
'APPLICATION_ID', 'get_device_code']

#: The base url for the Trakt API. Can be modified to run against different
#: Trakt.tv environments
Expand Down
6 changes: 4 additions & 2 deletions medusa/helpers/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ def get_trakt_show_collection(trakt_list, limit=None):
elif trakt_list == 'recommended':
return tv.recommended_shows(extended='full,images')
elif trakt_list == 'newshow':
return calendar.PremiereCalendar(days=30, extended='full,images', returns='shows')
calendar_items = calendar.PremiereCalendar(days=30, extended='full,images')
return [tv_episode.show_data for tv_episode in calendar_items]
elif trakt_list == 'newseason':
return calendar.SeasonCalendar(days=30, extended='full,images', returns='shows')
calendar_items = calendar.SeasonCalendar(days=15, extended='full,images')
return [tv_episode.show_data for tv_episode in calendar_items]

return tv.anticipated_shows(limit=limit, extended='full,images')
except TraktException as error:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ subliminal==2.1.0
tmdbsimple==2.7.0
tornado==6.1
tornroutes==0.5.1
trakt==2.14.1
trakt @ https://codeload.github.com/p0psicles/PyTrakt/tar.gz/8de5bfb04b3d5ee54e4a3b25db0e4c341cc31384
ttl-cache==1.6
tvdbapiv2 @ https://codeload.github.com/pymedusa/tvdbv2/tar.gz/bf1272c9264c280c3048e89a1920e2bf5f386284
validators==0.18.2