Commit d4b634c4 authored by echel0n's avatar echel0n
Browse files

Release v9.3.73

parent be3c7088
# Changelog
- * 9a5db91 - 2018-09-08: Release v9.3.72
- * e9c1a16 - 2018-09-08: Release v9.3.73
- * 0f56bf7 - 2018-09-08: Release v9.3.72
- * 5c3c795 - 2018-09-08: Pre-Release v9.3.72.dev1
- * 3b8de1e - 2018-09-08: Release v9.3.71
- * cf75694a - 2018-09-08: Release v9.3.70
......
......@@ -27,6 +27,7 @@ class API(object):
def token(self):
if sickrage.app.config.app_oauth_token:
return json.loads(sickrage.app.config.app_oauth_token)
return {}
@token.setter
def token(self, value):
......@@ -38,10 +39,10 @@ class API(object):
return self._request('GET', 'userinfo')
def register_appid(self, appid, username=""):
self._request('POST', 'register-appid', json={'appid': appid})
return self._request('POST', 'register-appid', json={'appid': appid})
def unregister_appid(self, appid):
self._request('POST', 'unregister-appid', json={'appid': appid})
return self._request('POST', 'unregister-appid', json={'appid': appid})
def _request(self, method, url, **kwargs):
try:
......@@ -49,13 +50,13 @@ class API(object):
hooks={'response': self.throttle_hook}, **kwargs)
if resp.status_code == 401:
msg = resp.json()['error']
if not self.token_refreshed:
raise TokenExpiredError
raise error(msg)
if 'error' in resp.json():
raise error(resp.json()['error'])
elif resp.status_code >= 400:
msg = resp.json()['error']
raise error(msg)
if 'error' in resp.json():
raise error(resp.json()['error'])
return resp.json()
except TokenExpiredError:
......@@ -67,18 +68,12 @@ class API(object):
def refresh_token(self):
self.token_refreshed = True
extras = {
'client_id': self.client_id,
'client_secret': self.client_secret,
'refresh_token': sickrage.app.config.app_oauth_refresh_token
}
extras = {'client_id': self.client_id, 'client_secret': self.client_secret}
try:
if sickrage.app.config.app_oauth_refresh_token:
self.token = self.session.refresh_token(self.token_url, **extras)
self.token = self.session.refresh_token(self.token_url, **extras)
except InvalidGrantError as e:
sickrage.app.config.app_oauth_refresh_token = ''
sickrage.app.config.save()
self.token = ''
@staticmethod
def throttle_hook(response, **kwargs):
......
......@@ -3,12 +3,11 @@ from sickrage.core import API
class ProviderCacheAPI(API):
def get(self, provider, indexerid, season, episode):
query = 'cache/providers/{}/indexerids/{}/seasons/()/episodes/()'.format(provider, indexerid, season,
episode)
query = 'cache/providers/{}/indexerids/{}/seasons/()/episodes/()'.format(provider, indexerid, season, episode)
return self._request('GET', query)
def add(self, data):
self._request('POST', 'cache/providers', json=data)
return self._request('POST', 'cache/providers', json=data)
class TorrentCacheAPI(API):
......@@ -17,4 +16,4 @@ class TorrentCacheAPI(API):
return self._request('GET', query)
def add(self, url):
self._request('POST', 'cache/torrents', data=dict({'url': url}))
return self._request('POST', 'cache/torrents', data=dict({'url': url}))
......@@ -55,7 +55,6 @@ class Config(object):
self.app_id = ""
self.app_oauth_token = ""
self.app_oauth_refresh_token = ""
self.debug = False
......@@ -692,7 +691,6 @@ class Config(object):
'General': {
'app_id': self.app_id or str(uuid.uuid4()),
'app_oauth_token': '',
'app_oauth_refresh_token': '',
'enable_api_providers_cache': True,
'log_size': 1048576,
'calendar_unprotected': False,
......@@ -1388,7 +1386,6 @@ class Config(object):
self.config_version = self.check_setting_int('General', 'config_version')
self.app_id = self.check_setting_str('General', 'app_id')
self.app_oauth_token = self.check_setting_str('General', 'app_oauth_token')
self.app_oauth_refresh_token = self.check_setting_str('General', 'app_oauth_refresh_token')
self.enable_api_providers_cache = self.check_setting_bool('General', 'enable_api_providers_cache')
self.debug = sickrage.app.debug or self.check_setting_bool('General', 'debug')
self.last_db_compact = self.check_setting_int('General', 'last_db_compact')
......@@ -1884,7 +1881,6 @@ class Config(object):
'last_db_compact': self.last_db_compact,
'app_id': self.app_id,
'app_oauth_token': self.app_oauth_token,
'app_oauth_refresh_token': self.app_oauth_refresh_token,
'enable_api_providers_cache': int(self.enable_api_providers_cache),
'git_autoissues': int(self.git_autoissues),
'git_username': self.git_username,
......
......@@ -150,7 +150,7 @@ class BaseHandler(RequestHandler):
def get_current_user(self):
try:
try:
return sickrage.app.oidc_client.userinfo(self.get_secure_cookie('access_token'))
return sickrage.app.oidc_client.userinfo(self.get_secure_cookie('sr_access_token'))
except HTTPError:
token = sickrage.app.oidc_client.refresh_token(self.get_secure_cookie('sr_refresh_token'))
self.set_secure_cookie('sr_access_token', token['access_token'])
......@@ -280,14 +280,16 @@ class LoginHandler(BaseHandler):
self.set_secure_cookie('sr_access_token', token['access_token'])
self.set_secure_cookie('sr_refresh_token', token['refresh_token'])
if not sickrage.app.config.app_oauth_refresh_token:
if not API().token:
exchange = {'scope': 'offline_access', 'subject_token': token['access_token']}
API().token = sickrage.app.oidc_client.token_exchange(**exchange)
API().register_appid(sickrage.app.config.app_id)
sickrage.app.config.app_oauth_refresh_token = API().token['refresh_token']
sickrage.app.config.save()
elif sickrage.app.oidc_client.userinfo(token['access_token'])['sub'] != API().userinfo['sub']:
return self.redirect('/logout')
if not bool(API().register_appid(sickrage.app.config.app_id)['success']):
API().token = sickrage.app.oidc_client.logout(API().token['refresh_token'])
return self.redirect('/logout')
else:
app_ids = sickrage.app.oidc_client.userinfo(token['access_token']).get('appid', [])
if sickrage.app.config.app_id not in app_ids:
return self.redirect('/logout')
except Exception as e:
return self.redirect('/logout')
......@@ -534,13 +536,11 @@ class WebRoot(WebHandler):
)
def unlink(self):
if self.get_current_user()['sub'] != API().userinfo['sub']:
if sickrage.app.config.app_id not in self.get_current_user().get('appid', []):
return self.redirect("/{}/".format(sickrage.app.config.default_page))
API().unregister_appid(sickrage.app.config.app_id)
sickrage.app.oidc_client.logout(sickrage.app.config.app_oauth_refresh_token)
sickrage.app.config.app_oauth_refresh_token = ''
sickrage.app.config.save()
API().token = sickrage.app.oidc_client.logout(API().token['refresh_token'])
return self.redirect('/logout/')
......
......@@ -322,7 +322,7 @@
class="confirm shutdown">
<i class="fas fa-power-off"></i>&nbsp;${_('Shutdown')}
</a>
% if current_user['sub'] == API().userinfo['sub']:
% if sickrage.app.config.app_id in current_user.get('appid', []):
<a class="dropdown-item" href="${srWebRoot}/unlink" class="confirm logout">
<i class="fas fa-unlink"></i>&nbsp;${_('Unlink Account')}
</a>
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: Arabic\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "عند بدء تشغيل واجهة سيكراجي"
msgid "Shows"
msgstr "يظهر"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6197,11 +6197,11 @@ msgstr "خطأ HTTP 404"
msgid "HTTP Error 500"
msgstr "خطأ HTTP 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "لا يتم إنشاء مفتاح API"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "منشئ API"
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: Catalan\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "Quan s'iniciï la interfície SickRage"
msgid "Shows"
msgstr "Espectacles"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6197,11 +6197,11 @@ msgstr "HTTP Error 404"
msgid "HTTP Error 500"
msgstr "Error de HTTP 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "Clau d'API no genera"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "Constructor d'API"
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: Czech\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "Při spuštění rozhraní SickRage"
msgid "Shows"
msgstr "Ukazuje"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6197,11 +6197,11 @@ msgstr "Chyba HTTP 404"
msgid "HTTP Error 500"
msgstr "Chyba protokolu HTTP 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "Není generován klíč API"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "API Tvůrce"
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: Danish\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "Når indlede SickRage interface"
msgid "Shows"
msgstr "Viser"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6197,11 +6197,11 @@ msgstr "Http-fejl 404"
msgid "HTTP Error 500"
msgstr "Http-fejl 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "API-nøgle genereres ikke"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "API Builder"
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "beim Start von SickRage Schnittstelle"
msgid "Shows"
msgstr "Zeigt"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6197,11 +6197,11 @@ msgstr "HTTP-Fehler 404"
msgid "HTTP Error 500"
msgstr "HTTP-Fehler 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "API-Schlüssel generiert nicht"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "API-Generator"
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: Greek\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "κατά την εκκίνηση του SickRage διασύνδεση"
msgid "Shows"
msgstr "Δείχνει"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6197,11 +6197,11 @@ msgstr "Σφάλμα HTTP 404"
msgid "HTTP Error 500"
msgstr "Σφάλμα HTTP 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "API κλειδί δεν δημιουργείται"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "API οικοδόμος"
......
......@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sickragetv\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2018-09-08 16:58-0700\n"
"PO-Revision-Date: 2018-09-08 23:58\n"
"POT-Creation-Date: 2018-09-08 22:01-0700\n"
"PO-Revision-Date: 2018-09-09 05:01\n"
"Last-Translator: echel0n <[email protected]>\n"
"Language-Team: English\n"
"MIME-Version: 1.0\n"
......@@ -761,7 +761,7 @@ msgstr "when launching SickRage interface"
msgid "Shows"
msgstr "Shows"
#: sickrage/core/webserver/views.py:529 sickrage/core/webserver/views.py:530
#: sickrage/core/webserver/views.py:531 sickrage/core/webserver/views.py:532
#: sickrage/core/webserver/views/config/general.mako:145
#: sickrage/core/webserver/views/layouts/main.mako:220
msgid "Schedule"
......@@ -6201,11 +6201,11 @@ msgstr "HTTP Error 404"
msgid "HTTP Error 500"
msgstr "HTTP Error 500"
#: sickrage/core/webserver/views.py:427
#: sickrage/core/webserver/views.py:429
msgid "API Key not generated"
msgstr "API Key not generated"
#: sickrage/core/webserver/views.py:431 sickrage/core/webserver/views.py:432
#: sickrage/core/webserver/views.py:433 sickrage/core/webserver/views.py:434
msgid "API Builder"
msgstr "API Builder"
......
Supports Markdown
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