def _get_inprogress_shows(self): response = self.get_sync('watched', 'show') response = TraktItems(response).sort_items('watched', 'desc') hidden_shows = self.get_hiddenitems('show') return [ i for i in response if self._is_inprogress_show(i, hidden_shows) ]
def get_simple_list(self, *args, **kwargs): trakt_type = kwargs.pop('trakt_type', None) response = self.get_response(*args, **kwargs) if not response: return return TraktItems(response.json(), headers=response.headers, trakt_type=trakt_type).configure_items()
def _get_sync_list(self, sync_type, trakt_type, sort_by=None, sort_how=None): return TraktItems(items=self.get_sync(sync_type, trakt_type), trakt_type=trakt_type).build_items( sort_by, sort_how)
def get_inprogress_shows_list(self, page=1, limit=20, params=None, next_page=True, sort_by=None, sort_how=None): response = self._get_upnext_episodes_list(sort_by_premiered=True) if sort_by == 'year' else self._get_inprogress_shows() response = TraktItems(response, trakt_type='show').build_items( params_def=params, sort_by=sort_by if sort_by != 'year' else 'unsorted', sort_how=sort_how) response = PaginatedItems(response['items'], page=page, limit=limit) if not next_page: return response.items return response.items + response.next_page
def get_upnext_episodes_list(self, page=1, sort_by_premiered=False): """ Gets a list of episodes for in-progress shows that user should watch next """ response = self._get_upnext_episodes_list(sort_by_premiered=sort_by_premiered) response = TraktItems(response, trakt_type='episode').configure_items(params_def={ 'info': 'details', 'tmdb_type': '{tmdb_type}', 'tmdb_id': '{tmdb_id}', 'season': '{season}', 'episode': '{number}'}) response = PaginatedItems(response['items'], page=page, limit=10) return response.items + response.next_page
def get_sorted_list(self, path, sort_by=None, sort_how=None, extended=None, trakt_type=None, permitted_types=None, cache_refresh=False): response = self.get_response(path, extended=extended, limit=4095) if not response: return return TraktItems(response.json(), headers=response.headers).build_items( sort_by=sort_by or response.headers.get('X-Sort-By'), sort_how=sort_how or response.headers.get('X-Sort-How'), permitted_types=permitted_types)
def get_inprogress_shows_list(self, page=1, limit=20, params=None, next_page=True): response = TraktItems(self._get_inprogress_shows(), trakt_type='show').build_items(params_def=params) response = PaginatedItems(response['items'], page=page, limit=limit) if not next_page: return response.items return response.items + response.next_page
def get_upnext_list(self, unique_id, id_type=None, page=1): """ Gets the next episodes for a show that user should watch next """ if id_type != 'slug': unique_id = self.get_id(unique_id, id_type, 'show', output_type='slug') if unique_id: showitem = self.get_details('show', unique_id) response = self.get_upnext_episodes(unique_id, showitem) response = TraktItems(response, trakt_type='episode').configure_items(params_def={ 'info': 'details', 'tmdb_type': '{tmdb_type}', 'tmdb_id': '{tmdb_id}', 'season': '{season}', 'episode': '{number}'}) response = PaginatedItems(response['items'], page=page, limit=10) return response.items + response.next_page
def _get_upnext_episodes_list(self, sort_by_premiered=False): shows = self._get_inprogress_shows() or [] items = [j for j in (self.get_upnext_episodes( i.get('show', {}).get('ids', {}).get('slug'), i.get('show', {}), get_single_episode=True) for i in shows) if j] if sort_by_premiered: items = [ {'show': i.get('show'), 'episode': self.get_details( 'show', i.get('show', {}).get('ids', {}).get('slug'), season=i.get('episode', {}).get('season'), episode=i.get('episode', {}).get('number')) or i.get('episode')} for i in items] items = TraktItems(items, trakt_type='episode').sort_items('released', 'desc') return items
def get_imdb_top250(self, id_type=None): path = 'users/justin/lists/imdb-top-rated-movies/items' response = self.get_response(path, limit=4095) sorted_items = TraktItems(response.json() if response else [] ).sort_items('rank', 'asc') or [] return [i['movie']['ids'][id_type] for i in sorted_items]