Commit ff1231ed authored by echel0n's avatar echel0n
Browse files

Merge branch 'release/10.0.23'

parents c8bc8443 3428ae6e
......@@ -2,8 +2,16 @@
 
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
 
#### [10.0.23](https://git.sickrage.ca/SiCKRAGE/sickrage/compare/10.0.22...10.0.23)
- Refactored web handlers to return data and call tornado finish on resp from run_async method [`a7bffda`](https://git.sickrage.ca/SiCKRAGE/sickrage/commit/a7bffda58098baab6b9392bef05ff92fbe43690c)
- Refactored web handlers to return data and call tornado finish on resp from run_async method [`7635d83`](https://git.sickrage.ca/SiCKRAGE/sickrage/commit/7635d83894ecdaa8b72f5f3e3918e24eff8aa37e)
- Refactored web handlers to return data and call tornado finish on resp from run_async method [`98396dc`](https://git.sickrage.ca/SiCKRAGE/sickrage/commit/98396dc7f97b2b355fee8e9271b418a65a74f370)
#### [10.0.22](https://git.sickrage.ca/SiCKRAGE/sickrage/compare/10.0.21...10.0.22)
 
> 1 August 2021
- Moved websocket queue check function to webserver class [`18042f3`](https://git.sickrage.ca/SiCKRAGE/sickrage/commit/18042f35c632962689f8854d24c09422ceaf666c)
 
#### [10.0.21](https://git.sickrage.ca/SiCKRAGE/sickrage/compare/10.0.20...10.0.21)
......
{
"name": "sickrage",
"version": "10.0.22",
"version": "10.0.23",
"private": true,
"repository": {
"type": "git",
......
[bumpversion]
current_version = 10.0.22
current_version = 10.0.23
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
......
......@@ -19,7 +19,7 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
__version__ = "10.0.22"
__version__ = "10.0.23"
__install_type__ = ""
import argparse
......
sickrage/__init__.py = 16d9974cfd6895fe2a0951879424772a
sickrage/__init__.py = 78861991644ffbfe5f003de2d3d5805c
sickrage/checksums.md5 = d41d8cd98f00b204e9800998ecf8427e
sickrage/version.txt = 098715703bb3982ab9d04ba266ce0094
sickrage/version.txt = 240ec8676db182af03fcab9a304273de
sickrage/autoProcessTV/hellaToSiCKRAGE.py = 9bc477abfd456aaba8d6bf46f2c59b1f
sickrage/autoProcessTV/__init__.py = bfa892dee586740a3a618d3c1955156c
sickrage/autoProcessTV/mediaToSiCKRAGE.py = f88a6679a211b1f97126c116e2c33b9c
......@@ -82,55 +82,55 @@ sickrage/core/tv/show/coming_episodes.py = 0d43711e559f1fbda75fc25b3485928f
sickrage/core/tv/show/__init__.py = 35291b3647ef4dbacebc60f2dfe48d39
sickrage/core/tv/show/helpers.py = 7e3bc2e2e744a50ac7188e79e9d98465
sickrage/core/tv/show/history.py = 02a46fa4946cdf7b80915da916f25ca0
sickrage/core/webserver/__init__.py = aafd702f571bb637a79aefc62becdf7b
sickrage/core/webserver/handlers/announcements.py = 7c15af0ca9f88c7b6beb239e1ff0da1c
sickrage/core/webserver/handlers/calendar.py = 20c8912a22c6978f8b3cd76d7bccb727
sickrage/core/webserver/__init__.py = c64c41ca9a8063f28762ba1e3827fc91
sickrage/core/webserver/handlers/announcements.py = cca0415f047c367e5b41c0fed6a24dbf
sickrage/core/webserver/handlers/calendar.py = 8053d4d70a574a54d4bb9a0ad88f9f4e
sickrage/core/webserver/handlers/google_drive.py = 98fde470e65096ec71a8e3f1cce2bd44
sickrage/core/webserver/handlers/logs.py = a0bfa797b3e3d5cf4539da53606bf94e
sickrage/core/webserver/handlers/logs.py = c0e649db7efc0168a8dcbea429878deb
sickrage/core/webserver/handlers/__init__.py = 4e94a1192bc45368b8cc3cd5f6d1debc
sickrage/core/webserver/handlers/root.py = 4f51ae78b735ae7fb97cdcb4c904e9b8
sickrage/core/webserver/handlers/account.py = 60c21b6e169f52c98c9c03814c2ea683
sickrage/core/webserver/handlers/root.py = be47a31ef1b27e6c8ca4abe9d5c4c3f8
sickrage/core/webserver/handlers/account.py = 593927d9b1826594dd9ec59101ce1200
sickrage/core/webserver/handlers/history.py = 34961ffbbb07803515ded9626c7f853a
sickrage/core/webserver/handlers/base.py = eea05bd1eb01c14df2f03cf799f0f92a
sickrage/core/webserver/handlers/changelog.py = 372aedb7c5e2eb2e69bffe6444c6ff88
sickrage/core/webserver/handlers/logout.py = 4abe5196987ac8bf58b00f05e9d4a4c4
sickrage/core/webserver/handlers/base.py = 0b9f86302fff8b2963d99cf33e06f41f
sickrage/core/webserver/handlers/changelog.py = 74407bee7cd98416432124fbb2a9c529
sickrage/core/webserver/handlers/logout.py = b91b1805bfd1ba69e8d19dc3254f5708
sickrage/core/webserver/handlers/not_found.py = 3b7253c2d4d323cbb0dc6828d87c8d2c
sickrage/core/webserver/handlers/web_file_browser.py = 4361bcc88688f7f6f9e616905aca72b2
sickrage/core/webserver/handlers/login.py = 8ecd1957b142f226e5a04d6aa30af12a
sickrage/core/webserver/handlers/home/add_shows.py = 0395e2cd534d1d8e99ce112bd9498505
sickrage/core/webserver/handlers/home/__init__.py = 011adfccade376632b5863f4ccb142a6
sickrage/core/webserver/handlers/home/postprocess.py = 50b6929e02d859c5387c14e0b406fb97
sickrage/core/webserver/handlers/config/backup_restore.py = 54b4db1cba99322b38ea146a16c192ce
sickrage/core/webserver/handlers/web_file_browser.py = fd7ea59001053b333cd56960181d4550
sickrage/core/webserver/handlers/login.py = 77457b9466f66add2d09fed70a77356a
sickrage/core/webserver/handlers/home/add_shows.py = 63773c53ec9288661aadeb242e15ab0e
sickrage/core/webserver/handlers/home/__init__.py = 06c15e8230c64566c1bc6f2d8d1fecbd
sickrage/core/webserver/handlers/home/postprocess.py = bd1ea821bd162300af4b5bf27c5aba94
sickrage/core/webserver/handlers/config/backup_restore.py = 5dc47bafd0e7f842930ae31bcac234e2
sickrage/core/webserver/handlers/config/__init__.py = 1b9eeca6d49289e7c36bf369450e459c
sickrage/core/webserver/handlers/config/subtitles.py = 0134a7fe351cd9e0dbe6c1952d8d2dd7
sickrage/core/webserver/handlers/config/postprocessing.py = d49cf15814f48e5821107ef4ab8d9879
sickrage/core/webserver/handlers/config/subtitles.py = 73b0155c03e43a895e3456a83f6f5558
sickrage/core/webserver/handlers/config/postprocessing.py = 85f89d663c651279cf9b589d8934431a
sickrage/core/webserver/handlers/config/anime.py = b30c5a43317e9bc2fde98493364391f1
sickrage/core/webserver/handlers/config/providers.py = bd3f764a491e56e818aec356a0d25ba7
sickrage/core/webserver/handlers/config/providers.py = e5df1dd0fb7b14d64f7fb0770c859aee
sickrage/core/webserver/handlers/config/search.py = 6ced2a39316938481d9d5086184bb3c5
sickrage/core/webserver/handlers/config/notifications.py = 88ee26540e55fa1aa65de84ed7d40fc5
sickrage/core/webserver/handlers/config/general.py = e209e2c4e5a4d7495ee34bcf82487c9b
sickrage/core/webserver/handlers/config/general.py = 6ced8e7cdfb4e10e391206ba314378fc
sickrage/core/webserver/handlers/config/quality_settings.py = 6a2849c97b8635d46a92b758ba641428
sickrage/core/webserver/handlers/manage/__init__.py = 6aceae4770c0a3f3a67e58e7b24c9254
sickrage/core/webserver/handlers/manage/__init__.py = 99ba915c56a2f50b76803e0ef7b1235f
sickrage/core/webserver/handlers/manage/queues.py = f92d4a8b34b1872e529886f4aa80ed08
sickrage/core/webserver/handlers/api/__init__.py = 56d5abc39345b7e584e41c9845d8826d
sickrage/core/webserver/handlers/api/__init__.py = 06da56d950844219a4329b68c6b80258
sickrage/core/webserver/handlers/api/schemas.py = 7fcfd3dee63378ba5bd8fcbaebbf49ef
sickrage/core/webserver/handlers/api/v1/__init__.py = bf5ed80398b88117dfb62ec5350ce082
sickrage/core/webserver/handlers/api/v2/__init__.py = e8e3e20065fd63c2a41dca9779f90271
sickrage/core/webserver/handlers/api/v2/schedule/__init__.py = a144a01b4b90f36b7c92f2c07a612d03
sickrage/core/webserver/handlers/api/v1/__init__.py = 0f49cecf3a7cd60687e33721517bad60
sickrage/core/webserver/handlers/api/v2/__init__.py = 08d80a10550ea252a07c0206f11d93c3
sickrage/core/webserver/handlers/api/v2/schedule/__init__.py = 5355332d142a363be9939c7f7a89ed5d
sickrage/core/webserver/handlers/api/v2/schedule/schemas.py = 4af02a112f828040cbb1cf34ad03fdd5
sickrage/core/webserver/handlers/api/v2/config/__init__.py = b2511c3a63779100f8ea30c774048d3d
sickrage/core/webserver/handlers/api/v2/config/__init__.py = 9adc51cf3d6ec90c461fdd66f93b19a0
sickrage/core/webserver/handlers/api/v2/config/schemas.py = 014e84083401e6b05a9626cb29bd8467
sickrage/core/webserver/handlers/api/v2/episode/__init__.py = bfa892dee586740a3a618d3c1955156c
sickrage/core/webserver/handlers/api/v2/episode/schemas.py = 014e84083401e6b05a9626cb29bd8467
sickrage/core/webserver/handlers/api/v2/file_browser/__init__.py = 3ea22c808e52793f29f2c55a48afac94
sickrage/core/webserver/handlers/api/v2/file_browser/__init__.py = 9ad979ce18b7eb4213cda88d3ae3265b
sickrage/core/webserver/handlers/api/v2/file_browser/schemas.py = 014e84083401e6b05a9626cb29bd8467
sickrage/core/webserver/handlers/api/v2/series_provider/__init__.py = dd1a7c5fdcaa800334e2e09d7a45a3a9
sickrage/core/webserver/handlers/api/v2/series_provider/__init__.py = 6e784490dbee802254b20fcd8e42613c
sickrage/core/webserver/handlers/api/v2/series_provider/schemas.py = 014e84083401e6b05a9626cb29bd8467
sickrage/core/webserver/handlers/api/v2/history/__init__.py = 79dbaa86ccd90eaf698764dfe5dfc268
sickrage/core/webserver/handlers/api/v2/history/__init__.py = 188782bd1f1e733d1538cacbcfabedfd
sickrage/core/webserver/handlers/api/v2/history/schemas.py = 014e84083401e6b05a9626cb29bd8467
sickrage/core/webserver/handlers/api/v2/postprocess/__init__.py = f85bc7d459534c990dfabf17e2895fb6
sickrage/core/webserver/handlers/api/v2/postprocess/__init__.py = 0accc2320492872780bac98e7cbcbf89
sickrage/core/webserver/handlers/api/v2/postprocess/schemas.py = 994d368e0a2321b8311700d613695563
sickrage/core/webserver/handlers/api/v2/series/__init__.py = a99faf7a6da64f0c3f0e0f4e3304de4a
sickrage/core/webserver/handlers/api/v2/series/__init__.py = 4fe7d7074c6a01ce9ca23b501ea08602
sickrage/core/webserver/handlers/api/v2/series/schemas.py = b5159b40ee6d67aa04a85de7c7810284
sickrage/core/webserver/static/css/core.min.css = 05ca1e9c48f013d71d97ecec458b9f76
sickrage/core/webserver/static/images/ui-icons_555555_256x240.png = 971364734f3b603e5d363a2634898b42
......@@ -165,8 +165,8 @@ sickrage/core/webserver/static/images/backdrops/manage.jpg = 2e49098c0ed9aacf602
sickrage/core/webserver/static/images/backdrops/addshows.jpg = 7f3e186790208b63dadda09d6b91d334
sickrage/core/webserver/static/images/backdrops/home.jpg = 804dfc976638bbf45df310a3627e2d5c
sickrage/core/webserver/static/images/backdrops/schedule.jpg = 0c0e5f4dcee42bfcfb73de100f1d3015
sickrage/core/webserver/static/js/core.js.map = 790817bd09c781547b18a7dad44e8d8c
sickrage/core/webserver/static/js/core.min.js = dde0a5ec4125f9387cda8551268a7bf1
sickrage/core/webserver/static/js/core.js.map = 3efac89019d5ea6b6ad9959edb6f6bc0
sickrage/core/webserver/static/js/core.min.js = f77b26af442b85131b0af2d132b4545f
sickrage/core/webserver/static/fonts/fa-solid-900.eot = 89bd2e38475e441a5cd70f663f921d61
sickrage/core/webserver/static/fonts/fa-regular-400.eot = ad3a7c0d77e09602f4ab73db3660ffd8
sickrage/core/webserver/static/fonts/fa-brands-400.eot = 0fabb6606be4c45acfeedd115d0caca4
......@@ -185,7 +185,7 @@ sickrage/core/webserver/static/fonts/fa-brands-400.woff = dc0bd022735ed218df5477
sickrage/core/webserver/views/history.mako = a90a54341918b398eb652d186a636952
sickrage/core/webserver/views/login_failed.mako = 5684d10edff37970a2285d7d5bb815eb
sickrage/core/webserver/views/generic_message.mako = 20ba53fc129c1b69d5b8ccc960233757
sickrage/core/webserver/views/api_builder.mako = 4e7ea1273b10cd0d684c06cab177732d
sickrage/core/webserver/views/api_builder.mako = b1021efdfccdb7cf72d4125700c648c8
sickrage/core/webserver/views/announcements.mako = d5902b3926cc0d02cc1329676d8a9e1b
sickrage/core/webserver/views/schedule.mako = 1492940accef5afe80d9cbd14be1c078
sickrage/core/webserver/views/login.mako = 3f6c8e8325928539d6bb70a77b378116
......
......@@ -39,7 +39,7 @@ from sickrage.core.helpers import create_https_certificates
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 ApiSwaggerDotJsonHandler, ApiPingHandler, ApiProfileHandler
from sickrage.core.webserver.handlers.api.v1 import ApiHandler
from sickrage.core.webserver.handlers.api.v1 import ApiV1Handler
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.file_browser import ApiV2FileBrowserHandler
......@@ -204,7 +204,7 @@ class WebServer(object):
# API v1 Handlers
self.handlers['api_v1_handlers'] = [
# api
(fr'{self.api_v1_root}(/?.*)', ApiHandler),
(fr'{self.api_v1_root}(/?.*)', ApiV1Handler),
# api builder
(fr'{sickrage.app.config.general.web_root}/api/builder', RedirectHandler,
......
......@@ -92,7 +92,7 @@ class AccountLinkHandler(BaseHandler):
else:
authorization_url = sickrage.app.auth_server.authorization_url(redirect_uri=redirect_uri, scope="profile email")
if authorization_url:
return super(BaseHandler, self).redirect(authorization_url)
return self.redirect(authorization_url, add_web_root=False)
return self.redirect('/account/link')
......@@ -117,4 +117,4 @@ class AccountUnlinkHandler(BaseHandler):
class AccountIsLinkedHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
return self.write(json.dumps({'linked': ('true', 'false')[not sickrage.app.api.userinfo]}))
return json.dumps({'linked': ('true', 'false')[not sickrage.app.api.userinfo]})
......@@ -46,10 +46,10 @@ class MarkAnnouncementSeenHandler(BaseHandler):
if announcement:
announcement.seen = True
return self.write(json.dumps({'success': True}))
return json.dumps({'success': True})
class AnnouncementCountHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
return self.write(json.dumps({'count': sickrage.app.announcements.count()}))
return json.dumps({'count': sickrage.app.announcements.count()})
......@@ -18,9 +18,10 @@
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import ipaddress
import functools
import json
import traceback
import types
import sentry_sdk
from apispec import APISpec
......@@ -28,11 +29,12 @@ from apispec.exceptions import APISpecError
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_webframeworks.tornado import TornadoPlugin
from tornado.escape import to_basestring
from tornado.ioloop import IOLoop
from tornado.web import HTTPError
import sickrage
from sickrage.core.enums import UserPermission
from sickrage.core.helpers import get_external_ip, get_internal_ip, get_ip_address
from sickrage.core.helpers import get_internal_ip
from sickrage.core.webserver.handlers.base import BaseHandler
......@@ -104,6 +106,9 @@ class APIBaseHandler(BaseHandler):
if sickrage.app.config.general.server_id:
sentry_sdk.set_tag('server_id', sickrage.app.config.general.server_id)
method = self.run_async(getattr(self, method_name))
setattr(self, method_name, method)
except Exception:
return self.send_error(401, error='failed to decode token')
else:
......@@ -111,6 +116,14 @@ class APIBaseHandler(BaseHandler):
else:
return self.send_error(401, error='authorization header missing')
def run_async(self, method):
@functools.wraps(method)
async def wrapper(self, *args, **kwargs):
resp = await IOLoop.current().run_in_executor(self.executor, functools.partial(method, *args, **kwargs))
self.finish(resp)
return types.MethodType(wrapper, self)
def get_current_user(self):
auth_header = self.request.headers.get('Authorization')
if 'bearer' in auth_header.lower():
......@@ -135,14 +148,14 @@ class APIBaseHandler(BaseHandler):
sickrage.app.log.error(error_msg)
self.write_json({'error': error_msg})
return self.finish(self.to_json({'error': error_msg}))
def set_default_headers(self):
super(APIBaseHandler, self).set_default_headers()
self.set_header('Content-Type', 'application/json')
def write_json(self, response):
self.write(json.dumps(response))
def to_json(self, response):
return json.dumps(response)
def _validate_schema(self, schema, arguments):
return schema().validate({k: to_basestring(v[0]) if len(v) <= 1 else to_basestring(v) for k, v in arguments.items()})
......@@ -183,12 +196,12 @@ class APIBaseHandler(BaseHandler):
class ApiProfileHandler(APIBaseHandler):
def get(self):
return self.write_json(self.current_user)
return self.to_json(self.current_user)
class ApiPingHandler(APIBaseHandler):
def get(self):
return self.write_json({'message': 'pong'})
return self.to_json({'message': 'pong'})
class ApiSwaggerDotJsonHandler(APIBaseHandler):
......@@ -199,4 +212,4 @@ class ApiSwaggerDotJsonHandler(APIBaseHandler):
def get(self):
""" Get swagger.json """
return self.write_json(self.generate_swagger_json(self.api_handlers, self.api_version))
return self.to_json(self.generate_swagger_json(self.api_handlers, self.api_version))
......@@ -19,12 +19,19 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import os
from concurrent.futures.thread import ThreadPoolExecutor
import sickrage
from sickrage.core.webserver.handlers.api import APIBaseHandler
class ApiV2RetrieveSeriesMetadataHandler(APIBaseHandler):
class ApiV2BaseHandler(APIBaseHandler):
def __init__(self, application, request, **kwargs):
super(ApiV2BaseHandler, self).__init__(application, request, **kwargs)
self.executor = ThreadPoolExecutor(thread_name_prefix='APIv2-Thread')
class ApiV2RetrieveSeriesMetadataHandler(ApiV2BaseHandler):
def get(self):
series_directory = self.get_argument('seriesDirectory', None)
if not series_directory:
......@@ -54,4 +61,4 @@ class ApiV2RetrieveSeriesMetadataHandler(APIBaseHandler):
if not json_data['seriesSlug'] and series_id and series_provider_id:
json_data['seriesSlug'] = f'{series_id}-{series_provider_id.slug}'
self.write_json(json_data)
return self.to_json(json_data)
......@@ -24,10 +24,10 @@ import sickrage
from sickrage.core.common import Overview
from sickrage.core.common import Qualities, EpisodeStatus
from sickrage.core.enums import SearchFormat
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
class ApiV2ConfigHandler(APIBaseHandler):
class ApiV2ConfigHandler(ApiV2BaseHandler):
def get(self, *args, **kwargs):
config_data = sickrage.app.config.to_json()
......@@ -59,4 +59,4 @@ class ApiV2ConfigHandler(APIBaseHandler):
}
}
return self.write_json(config_data)
return self.to_json(config_data)
......@@ -20,15 +20,15 @@
# ##############################################################################
import os
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
class ApiV2FileBrowserHandler(APIBaseHandler):
class ApiV2FileBrowserHandler(ApiV2BaseHandler):
def get(self):
path = self.get_argument('path', None)
include_files = self.get_argument('includeFiles', None)
return self.write_json(self.get_path(path, bool(include_files)))
return self.to_json(self.get_path(path, bool(include_files)))
def get_path(self, path, include_files=False):
entries = {
......
......@@ -26,10 +26,10 @@ from sickrage.core import Quality
from sickrage.core.common import dateTimeFormat
from sickrage.core.helpers import convert_dict_keys_to_camelcase
from sickrage.core.tv.show.history import History
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
class ApiV2HistoryHandler(APIBaseHandler):
class ApiV2HistoryHandler(ApiV2BaseHandler):
def get(self):
"""Get snatch and download history"
---
......@@ -88,4 +88,4 @@ class ApiV2HistoryHandler(APIBaseHandler):
results.append(row)
return self.write_json(results)
return self.to_json(results)
......@@ -22,11 +22,11 @@
import sickrage
from sickrage.core.enums import ProcessMethod
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
from sickrage.core.webserver.handlers.api.v2.postprocess.schemas import PostProcessSchema
class Apiv2PostProcessHandler(APIBaseHandler):
class Apiv2PostProcessHandler(ApiV2BaseHandler):
def get(self):
"""Postprocess TV show video files"
---
......@@ -81,4 +81,4 @@ class Apiv2PostProcessHandler(APIBaseHandler):
if 'Processing succeeded' not in json_data:
return self.send_error(400, error=json_data)
self.write_json({'data': json_data if return_data else ''})
return self.to_json({'data': json_data if return_data else ''})
......@@ -23,10 +23,10 @@ import datetime
import sickrage
from sickrage.core.helpers import convert_dict_keys_to_camelcase
from sickrage.core.tv.show.coming_episodes import ComingEpisodes
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
class ApiV2ScheduleHandler(APIBaseHandler):
class ApiV2ScheduleHandler(ApiV2BaseHandler):
def get(self):
"""Get TV show schedule information"
---
......@@ -74,4 +74,4 @@ class ApiV2ScheduleHandler(APIBaseHandler):
results[i]['localtime'] = result['localtime'].timestamp()
results[i] = convert_dict_keys_to_camelcase(results[i])
return self.write_json({'episodes': results, 'today': today.timestamp(), 'nextWeek': next_week.timestamp()})
return self.to_json({'episodes': results, 'today': today.timestamp(), 'nextWeek': next_week.timestamp()})
......@@ -35,12 +35,12 @@ from sickrage.core.media.util import series_image, SeriesImageType
from sickrage.core.queues.search import ManualSearchTask
from sickrage.core.tv.episode.helpers import find_episode
from sickrage.core.tv.show.helpers import get_show_list, find_show, find_show_by_slug
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
from sickrage.core.websocket import WebSocketMessage
from .schemas import *
class ApiV2SeriesHandler(APIBaseHandler):
class ApiV2SeriesHandler(ApiV2BaseHandler):
def get(self, series_slug=None):
"""Get list of series or specific series information"
---
......@@ -87,13 +87,13 @@ class ApiV2SeriesHandler(APIBaseHandler):
all_series.append(show.to_json(progress=True))
return self.write_json(all_series)
return self.to_json(all_series)
series = find_show_by_slug(series_slug)
if series is None:
return self.send_error(404, error=f"Unable to find the specified series using slug: {series_slug}")
return self.write_json(series.to_json(episodes=True, details=True))
return self.to_json(series.to_json(episodes=True, details=True))
def post(self):
data = json_decode(self.request.body)
......@@ -181,7 +181,7 @@ class ApiV2SeriesHandler(APIBaseHandler):
sickrage.app.alerts.message(_('Adding Show'), _(f'Adding the specified show into {series_directory}'))
return self.write_json({'message': True})
return self.to_json({'message': True})
def patch(self, series_slug):
warnings, errors = [], []
......@@ -307,7 +307,7 @@ class ApiV2SeriesHandler(APIBaseHandler):
# commit changes to database
series.save()
return self.write_json(series.to_json(episodes=True, details=True))
return self.to_json(series.to_json(episodes=True, details=True))
def delete(self, series_slug):
data = json_decode(self.request.body)
......@@ -318,10 +318,10 @@ class ApiV2SeriesHandler(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': True})
return self.to_json({'message': True})
class ApiV2SeriesEpisodesHandler(APIBaseHandler):
class ApiV2SeriesEpisodesHandler(ApiV2BaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -331,20 +331,20 @@ class ApiV2SeriesEpisodesHandler(APIBaseHandler):
for episode in series.episodes:
episodes.append(episode.to_json())
return self.write_json(episodes)
return self.to_json(episodes)
class ApiV2SeriesImagesHandler(APIBaseHandler):
class ApiV2SeriesImagesHandler(ApiV2BaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
return self.send_error(404, error=f"Unable to find the specified series using slug: {series_slug}")
image = series_image(series.series_id, series.series_provider_id, SeriesImageType.POSTER_THUMB)
return self.write_json({'poster': image.url})
return self.to_json({'poster': image.url})
class ApiV2SeriesImdbInfoHandler(APIBaseHandler):
class ApiV2SeriesImdbInfoHandler(ApiV2BaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -354,10 +354,10 @@ class ApiV2SeriesImdbInfoHandler(APIBaseHandler):
imdb_info = session.query(MainDB.IMDbInfo).filter_by(imdb_id=series.imdb_id).one_or_none()
json_data = IMDbInfoSchema().dump(imdb_info)
return self.write_json(json_data)
return self.to_json(json_data)
class ApiV2SeriesBlacklistHandler(APIBaseHandler):
class ApiV2SeriesBlacklistHandler(ApiV2BaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -367,10 +367,10 @@ class ApiV2SeriesBlacklistHandler(APIBaseHandler):
blacklist = session.query(MainDB.Blacklist).filter_by(series_id=series.series_id, series_provider_id=series.series_provider_id).one_or_none()
json_data = BlacklistSchema().dump(blacklist)
return self.write_json(json_data)
return self.to_json(json_data)
class ApiV2SeriesWhitelistHandler(APIBaseHandler):
class ApiV2SeriesWhitelistHandler(ApiV2BaseHandler):
def get(self, series_slug, *args, **kwargs):
series = find_show_by_slug(series_slug)
if series is None:
......@@ -380,10 +380,10 @@ class ApiV2SeriesWhitelistHandler(APIBaseHandler):
whitelist = session.query(MainDB.Whitelist).filter_by(series_id=series.series_id, series_provider_id=series.series_provider_id).one_or_none()
json_data = WhitelistSchema().dump(whitelist)
return self.write_json(json_data)
return self.to_json(json_data)
class ApiV2SeriesRefreshHandler(APIBaseHandler):
class ApiV2SeriesRefreshHandler(ApiV2BaseHandler):
def get(self, series_slug):
force = self.get_argument('force', None)
......@@ -397,7 +397,7 @@ class ApiV2SeriesRefreshHandler(APIBaseHandler):
return self.send_error(400, error=_(f"Unable to refresh this show, error: {e}"))
class ApiV2SeriesUpdateHandler(APIBaseHandler):
class ApiV2SeriesUpdateHandler(ApiV2BaseHandler):
def get(self, series_slug):
force = self.get_argument('force', None)
......@@ -411,7 +411,7 @@ class ApiV2SeriesUpdateHandler(APIBaseHandler):
return self.send_error(400, error=_(f"Unable to update this show, error: {e}"))
class ApiV2SeriesEpisodesRenameHandler(APIBaseHandler):
class ApiV2SeriesEpisodesRenameHandler(ApiV2BaseHandler):
def get(self, series_slug):
"""Get list of episodes to rename"
---
......@@ -470,7 +470,7 @@ class ApiV2SeriesEpisodesRenameHandler(APIBaseHandler):
'newLocation': new_location,
})
return self.write_json(rename_data)
return self.to_json(rename_data)
def post(self, series_slug):
"""Rename list of episodes"
......@@ -522,10 +522,10 @@ class ApiV2SeriesEpisodesRenameHandler(APIBaseHandler):
if len(renamed_episodes) > 0:
WebSocketMessage('SHOW_RENAMED', {'seriesSlug': series.slug}).push()
return self.write_json(renamed_episodes)
return self.to_json(renamed_episodes)
class ApiV2SeriesEpisodesManualSearchHandler(APIBaseHandler):
class ApiV2SeriesEpisodesManualSearchHandler(ApiV2BaseHandler):
def get(self, series_slug, episode_slug):
"""Episode Manual Search"
---
......@@ -597,7 +597,7 @@ class ApiV2SeriesEpisodesManualSearchHandler(APIBaseHandler):
sickrage.app.search_queue.put(ep_queue_item)
if not all([ep_queue_item.started, ep_queue_item.success]):
return self.write_json({'success': True})
return self.to_json({'success': True})
return self.send_error(
status_code=404,
......
......@@ -22,15 +22,15 @@
import sickrage
from sickrage.core.enums import SeriesProviderID
from sickrage.core.webserver.handlers.api import APIBaseHandler
from sickrage.core.webserver.handlers.api.v2 import ApiV2BaseHandler
class ApiV2SeriesProvidersHandler(APIBaseHandler):