Commit 9c4ff3aa authored by echel0n's avatar echel0n

Merge branch 'release/10.0.4'

# Conflicts:
#	CHANGELOG.md
#	package.json
#	setup.cfg
#	sickrage/checksums.md5
#	sickrage/core/webserver/static/js/core.min.js
#	sickrage/version.txt
parents bb09a875 e370dfd3
......@@ -109,22 +109,23 @@ release_build_master:
- apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
- git config --global user.email $(git --no-pager show -s --format='%ae' HEAD)
- git config --global user.name $(git --no-pager show -s --format='%an' HEAD)
- yarn install --pure-lockfile --cache-folder .yarn-cache
- git reset --hard
- pip install bumpversion
- pip install -r requirements-dev.txt
- RELEASE_VERSION=$(bumpversion --dry-run --list release | awk -F= '/new_version=/ { print $2 }')
- bumpversion --allow-dirty release package.json sickrage/version.txt
- git checkout -b release-$(cat sickrage/version.txt)
- npx auto-changelog -v $RELEASE_VERSION --hide-credit --package --commit-limit false --ignore-commit-pattern \[TASK\].*
- yarn install --pure-lockfile --cache-folder .yarn-cache
- yarn run build
- python checksum-generator.py
- git checkout -b release/$RELEASE_VERSION
- git fetch --all
- git add --all
- git commit -m "[TASK] Releasing v$(cat sickrage/version.txt)"
- git fetch . release-$(cat sickrage/version.txt):master
- git fetch . release-$(cat sickrage/version.txt):develop
- git tag -a $(cat sickrage/version.txt) -m "Release v$(cat sickrage/version.txt) master"
- npx auto-changelog --hide-credit --package --commit-limit false --ignore-commit-pattern \[TASK\].*
- git add CHANGELOG.md
- git commit --amend --no-edit
- git tag -f -a $(cat sickrage/version.txt) -m "Release v$(cat sickrage/version.txt) master"
- git commit -m "[TASK] Releasing v$RELEASE_VERSION"
- git checkout master
- git fetch --all
- git merge --ff-only release/$RELEASE_VERSION
- git tag -a $RELEASE_VERSION -m "Release v$RELEASE_VERSION master"
- git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master --follow-tags
- git checkout develop
- bumpversion --allow-dirty patch package.json sickrage/version.txt
......@@ -155,6 +156,7 @@ release_build_develop:
- pip install bumpversion
- pip install -r requirements-dev.txt
- bumpversion --allow-dirty dev package.json sickrage/version.txt
- npx auto-changelog -v $(cat sickrage/version.txt) --hide-credit --unreleased --package --commit-limit false --ignore-commit-pattern \[TASK\].*
- yarn run build
- python checksum-generator.py
# - python setup.py extract_messages
......@@ -166,10 +168,6 @@ release_build_develop:
- git add --all
- git commit -m "[TASK] Pre-Releasing v$(cat sickrage/version.txt)"
- git tag -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
- npx auto-changelog --hide-credit --unreleased --package --commit-limit false --ignore-commit-pattern \[TASK\].*
- git add CHANGELOG.md
- git commit --amend --no-edit
- git tag -f -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
- git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --follow-tags
only:
- [email protected]/sickrage
......
This diff is collapsed.
{
"name": "sickrage",
"version": "10.0.3",
"version": "10.0.4",
"private": true,
"repository": {
"type": "git",
......
[bumpversion]
current_version = 10.0.3
current_version = 10.0.4
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
......
This diff is collapsed.
......@@ -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(
......
......@@ -17,7 +17,7 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
import datetime
from sqlalchemy import Column, Integer, Text, ForeignKeyConstraint, String, DateTime, Boolean, Index, Date, BigInteger, func, literal_column, Enum
from sqlalchemy import Column, Integer, Text, ForeignKeyConstraint, String, DateTime, Boolean, Index, Date, BigInteger, func, literal_column, Enum, exists
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
......@@ -37,6 +37,65 @@ class MainDB(SRDatabase):
self.base.metadata.create_all(self.engine)
def cleanup(self):
def remove_orphaned():
session = self.session()
# orphaned episode entries
for orphaned_result in session.query(self.TVEpisode).filter(~exists().where(self.TVEpisode.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned episode detected! episode_id: {orphaned_result.episode_id}")
sickrage.app.log.info(f"Deleting orphaned episode with episode_id: {orphaned_result.episode_id}")
session.delete(orphaned_result)
session.commit()
# orphaned imdb info entries
for orphaned_result in session.query(self.IMDbInfo).filter(~exists().where(self.IMDbInfo.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned imdb info detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned imdb info with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
# orphaned series provider mapping entries
for orphaned_result in session.query(self.SeriesProviderMapping).filter(~exists().where(self.SeriesProviderMapping.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned series provider mapper detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned series provider mapper with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
# orphaned whitelist entries
for orphaned_result in session.query(self.Whitelist).filter(~exists().where(self.Whitelist.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned whitelist detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned whitelist with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
# orphaned blacklist entries
for orphaned_result in session.query(self.Blacklist).filter(~exists().where(self.Blacklist.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned blacklist detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned blacklist with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
# orphaned history entries
for orphaned_result in session.query(self.History).filter(~exists().where(self.History.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned history detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned history with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
# orphaned failed snatch history entries
for orphaned_result in session.query(self.FailedSnatchHistory).filter(~exists().where(self.FailedSnatchHistory.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned failed snatch history detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned failed snatch history with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
# orphaned failed snatch entries
for orphaned_result in session.query(self.FailedSnatch).filter(~exists().where(self.FailedSnatch.series_id == self.TVShow.series_id)):
sickrage.app.log.debug(f"Orphaned failed snatch detected! series_id: {orphaned_result.series_id}")
sickrage.app.log.info(f"Deleting orphaned failed snatch with series_id: {orphaned_result.series_id}")
session.delete(orphaned_result)
session.commit()
def remove_duplicate_shows():
session = self.session()
......@@ -223,6 +282,7 @@ class MainDB(SRDatabase):
session.commit()
remove_orphaned()
remove_duplicate_shows()
remove_duplicate_episodes()
remove_invalid_episodes()
......@@ -271,8 +331,14 @@ class MainDB(SRDatabase):
last_backlog_search = Column(DateTime(timezone=True), default=datetime.datetime.now())
last_proper_search = Column(DateTime(timezone=True), default=datetime.datetime.now())
episodes = relationship('TVEpisode', uselist=True, backref='tv_shows', lazy='dynamic')
imdb_info = relationship('IMDbInfo', uselist=False, backref='tv_shows')
episodes = relationship('TVEpisode', uselist=True, backref='tv_shows', cascade="all, delete-orphan", lazy='dynamic')
imdb_info = relationship('IMDbInfo', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
series_provider_mapping = relationship('SeriesProviderMapping', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
blacklist = relationship('Blacklist', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
whitelist = relationship('Whitelist', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
history = relationship('History', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
failed_snatch_history = relationship('FailedSnatchHistory', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
failed_snatches = relationship('FailedSnatch', uselist=False, backref='tv_shows', cascade="all, delete-orphan")
class TVEpisode(base):
__tablename__ = 'tv_episodes'
......
This diff is collapsed.
......@@ -1111,9 +1111,8 @@ class TVShow(object):
# remove from database
with sickrage.app.main_db.session() as session:
session.query(MainDB.TVShow).filter_by(series_id=self.series_id).delete()
# session.query(MainDB.TVEpisode).filter_by(series_id=self.series_id).delete()
# session.query(MainDB.IMDbInfo).filter_by(series_id=self.series_id).delete()
series = session.query(MainDB.TVShow).filter_by(series_id=self.series_id, series_provider_id=self.series_provider_id).one()
session.delete(series)
session.commit()
# remove episodes from show episode cache
......
......@@ -27,7 +27,6 @@ from sickrage.core.common import timeFormat, dateFormat
from sickrage.core.databases.main import MainDB
from sickrage.core.helpers import flatten
from sickrage.core.helpers.srdatetime import SRDateTime
from sickrage.core.tv.show.helpers import get_show_list
class ComingEpsLayout(enum.Enum):
......@@ -158,46 +157,29 @@ 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,
with sickrage.app.main_db.session() as session:
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)
)]
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.status.in_(qualities_list)):
# if not episode.show:
# continue
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)
)]
~MainDB.TVEpisode.status.in_(qualities_list)):
# if not episode.show:
# continue
add_result(episode.show, episode, grouped=group)
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):
......
......@@ -19,8 +19,6 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import json
import os
from abc import ABC
import sentry_sdk
from tornado.web import authenticated
......@@ -31,7 +29,7 @@ from sickrage.core.helpers import get_internal_ip, get_external_ip
from sickrage.core.webserver.handlers.base import BaseHandler
class AccountLinkHandler(BaseHandler, ABC):
class AccountLinkHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
code = self.get_argument('code', None)
......@@ -101,7 +99,7 @@ class AccountLinkHandler(BaseHandler, ABC):
return self.redirect('/account/link')
class AccountUnlinkHandler(BaseHandler, ABC):
class AccountUnlinkHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
if not sickrage.app.config.general.server_id or sickrage.app.api.account.unregister_server(sickrage.app.config.general.server_id):
......@@ -118,7 +116,7 @@ class AccountUnlinkHandler(BaseHandler, ABC):
sickrage.app.alerts.message(_('Unlinked SiCKRAGE account from SiCKRAGE API'))
class AccountIsLinkedHandler(BaseHandler, ABC):
class AccountIsLinkedHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
return self.write(json.dumps({'linked': ('true', 'false')[not sickrage.app.api.userinfo]}))
......@@ -19,14 +19,13 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import json
from abc import ABC
import sickrage
from sickrage.core.webserver.handlers.base import BaseHandler
from sickrage.libs.trakt.interfaces.base import authenticated
class AnnouncementsHandler(BaseHandler, ABC):
class AnnouncementsHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
return self.render('announcements.mako',
......@@ -38,7 +37,7 @@ class AnnouncementsHandler(BaseHandler, ABC):
action='announcements')
class MarkAnnouncementSeenHandler(BaseHandler, ABC):
class MarkAnnouncementSeenHandler(BaseHandler):
@authenticated
def post(self, *args, **kwargs):
ahash = self.get_argument('ahash')
......@@ -50,7 +49,7 @@ class MarkAnnouncementSeenHandler(BaseHandler, ABC):
return self.write(json.dumps({'success': True}))
class AnnouncementCountHandler(BaseHandler, ABC):
class AnnouncementCountHandler(BaseHandler):
@authenticated
def get(self, *args, **kwargs):
return self.write(json.dumps({'count': sickrage.app.announcements.count()}))
......@@ -20,7 +20,6 @@
# ##############################################################################
import json
import traceback
from abc import ABC
import sentry_sdk
from apispec import APISpec
......@@ -36,7 +35,7 @@ from sickrage.core.helpers import get_external_ip, get_internal_ip
from sickrage.core.webserver.handlers.base import BaseHandler
class APIBaseHandler(BaseHandler, ABC):
class APIBaseHandler(BaseHandler):
def prepare(self):
super(APIBaseHandler, self).prepare()
......@@ -58,11 +57,21 @@ class APIBaseHandler(BaseHandler, ABC):
sickrage.app.config.save(mark_dirty=True)
if sickrage.app.config.user.sub_id == decoded_token.get('sub'):
save_config = False
if not sickrage.app.config.user.username:
sickrage.app.config.user.username = decoded_token.get('preferred_username')
sickrage.app.config.user.email = decoded_token.get('email')
sickrage.app.config.user.permissions = UserPermission.SUPERUSER
sickrage.app.config.save()
save_config = True
if not sickrage.app.config.user.email:
sickrage.app.config.user.email = decoded_token.get('email')
save_config = True
if not sickrage.app.config.user.permissions == UserPermission.SUPERUSER:
sickrage.app.config.user.permissions = UserPermission.SUPERUSER
save_config = True
if save_config:
sickrage.app.config.save()
if sickrage.app.config.user.sub_id == decoded_token.get('sub'):
sentry_sdk.set_user({
......@@ -79,16 +88,8 @@ class APIBaseHandler(BaseHandler, ABC):
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):
......@@ -173,14 +174,14 @@ class APIBaseHandler(BaseHandler, ABC):
return spec.to_dict()
class PingHandler(APIBaseHandler, ABC):
class ApiPingHandler(APIBaseHandler):
def get(self):
return self.write_json({'message': 'pong'})
class SwaggerDotJsonHandler(APIBaseHandler, ABC):
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
......
......@@ -19,13 +19,12 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import os
from abc import ABC
import sickrage
from sickrage.core.webserver.handlers.api import APIBaseHandler
class RetrieveSeriesMetadataHandler(APIBaseHandler, ABC):
class ApiV2RetrieveSeriesMetadataHandler(APIBaseHandler):
def get(self):
series_directory = self.get_argument('seriesDirectory', None)
if not series_directory:
......
......@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
from abc import ABC
import sickrage
from sickrage.core.common import Overview
......@@ -27,7 +27,7 @@ from sickrage.core.enums import SearchFormat
from sickrage.core.webserver.handlers.api import APIBaseHandler
class ConfigHandler(APIBaseHandler, ABC):
class ApiV2ConfigHandler(APIBaseHandler):
def get(self, *args, **kwargs):
config_data = sickrage.app.config.to_json()
......