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

Feature/replace traktor with pytrakt #8916

Merged
merged 34 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c167f81
Added pytrakt commit 37e7aa3 (master) to /ext.
p0psicles Aug 13, 2018
dbd3a1b
Implemented basic POC device authentication by calling the urls:
p0psicles Aug 13, 2018
6710889
Update moogar0880/pytrakt to 2b1b5d6b032e040db9bb1f9ee094f6a4350f0744
p0psicles Aug 17, 2018
9237686
Renamed /medusa/show/recommendations/trakt -> /medusa/show/recommenda…
p0psicles Sep 14, 2018
eb8ead9
Merge branch 'develop' into feature/replace-traktor-with-pytrakt
p0psicles Sep 14, 2018
1e7632a
Merge remote-tracking branch 'remotes/origin/develop' into feature/re…
p0psicles Dec 18, 2020
fc9a6c2
Fixed config-notifications.vue trakt authentication flow.
p0psicles Dec 19, 2020
5ea4135
Save changes to pyTrakt
p0psicles Dec 24, 2020
fc2c1d0
Added new module helpers/trakt.py to store some basic trakt helpers.
p0psicles Dec 24, 2020
5247443
Fix trakt recommendations/trakt_recommendations.py
p0psicles Dec 24, 2020
a5b5cb1
Replaced traktor calls with pyTrakt.
p0psicles Dec 24, 2020
51bad63
Changed some stuff that I just don't understand.
p0psicles Dec 24, 2020
18371dc
Reverted the ['show'] key change.
p0psicles Dec 24, 2020
83dfae9
Updated the sync/watchlist and sync/collection routes. So it's able t…
p0psicles Dec 26, 2020
af37416
Moved Episode.status to Episode._status.
p0psicles Dec 26, 2020
815dbe4
Trying to adapt the sync/ methods to use PyTrakt.
p0psicles Dec 26, 2020
d1376cd
Update sync.py to allow for passing dicts.
p0psicles Dec 27, 2020
1bc63af
Improved log
p0psicles Dec 27, 2020
98e960b
Moved create_episode_structure and create_show_structure functions to…
p0psicles Dec 27, 2020
5d0ab66
Fixed and refactored the trakt_checker.py sync methods.
p0psicles Dec 27, 2020
667d5be
Sync trakt modules with proposed PR
p0psicles Dec 28, 2020
3dd15e5
Start/Stop trakt_checker thread on changing USE_TRAKT setting.
p0psicles Dec 31, 2020
e49e388
Add exception handling.
p0psicles Jan 1, 2021
84f4422
Fix .pytrakt.json storage location.
p0psicles Jan 1, 2021
9c17d0f
Fix initializing trakt
p0psicles Jan 1, 2021
4b5a3aa
Sync trakt libs.
p0psicles Jan 1, 2021
cdd1274
Merge branch 'develop' into feature/replace-traktor-with-pytrakt
p0psicles Jan 1, 2021
4d51702
Fix lint
p0psicles Jan 1, 2021
e0f6786
Fix flake issues
p0psicles Jan 3, 2021
9ac6999
Remove comments
p0psicles Jan 3, 2021
aee626a
comment
p0psicles Jan 3, 2021
a12592c
Rename
p0psicles Jan 3, 2021
84fdb5a
re-build themes
p0psicles Jan 3, 2021
983b0fc
update changelog
p0psicles Jan 3, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### New Features

#### Improvements
- Replace trakt lib with PyTrakt (and switch to OAuth device authentication) ([8916](https://github.com/pymedusa/Medusa/pull/8916))

#### Fixes
- Fix setting default episode status (after) when adding a new show. ([8918](https://github.com/pymedusa/Medusa/pull/8918))
Expand Down
1 change: 1 addition & 0 deletions ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +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`** | [5.1.1](https://pypi.org/project/tornado/5.1.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 | `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
10 changes: 10 additions & 0 deletions ext/trakt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
"""A wrapper for the Trakt.tv REST API"""
try:
from trakt.core import * # NOQA
except ImportError:
pass

version_info = (2, 14, 1)
__author__ = 'Jon Nappi'
__version__ = '.'.join([str(i) for i in version_info])
131 changes: 131 additions & 0 deletions ext/trakt/calendar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# -*- coding: utf-8 -*-
"""Interfaces to all of the Calendar objects offered by the Trakt.tv API"""
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

__author__ = 'Jon Nappi'
__all__ = ['Calendar', 'PremiereCalendar', 'MyPremiereCalendar',
'ShowCalendar', 'MyShowCalendar', 'SeasonCalendar',
'MySeasonCalendar', 'MovieCalendar', 'MyMovieCalendar']


class Calendar(object):
"""Base :class:`Calendar` type serves as a foundation for other Calendar
types
"""
url = None

def __init__(self, date=None, days=7, extended=None):
"""Create a new :class:`Calendar` object

:param date: Start date of this :class:`Calendar` in the format Ymd
(i.e. 2011-04-21). Defaults to today
:param days: Number of days for this :class:`Calendar`. Defaults to 7
days
"""
super(Calendar, self).__init__()
self.date = date or now()
self.days = days
self._calendar = []
self.extended = extended
self._get()

def __getitem__(self, key):
"""Pass index requests through to the internal _calendar object"""
return self._calendar.__getitem__(key)

def __iter__(self):
"""Custom iterator for iterating over the episodes in this Calendar"""
return iter(self._calendar)

def __len__(self):
"""Returns the length of the episodes list in this calendar"""
return len(self._calendar)

def __str__(self):
"""str representation of this Calendar"""
return pformat(self._calendar)
__repr__ = __str__

@property
def ext(self):
"""construct the fully formatted url for this Calendar"""
uri = '/'.join([self.url, str(self.date), str(self.days)])
if self.extended:
uri += '?extended={extended}'.format(extended=self.extended)
return uri

@get
def _get(self):
data = yield self.ext
self._build(data)

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))
self._calendar = sorted(self._calendar, key=lambda x: x.airs_at)


class PremiereCalendar(Calendar):
"""All shows premiering during the time period specified."""
url = 'calendars/all/shows/new'


class MyPremiereCalendar(Calendar):
"""Personalized calendar of all shows premiering during the time period
specified.
"""
url = 'calendars/my/shows/new'


class ShowCalendar(Calendar):
"""TraktTV ShowCalendar"""
url = 'calendars/all/shows'


class MyShowCalendar(Calendar):
"""Personalized TraktTV ShowCalendar"""
url = 'calendars/my/shows'


class SeasonCalendar(Calendar):
"""TraktTV TV Show Season Premiere"""
url = 'calendars/all/shows/premieres'


class MySeasonCalendar(Calendar):
"""Personalized TraktTV TV Show Season Premiere"""
url = 'calendars/my/shows/premieres'


class MovieCalendar(Calendar):
"""TraktTV Movie Calendar. Returns all movies with a release date during
the time period specified.
"""
url = 'calendars/all/movies'

def _build(self, data):
"""Build the calendar of Movies"""
self._calendar = []
for movie in data:
m_data = movie.get('movie', {})
released = movie.get('released', None)
self._calendar.append(Movie(released=released, **m_data))

self._calendar = sorted(self._calendar, key=lambda x: x.released)


class MyMovieCalendar(MovieCalendar):
"""Personalized TraktTV Movie Calendar."""
url = 'calendars/my/movies'
Loading