Commit 4d571f86 authored by echel0n's avatar echel0n
Browse files

Fixed issue with searching for new shows

Refactoring coming episodes class code to resolve performance issues
Refactored names of API v2 class endpoints
Moved startup message to appear after web server is started
Fixed launching browser to use a proper IP address when SR is set to listen on all interface's
parent e9812be7
......@@ -578,20 +578,6 @@ class Core(object):
# load shows
self.scheduler.add_job(self.load_shows)
# launch browser window
if not sickrage.app.no_launch and sickrage.app.config.general.launch_browser:
self.scheduler.add_job(launch_browser, args=[('http', 'https')[sickrage.app.config.general.enable_https],
sickrage.app.config.general.web_host, sickrage.app.config.general.web_port])
self.log.info("SiCKRAGE :: STARTED")
self.log.info("SiCKRAGE :: APP VERSION:[{}]".format(sickrage.version()))
self.log.info("SiCKRAGE :: CONFIG VERSION:[v{}]".format(self.config.db.version))
self.log.info("SiCKRAGE :: DATABASE VERSION:[v{}]".format(self.main_db.version))
self.log.info("SiCKRAGE :: DATABASE TYPE:[{}]".format(self.db_type))
self.log.info("SiCKRAGE :: URL:[{}://{}:{}/{}]".format(('http', 'https')[self.config.general.enable_https],
(self.config.general.web_host, get_lan_ip())[self.config.general.web_host == '0.0.0.0'],
self.config.general.web_port, self.config.general.web_root))
def init_sentry(self):
# sentry log handler
sentry_logging = LoggingIntegration(
......
This diff is collapsed.
......@@ -158,46 +158,26 @@ class ComingEpisodes:
EpisodeStatus.composites(EpisodeStatus.SNATCHED_BEST), EpisodeStatus.composites(EpisodeStatus.SNATCHED_PROPER),
EpisodeStatus.composites(EpisodeStatus.ARCHIVED), EpisodeStatus.composites(EpisodeStatus.IGNORED)])
for show in get_show_list():
with sickrage.app.main_db.session() as session:
[add_result(show, episode, grouped=group) for episode in session.query(
MainDB.TVEpisode
).filter_by(
series_id=show.series_id,
series_provider_id=show.series_provider_id
).filter(
MainDB.TVEpisode.airdate < next_week,
MainDB.TVEpisode.airdate >= today,
MainDB.TVEpisode.season != 0,
~MainDB.TVEpisode.status.in_(qualities_list)
)]
if show.series_id not in [int(r['series_id']) for r in results]:
[add_result(show, episode, grouped=group) for episode in session.query(
MainDB.TVEpisode
).filter_by(
series_id=show.series_id,
series_provider_id=show.series_provider_id
).filter(
MainDB.TVEpisode.airdate >= next_week,
MainDB.TVEpisode.season != 0,
~MainDB.TVEpisode.status.in_(flatten(
[EpisodeStatus.composites(EpisodeStatus.DOWNLOADED), EpisodeStatus.composites(EpisodeStatus.SNATCHED),
EpisodeStatus.composites(EpisodeStatus.SNATCHED_BEST), EpisodeStatus.composites(EpisodeStatus.SNATCHED_PROPER)]))
)]
[add_result(show, episode, grouped=group) for episode in session.query(
MainDB.TVEpisode
).filter_by(
series_id=show.series_id,
series_provider_id=show.series_provider_id
).filter(
MainDB.TVEpisode.airdate >= recently,
MainDB.TVEpisode.airdate < today,
MainDB.TVEpisode.season != 0,
MainDB.TVEpisode.status.in_([EpisodeStatus.WANTED, EpisodeStatus.UNAIRED]),
~MainDB.TVEpisode.status.in_(qualities_list)
)]
with sickrage.app.main_db.session() as session:
[add_result(episode.show, episode, grouped=group) for episode in session.query(
MainDB.TVEpisode
).filter(
MainDB.TVEpisode.airdate <= next_week,
MainDB.TVEpisode.airdate >= today,
MainDB.TVEpisode.season != 0,
~MainDB.TVEpisode.status.in_(qualities_list)
)]
[add_result(episode.show, episode, grouped=group) for episode in session.query(
MainDB.TVEpisode
).filter(
MainDB.TVEpisode.airdate >= recently,
MainDB.TVEpisode.airdate < today,
MainDB.TVEpisode.season != 0,
MainDB.TVEpisode.status.in_([EpisodeStatus.WANTED, EpisodeStatus.UNAIRED]),
~MainDB.TVEpisode.status.in_(qualities_list)
)]
if group:
for category in categories:
......
......@@ -33,19 +33,21 @@ from tornado.ioloop import IOLoop
from tornado.web import Application, RedirectHandler, StaticFileHandler
import sickrage
from sickrage.core.helpers import create_https_certificates
from sickrage.core.helpers import create_https_certificates, get_lan_ip, launch_browser
from sickrage.core.webserver.handlers.account import AccountLinkHandler, AccountUnlinkHandler, AccountIsLinkedHandler
from sickrage.core.webserver.handlers.announcements import AnnouncementsHandler, MarkAnnouncementSeenHandler, AnnouncementCountHandler
from sickrage.core.webserver.handlers.api import SwaggerDotJsonHandler, PingHandler
from sickrage.core.webserver.handlers.api import ApiSwaggerDotJsonHandler, ApiPingHandler
from sickrage.core.webserver.handlers.api.v1 import ApiHandler
from sickrage.core.webserver.handlers.api.v2 import RetrieveSeriesMetadataHandler
from sickrage.core.webserver.handlers.api.v2.postprocess import PostProcessHandler
from sickrage.core.webserver.handlers.api.v2.config import ConfigHandler
from sickrage.core.webserver.handlers.api.v2.episode import EpisodesRenameHandler, EpisodesManualSearchHandler
from sickrage.core.webserver.handlers.api.v2.file_browser import FileBrowserHandler
from sickrage.core.webserver.handlers.api.v2.series import SeriesHandler, SeriesEpisodesHandler, SeriesImagesHandler, SeriesImdbInfoHandler, \
SeriesBlacklistHandler, SeriesWhitelistHandler, SeriesRefreshHandler, SeriesUpdateHandler
from sickrage.core.webserver.handlers.api.v2.series_provider import SeriesProvidersHandler, SeriesProvidersSearchHandler, SeriesProvidersLanguagesHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2RetrieveSeriesMetadataHandler
from sickrage.core.webserver.handlers.api.v2.config import ApiV2ConfigHandler
from sickrage.core.webserver.handlers.api.v2.episode import ApiV2EpisodesRenameHandler, ApiV2EpisodesManualSearchHandler
from sickrage.core.webserver.handlers.api.v2.file_browser import ApiV2FileBrowserHandler
from sickrage.core.webserver.handlers.api.v2.postprocess import Apiv2PostProcessHandler
from sickrage.core.webserver.handlers.api.v2.schedule import ApiV2ScheduleHandler
from sickrage.core.webserver.handlers.api.v2.series import ApiV2SeriesHandler, ApiV2SeriesEpisodesHandler, ApiV2SeriesImagesHandler, ApiV2SeriesImdbInfoHandler, \
ApiV2SeriesBlacklistHandler, ApiV2SeriesWhitelistHandler, ApiV2SeriesRefreshHandler, ApiV2SeriesUpdateHandler
from sickrage.core.webserver.handlers.api.v2.series_provider import ApiV2SeriesProvidersHandler, ApiV2SeriesProvidersSearchHandler, \
ApiV2SeriesProvidersLanguagesHandler
from sickrage.core.webserver.handlers.calendar import CalendarHandler
from sickrage.core.webserver.handlers.changelog import ChangelogHandler
from sickrage.core.webserver.handlers.config import ConfigWebHandler, ConfigResetHandler
......@@ -213,26 +215,27 @@ class WebServer(threading.Thread):
# API v2 Handlers
self.handlers['api_v2_handlers'] = [
(fr'{self.api_v2_root}/swagger.json', SwaggerDotJsonHandler, {'api_handlers': 'api_v2_handlers', 'api_version': '2.0.0'}),
(fr'{self.api_v2_root}/config', ConfigHandler),
(fr'{self.api_v2_root}/ping', PingHandler),
(fr'{self.api_v2_root}/file-browser', FileBrowserHandler),
(fr'{self.api_v2_root}/postprocess', PostProcessHandler),
(fr'{self.api_v2_root}/retrieve-series-metadata', RetrieveSeriesMetadataHandler),
(fr'{self.api_v2_root}/series-providers', SeriesProvidersHandler),
(fr'{self.api_v2_root}/series-providers/([a-z]+)/search', SeriesProvidersSearchHandler),
(fr'{self.api_v2_root}/series-providers/([a-z]+)/languages', SeriesProvidersLanguagesHandler),
(fr'{self.api_v2_root}/series', SeriesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)', SeriesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/episodes', SeriesEpisodesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/images', SeriesImagesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/imdb-info', SeriesImdbInfoHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/blacklist', SeriesBlacklistHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/whitelist', SeriesWhitelistHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/refresh', SeriesRefreshHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/update', SeriesUpdateHandler),
(fr'{self.api_v2_root}/episodes/rename', EpisodesRenameHandler),
(fr'{self.api_v2_root}/episodes/(\d+[-][a-z]+)/search', EpisodesManualSearchHandler),
(fr'{self.api_v2_root}/ping', ApiPingHandler),
(fr'{self.api_v2_root}/swagger.json', ApiSwaggerDotJsonHandler, {'api_handlers': 'api_v2_handlers', 'api_version': '2.0.0'}),
(fr'{self.api_v2_root}/config', ApiV2ConfigHandler),
(fr'{self.api_v2_root}/file-browser', ApiV2FileBrowserHandler),
(fr'{self.api_v2_root}/postprocess', Apiv2PostProcessHandler),
(fr'{self.api_v2_root}/retrieve-series-metadata', ApiV2RetrieveSeriesMetadataHandler),
(fr'{self.api_v2_root}/schedule', ApiV2ScheduleHandler),
(fr'{self.api_v2_root}/series-providers', ApiV2SeriesProvidersHandler),
(fr'{self.api_v2_root}/series-providers/([a-z]+)/search', ApiV2SeriesProvidersSearchHandler),
(fr'{self.api_v2_root}/series-providers/([a-z]+)/languages', ApiV2SeriesProvidersLanguagesHandler),
(fr'{self.api_v2_root}/series', ApiV2SeriesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)', ApiV2SeriesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/episodes', ApiV2SeriesEpisodesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/images', ApiV2SeriesImagesHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/imdb-info', ApiV2SeriesImdbInfoHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/blacklist', ApiV2SeriesBlacklistHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/whitelist', ApiV2SeriesWhitelistHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/refresh', ApiV2SeriesRefreshHandler),
(fr'{self.api_v2_root}/series/(\d+[-][a-z]+)/update', ApiV2SeriesUpdateHandler),
(fr'{self.api_v2_root}/episodes/rename', ApiV2EpisodesRenameHandler),
(fr'{self.api_v2_root}/episodes/(\d+[-][a-z]+)/search', ApiV2EpisodesManualSearchHandler),
]
# New UI Static File Handlers
......@@ -494,6 +497,20 @@ class WebServer(threading.Thread):
sickrage.app.log.warning(e.strerror)
raise SystemExit
# launch browser window
if not sickrage.app.no_launch and sickrage.app.config.general.launch_browser:
sickrage.app.add_job(launch_browser, args=[('http', 'https')[sickrage.app.config.general.enable_https],
(sickrage.app.config.general.web_host, get_lan_ip())[sickrage.app.config.general.web_host == '0.0.0.0'],
sickrage.app.config.general.web_port])
sickrage.app.log.info("SiCKRAGE :: STARTED")
sickrage.app.log.info(f"SiCKRAGE :: APP VERSION:[{sickrage.version()}]")
sickrage.app.log.info(f"SiCKRAGE :: CONFIG VERSION:[v{sickrage.app.config.db.version}]")
sickrage.app.log.info(f"SiCKRAGE :: DATABASE VERSION:[v{sickrage.app.main_db.version}]")
sickrage.app.log.info(f"SiCKRAGE :: DATABASE TYPE:[{sickrage.app.db_type}]")
sickrage.app.log.info(
f"SiCKRAGE :: URL:[{('http', 'https')[sickrage.app.config.general.enable_https]}://{(sickrage.app.config.general.web_host, get_lan_ip())[sickrage.app.config.general.web_host == '0.0.0.0']}:{sickrage.app.config.general.web_port}/{sickrage.app.config.general.web_root}]")
self.io_loop.start()
def shutdown(self):
......
......@@ -88,16 +88,8 @@ class APIBaseHandler(BaseHandler):
if exchanged_token:
sickrage.app.api.token = exchanged_token
internal_connections = "{}://{}:{}{}".format(self.request.protocol,
get_internal_ip(),
sickrage.app.config.general.web_port,
sickrage.app.config.general.web_root)
external_connections = "{}://{}:{}{}".format(self.request.protocol,
get_external_ip(),
sickrage.app.config.general.web_port,
sickrage.app.config.general.web_root)
internal_connections = f"{self.request.protocol}://{get_internal_ip()}:{sickrage.app.config.general.web_port}{sickrage.app.config.general.web_root}"
external_connections = f"{self.request.protocol}://{get_external_ip()}:{sickrage.app.config.general.web_port}{sickrage.app.config.general.web_root}"
connections = ','.join([internal_connections, external_connections])
if sickrage.app.config.general.server_id and not sickrage.app.api.account.update_server(sickrage.app.config.general.server_id, connections):
......@@ -182,14 +174,14 @@ class APIBaseHandler(BaseHandler):
return spec.to_dict()
class PingHandler(APIBaseHandler):
class ApiPingHandler(APIBaseHandler):
def get(self):
return self.write_json({'message': 'pong'})
class SwaggerDotJsonHandler(APIBaseHandler):
class ApiSwaggerDotJsonHandler(APIBaseHandler):
def initialize(self, api_handlers, api_version):
super(SwaggerDotJsonHandler, self).initialize()
super(ApiSwaggerDotJsonHandler, self).initialize()
self.api_handlers = sickrage.app.wserver.handlers[api_handlers]
self.api_version = api_version
......
......@@ -24,7 +24,7 @@ import sickrage
from sickrage.core.webserver.handlers.api import APIBaseHandler
class RetrieveSeriesMetadataHandler(APIBaseHandler):
class ApiV2RetrieveSeriesMetadataHandler(APIBaseHandler):
def get(self):
series_directory = self.get_argument('seriesDirectory', None)
if not series_directory:
......
......@@ -27,7 +27,7 @@ from sickrage.core.enums import SearchFormat
from sickrage.core.webserver.handlers.api import APIBaseHandler
class ConfigHandler(APIBaseHandler):
class ApiV2ConfigHandler(APIBaseHandler):
def get(self, *args, **kwargs):
config_data = sickrage.app.config.to_json()
......
......@@ -31,7 +31,7 @@ from sickrage.core.webserver.handlers.api.v2.episode.schemas import EpisodesManu
from sickrage.core.websocket import WebSocketMessage
class EpisodesManualSearchHandler(APIBaseHandler):
class ApiV2EpisodesManualSearchHandler(APIBaseHandler):
def get(self, episode_slug):
"""Episode Manual Search"
---
......@@ -102,7 +102,7 @@ class EpisodesManualSearchHandler(APIBaseHandler):
)
class EpisodesRenameHandler(APIBaseHandler):
class ApiV2EpisodesRenameHandler(APIBaseHandler):
def get(self):
"""Get list of episodes to rename"
---
......
......@@ -23,7 +23,7 @@ import os
from sickrage.core.webserver.handlers.api import APIBaseHandler
class FileBrowserHandler(APIBaseHandler):
class ApiV2FileBrowserHandler(APIBaseHandler):
def get(self):
path = self.get_argument('path', None)
include_files = self.get_argument('includeFiles', None)
......
......@@ -26,7 +26,7 @@ from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2.postprocess.schemas import PostProcessSchema
class PostProcessHandler(APIBaseHandler):
class Apiv2PostProcessHandler(APIBaseHandler):
def get(self):
"""Postprocess TV show video files"
---
......
......@@ -18,20 +18,20 @@
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import datetime
import sickrage
from sickrage.core.tv.show.coming_episodes import ComingEpisodes
from sickrage.core.webserver.handlers.api import APIBaseHandler
class ScheduleHandler(APIBaseHandler):
class ApiV2ScheduleHandler(APIBaseHandler):
def get(self):
"""Get TV show schedule information"
---
tags: [Schedule]
summary: Get TV show schedule information
description: Get TV show schedule information
parameters:
- in: path
schema:
SeriesPath
responses:
200:
description: Success payload
......@@ -57,4 +57,19 @@ class ScheduleHandler(APIBaseHandler):
application/json:
schema:
NotFoundSchema
"""
\ No newline at end of file
"""
next_week = datetime.datetime.combine(datetime.date.today() + datetime.timedelta(days=7),
datetime.datetime.now().time().replace(tzinfo=sickrage.app.tz))
today = datetime.datetime.now().replace(tzinfo=sickrage.app.tz)
results = ComingEpisodes.get_coming_episodes(ComingEpisodes.categories, sickrage.app.config.gui.coming_eps_sort, group=False)
for i, result in enumerate(results.copy()):
results[i]['airdate'] = datetime.datetime.fromordinal(result['airdate'].toordinal()).timestamp()
results[i]['series_provider_id'] = result['series_provider_id'].name
results[i]['quality'] = result['quality'].name
results[i]['localtime'] = result['localtime'].timestamp()
return self.write_json({'data': results, 'today': today.timestamp(), 'nextWeek': next_week.timestamp()})
# ##############################################################################
# Author: echel0n <[email protected]>
# URL: https://sickrage.ca/
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git
# -
# This file is part of SiCKRAGE.
# -
# SiCKRAGE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# -
# SiCKRAGE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# -
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
from marshmallow import fields
from sickrage.core.webserver.handlers.api.schemas import BaseSchema, BaseSuccessSchema
class ScheduleSuccessSchema(BaseSuccessSchema):
data = fields.String(
required=True,
description="Validated and schedule information",
)
today = fields.Integer(
required=True,
description="Timestamp representing today",
)
nextWeek = fields.Integer(
required=True,
description="Timestamp representing next week",
)
......@@ -36,7 +36,7 @@ from sickrage.core.tv.show.helpers import get_show_list, find_show, find_show_by
from sickrage.core.webserver.handlers.api import APIBaseHandler
class SeriesHandler(APIBaseHandler):
class ApiV2SeriesHandler(APIBaseHandler):
def get(self, series_slug=None):
"""Get list of series or specific series information"
---
......@@ -177,7 +177,7 @@ class SeriesHandler(APIBaseHandler):
sickrage.app.alerts.message(_('Adding Show'), _(f'Adding the specified show into {series_directory}'))
return self.write_json({'message': 'successful'})
return self.write_json({'message': True})
def patch(self, series_slug):
warnings, errors = [], []
......@@ -314,10 +314,10 @@ class SeriesHandler(APIBaseHandler):
sickrage.app.show_queue.remove_show(series.series_id, series.series_provider_id, checkbox_to_value(data.get('delete')))
return self.write_json({'message': 'successful'})
return self.write_json({'message': True})
class SeriesEpisodesHandler(APIBaseHandler):
class ApiV2SeriesEpisodesHandler(APIBaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -330,7 +330,7 @@ class SeriesEpisodesHandler(APIBaseHandler):
return self.write_json(episodes)
class SeriesImagesHandler(APIBaseHandler):
class ApiV2SeriesImagesHandler(APIBaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -340,7 +340,7 @@ class SeriesImagesHandler(APIBaseHandler):
return self.write_json({'poster': image.url})
class SeriesImdbInfoHandler(APIBaseHandler):
class ApiV2SeriesImdbInfoHandler(APIBaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -353,7 +353,7 @@ class SeriesImdbInfoHandler(APIBaseHandler):
return self.write_json(json_data)
class SeriesBlacklistHandler(APIBaseHandler):
class ApiV2SeriesBlacklistHandler(APIBaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -366,7 +366,7 @@ class SeriesBlacklistHandler(APIBaseHandler):
return self.write_json(json_data)
class SeriesWhitelistHandler(APIBaseHandler):
class ApiV2SeriesWhitelistHandler(APIBaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -379,7 +379,7 @@ class SeriesWhitelistHandler(APIBaseHandler):
return self.write_json(json_data)
class SeriesRefreshHandler(APIBaseHandler):
class ApiV2SeriesRefreshHandler(APIBaseHandler):
def get(self, series_slug):
force = self.get_argument('force', None)
......@@ -393,7 +393,7 @@ class SeriesRefreshHandler(APIBaseHandler):
return self.send_error(400, error=_(f"Unable to refresh this show, error: {e}"))
class SeriesUpdateHandler(APIBaseHandler):
class ApiV2SeriesUpdateHandler(APIBaseHandler):
def get(self, series_slug):
force = self.get_argument('force', None)
......
......@@ -25,12 +25,12 @@ from sickrage.core.enums import SeriesProviderID
from sickrage.core.webserver.handlers.api import APIBaseHandler
class SeriesProvidersHandler(APIBaseHandler):
class ApiV2SeriesProvidersHandler(APIBaseHandler):
def get(self):
self.write_json([{'displayName': x.display_name, 'slug': x.slug} for x in SeriesProviderID])
class SeriesProvidersSearchHandler(APIBaseHandler):
class ApiV2SeriesProvidersSearchHandler(APIBaseHandler):
def get(self, series_provider_slug):
search_term = self.get_argument('searchTerm', None)
lang = self.get_argument('seriesProviderLanguage', None)
......@@ -49,7 +49,7 @@ class SeriesProvidersSearchHandler(APIBaseHandler):
return self.write_json(results)
class SeriesProvidersLanguagesHandler(APIBaseHandler):
class ApiV2SeriesProvidersLanguagesHandler(APIBaseHandler):
def get(self, series_provider_slug):
series_provider_id = SeriesProviderID.by_slug(series_provider_slug)
if not series_provider_id:
......
......@@ -77,7 +77,7 @@ class SearchSeriesProviderForShowNameHandler(BaseHandler):
series_provider_id = self.get_argument('series_provider_id', None)
lang = self.get_argument('lang', None)
search_results = []
results = []
series_provider = sickrage.app.series_providers[SeriesProviderID[series_provider_id]]
series_provider_language = lang if not lang or lang == 'null' else sickrage.app.config.general.series_provider_default_language
......@@ -85,16 +85,16 @@ class SearchSeriesProviderForShowNameHandler(BaseHandler):
sickrage.app.log.debug(f"Searching for Show with term: {search_term} on series provider: {series_provider.name}")
# search via series name
search_results = series_provider.search(search_term, language=series_provider_language)
if search_results:
for series in series_provider.search(search_term, language=series_provider_language):
series_results = series_provider.search(search_term, language=series_provider_language)
if series_results:
for series in series_results:
if not series.get('seriesname', None):
continue
if not series.get('firstaired', None):
continue
search_results.append((
results.append((
series_provider.name,
series_provider_id,
series_provider.show_url,
......@@ -104,7 +104,7 @@ class SearchSeriesProviderForShowNameHandler(BaseHandler):
('', 'disabled')[isinstance(find_show(int(series['id']), SeriesProviderID[series_provider_id]), TVShow)]
))
return self.write(json_encode({'results': search_results, 'langid': lang}))
return self.write(json_encode({'results': results, 'langid': lang}))
class MassAddTableHandler(BaseHandler):
......
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