Commit 2027b39e authored by echel0n's avatar echel0n
Browse files

added SiCKRAGE external API endpoint for searching series providers by series id

fixed "string indices must be integers" when attempting to retrieve season images from series providers
parent 4cef13e0
......@@ -444,6 +444,10 @@ class API(object):
endpoint = f'series-provider/{provider}/search/{query}/{language}'
return self.api.request('GET', endpoint)
def search_by_id(self, provider, remote_id, language='eng'):
endpoint = f'series-provider/{provider}/search-by-id/{remote_id}/{language}'
return self.api.request('GET', endpoint)
def get_series_info(self, provider, series_id, language='eng'):
endpoint = f'series-provider/{provider}/series/{series_id}/{language}'
return self.api.request('GET', endpoint)
......
......@@ -315,9 +315,11 @@ class AddShowByIDHandler(BaseHandler):
show_name = self.get_argument('showName')
if re.search(r'tt\d+', series_id):
result = sickrage.app.series_providers[SeriesProviderID.THETVDB].search(series_id)
if result and 'id' in result:
series_id = int(result['id'])
result = sickrage.app.series_providers[SeriesProviderID.THETVDB].search_by_id(series_id)
if not result:
return
series_id = int(result['id'])
if find_show(int(series_id), SeriesProviderID.THETVDB):
sickrage.app.log.debug(f"{series_id} already exists in your show library, skipping!")
......
......@@ -61,20 +61,34 @@ class TheTVDB(SeriesProvider):
self.dvd_order = False
def search(self, query, language='eng'):
"""This searches TheTVDB.com for the series by name, seriesid, imdbid, or zap2itid
and returns the result list
"""
This searches TheTVDB.com for the series by name and returns the result list
"""
sickrage.app.log.debug(f"Searching for show using query term: {query}")
search_result = sickrage.app.api.series_provider.search(provider=self.slug, query=quote(query), language=language)
if not search_result:
search_results = sickrage.app.api.series_provider.search(provider=self.slug, query=quote(query), language=language)
if not search_results:
sickrage.app.log.debug(f'Series search using query term {query} returned zero results, cannot find series on {self.name}')
return search_results
def search_by_id(self, remote_id, language='eng'):
"""
This searches TheTVDB.com for the seriesid, imdbid, or zap2itid and returns the result list
"""
sickrage.app.log.debug(f"Searching for show using remote id: {remote_id}")
search_result = sickrage.app.api.series_provider.search_by_id(provider=self.slug, remote_id=quote(remote_id), language=language)
if not search_result:
sickrage.app.log.debug(f'Series search using remote id {remote_id} returned zero results, cannot find series on {self.name}')
return search_result
def get_series_info(self, sid, language='eng', dvd_order=False, enable_cache=True):
"""Takes a series ID, gets the episodes URL and parses the TVDB
"""
Takes a series id, gets the episodes URL and parses the TVDB
"""
# check if series is in cache
......@@ -169,11 +183,11 @@ class TheTVDB(SeriesProvider):
if season:
image_url = series_info[season].imageUrl
if image_url != '':
images.append(image_url)
images.append({'image': image_url})
else:
image_url = series_info.imageUrl
if image_url != '':
images.append(image_url)
images.append({'image': image_url})
return images
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment