-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
141 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from api.trakt.models.show import Show | ||
|
||
class Shows: | ||
def __init__(self, client): | ||
self.client = client | ||
|
||
def _get_show_list(self, endpoint): | ||
params = {} | ||
response = self.client._get(endpoint, params=params) | ||
return [Show(show) for show in response] | ||
|
||
def get_popular(self): | ||
endpoint = 'shows/popular' | ||
return [Show(show) for show in self.client._get(endpoint)] | ||
|
||
def get_trending(self): | ||
endpoint = 'shows/trending' | ||
return self._get_show_list(endpoint) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from src.tmdb.client import TMDb | ||
|
||
class Episode: | ||
def __init__(self, data): | ||
self.title = data['episode']['title'] | ||
self.show_title = data['show']['title'] | ||
self.season_id = "{:02}".format(data['episode']['season']) # Format as two-digit number | ||
self.episode_id = "{:02}".format(data['episode']['number']) # Format as two-digit number | ||
self.year = data['show']['year'] | ||
self.slug = data['show']['ids']['slug'] | ||
self.trakt_id = data['show']['ids']['trakt'] | ||
self.imdb_id = data['show']['ids']['imdb'] | ||
self.tmdb_id = data['show']['ids']['tmdb'] | ||
self.tvdb_id = data['show']['ids']['tvdb'] | ||
self.poster = TMDb.show_poster_path(self.tvdb_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from src.tmdb.client import TMDb | ||
|
||
class Movie: | ||
def __init__(self, data): | ||
self.title = data['movie']['title'] | ||
self.year = data['movie']['year'] | ||
self.slug = data['movie']['ids']['slug'] | ||
self.trakt_id = data['movie']['ids']['trakt'] | ||
self.imdb_id = data['movie']['ids']['imdb'] | ||
self.tmdb_id = data['movie']['ids']['tmdb'] | ||
self.poster = TMDb.movie_poster_path(self.tmdb_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from src.tmdb.client import TMDb | ||
|
||
class Season: | ||
def __init__(self, data): | ||
self.title = data['show']['title'] | ||
self.show_title = data['show']['title'] | ||
self.season_id = "{:02}".format(data['season']['number']) # Format as two-digit number | ||
self.year = data['show']['year'] | ||
self.slug = data['show']['ids']['slug'] | ||
self.trakt_id = data['show']['ids']['trakt'] | ||
self.imdb_id = data['show']['ids']['imdb'] | ||
self.tmdb_id = data['show']['ids']['tmdb'] | ||
self.tvdb_id = data['show']['ids']['tvdb'] | ||
self.poster = TMDb.show_poster_path(self.tvdb_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from src.tmdb.client import TMDb | ||
|
||
class Show: | ||
def __init__(self, data): | ||
show_data = data['show'] if 'show' in data else data | ||
self.title = show_data['title'] | ||
self.year = show_data['year'] | ||
self.slug = show_data['ids']['slug'] | ||
self.trakt_id = show_data['ids']['trakt'] | ||
self.imdb_id = show_data['ids']['imdb'] | ||
self.tmdb_id = show_data['ids']['tmdb'] | ||
self.tvdb_id = show_data['ids']['tvdb'] | ||
self.poster = TMDb.show_poster_path(self.tvdb_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
from datetime import datetime, timedelta | ||
from api.trakt.client import TraktClient | ||
|
||
client = TraktClient() | ||
user = client.user('desiler') | ||
shows_instance = client.shows() | ||
|
||
# Get the current time and the time one hour ago | ||
now = datetime.now() | ||
one_hour_ago = now - timedelta(hours=1200) | ||
|
||
#ratings = user.get_ratings(start_time=one_hour_ago, end_time=now) | ||
#ratings = user.get_ratings() | ||
#for rating in ratings: | ||
favorites = user.get_favorites(start_time=one_hour_ago, end_time=now) | ||
for favorite in favorites: | ||
print(f"Title: {favorite.title}") | ||
print(f"Media type: {favorite.type}") | ||
print(f"Season: {favorite.season_id}") | ||
print(f"Episode: {favorite.episode_id}") | ||
print(f"Listed at: {favorite.listed_at}") | ||
print(f"Show title: {favorite.show_title}") | ||
print() | ||
for show in shows_instance.get_trending(): | ||
print(show.title) | ||
|
||
for show in shows_instance.get_popular(): | ||
print(show.title) |