Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@api.doc(params={'failed_entry_id': 'ID of the failed entry'})
@api.response(200, model=retry_failed_entry_schema)
def get(self, failed_entry_id, session=None):
""" Get failed entry by ID """
try:
failed_entry = session.query(FailedEntry).filter(FailedEntry.id == failed_entry_id).one()
except NoResultFound:
raise NotFoundError(f'could not find entry with ID {failed_entry_id}')
return jsonify(failed_entry.to_dict())
include_translations = args.pop('include_translations')
kwargs = args
try:
series = ApiTrakt.lookup_series(session=session, **kwargs)
except LookupError as e:
raise NotFoundError(e.args[0])
result = series.to_dict()
if include_actors:
result['actors'] = db.list_actors(series.actors)
if include_translations:
result['translations'] = db.get_translations_dict(series.translations, 'show')
return jsonify(result)
@trakt_api.route('/series/')
@api.doc(params={'title': 'Series name'})
class TraktSeriesWithTitleSearchApi(APIResource):
@api.doc(parser=lookup_parser)
@api.response(301)
def get(self, title, session=None):
kwargs = lookup_parser.parse_args()
kwargs['title'] = title
return redirect(api.url_for(TraktSeriesSearchApi, **kwargs), code=301)
@trakt_api.route('/movies/')
class TraktMovieSearchApi(APIResource):
@etag(cache_age=3600)
@api.response(200, 'Successfully found show', movie_return_schema)
@api.response(NotFoundError)
@api.doc(parser=lookup_parser)
def get(self, session=None):
@api.doc(parser=seen_search_parser, description='Get seen entries')
def get(self, session):
""" Search for seen entries """
args = seen_search_parser.parse_args()
# Filter params
value = args['value']
local = args['local']
# Pagination and sorting params
page = args['page']
per_page = args['per_page']
sort_by = args['sort_by']
sort_order = args['order']
# Handle max size limit
if per_page > 100:
@api.doc(
description='Sent movie identifiers will override any existing identifiers that the movie currently holds'
)
def put(self, list_id, movie_id, session=None):
""" Sets movie identifiers """
try:
movie = db.get_movie_by_id(list_id=list_id, movie_id=movie_id, session=session)
except NoResultFound:
raise NotFoundError('could not find movie with id %d in list %d' % (movie_id, list_id))
data = request.json
# Validates ID type based on allowed ID
for id_name in data:
if list(id_name)[0] not in MovieListBase().supported_ids:
raise BadRequest('movie identifier %s is not allowed' % id_name)
movie.ids[:] = db.get_db_movie_identifiers(
identifier_list=data, movie_id=movie_id, session=session
@api.doc(parser=tasks_parser)
def get(self, session=None):
""" List all tasks """
active_tasks = {task: task_data for task, task_data in self.manager.user_config.get('tasks', {}).items()
if not task.startswith('_')}
args = tasks_parser.parse_args()
if not args.get('include_config'):
return jsonify(list(active_tasks))
tasks = [{'name': name, 'config': config} for name, config in active_tasks.items()]
return jsonify(tasks)
@api.doc(parser=series_list_parser)
def get(self, session=None):
""" Gets series lists """
args = series_list_parser.parse_args()
name = args.get('name')
series_lists = [series_list.to_dict() for series_list in
sl.SeriesListDB.get_series_lists(name=name, session=session)]
return jsonify({'series_lists': series_lists})
@api.doc(
description='Get all matching releases for a specific season of a specific show.',
parser=release_list_parser,
)
def get(self, show_id, season_id, session):
""" Get all season releases by show ID and season ID """
try:
db.show_by_id(show_id, session=session)
except NoResultFound:
raise NotFoundError('show with ID %s not found' % show_id)
try:
season = db.season_by_id(season_id, session)
except NoResultFound:
raise NotFoundError('season with ID %s not found' % season_id)
if not db.season_in_show(show_id, season_id):
raise BadRequest(
'seasons with id %s does not belong to show %s' % (season_id, show_id)
@api.doc(parser=plugins_parser)
def get(self, session=None):
""" Get list of registered plugins """
args = plugins_parser.parse_args()
# Pagination and sorting params
page = args['page']
per_page = args['per_page']
# Handle max size limit
if per_page > 100:
per_page = 100
start = per_page * (page - 1)
stop = start + per_page
plugin_list = []
'last_update',
],
'additionalProperties': False,
}
tvmaze_series_schema = api.schema_model(
'tvmaze_series_schema', ObjectsContainer.tvmaze_series_object
)
tvmaze_episode_schema = api.schema_model(
'tvmaze_episode_schema', ObjectsContainer.tvmaze_episode_object
)
@tvmaze_api.route('/series//')
@api.doc(params={'title': 'TV Show name or TVMaze ID'})
class TVDBSeriesSearchApi(APIResource):
@etag(cache_age=3600)
@api.response(200, 'Successfully found show', model=tvmaze_series_schema)
@api.response(NotFoundError)
def get(self, title, session=None):
"""TVMaze series lookup"""
try:
tvmaze_id = int(title)
except ValueError:
tvmaze_id = None
try:
if tvmaze_id:
series = APITVMaze.series_lookup(tvmaze_id=tvmaze_id, session=session)
else:
series = APITVMaze.series_lookup(series_name=title, session=session)
except LookupError as e: