Commit 34521b84 authored by echel0n's avatar echel0n

Fixed #SICKRAGE-APP-5RS - AttributeError sickrage.providers in cookie_login

Fixed #SICKRAGE-APP-5SB - AttributeError sickrage.core.webserver.handlers.root in handle_post
Fixed #SICKRAGE-APP-5S8 - RuntimeError threading in start
Fixed #SICKRAGE-APP-5RJ - TypeError sickrage.core.version_updater in _git_cmd
Fixed #SICKRAGE-APP-5RM - ConnectionError requests.adapters in send
Downgraded error to warning before SystemExit raised due to corrupt config detected
parent acccef41
......@@ -39,17 +39,21 @@ class QBittorrentAPI(TorrentClient):
url = urljoin(self.host, 'api/v2/app/webapiVersion')
response = self.session.get(url, verify=sickrage.app.config.torrent_verify_cert)
if response and response.text:
version = tuple(map(int, response.text.split('.')))
version + (0,) * (3 - len(version))
elif response is not None:
status_code = response.status_code
if status_code == 404:
url = urljoin(self.host, 'version/api')
response = self.session.get(url, verify=sickrage.app.config.torrent_verify_cert)
if response.text:
version = int(response.text)
version = (1, version % 100, 0)
try:
if response and response.text:
version = tuple(map(int, response.text.split('.')))
version + (0,) * (3 - len(version))
elif response is not None:
status_code = response.status_code
if status_code == 404:
url = urljoin(self.host, 'version/api')
response = self.session.get(url, verify=sickrage.app.config.torrent_verify_cert)
if response and response.text:
version = int(response.text)
version = (1, version % 100, 0)
except ValueError:
pass
return version
......
......@@ -335,9 +335,6 @@ class Core(object):
if self.config.showupdate_hour < 0 or self.config.showupdate_hour > 23:
self.config.showupdate_hour = 0
# start web server
self.wserver.start()
# add version checker job
self.scheduler.add_job(
self.version_updater.task,
......@@ -507,6 +504,9 @@ class Core(object):
self.show_queue.start_worker(self.config.max_queue_workers)
self.postprocessor_queue.start_worker(self.config.max_queue_workers)
# start web server
self.wserver.start()
# fire off jobs now
self.scheduler.get_job(self.version_updater.name).modify(next_run_time=datetime.datetime.utcnow())
self.scheduler.get_job(self.tz_updater.name).modify(next_run_time=datetime.datetime.utcnow())
......
......@@ -1397,7 +1397,7 @@ class Config(object):
try:
self.config_obj = self.decrypt_config(config_file)
except Exception:
sickrage.app.log.error("Unable to decrypt config file {}, config is most likely corrupted and needs to be deleted.".format(config_file))
sickrage.app.log.warning("Unable to decrypt config file {}, config is most likely corrupted and needs to be deleted.".format(config_file))
raise SystemExit
# use defaults
......
......@@ -52,6 +52,7 @@ from bs4 import BeautifulSoup
import sickrage
from sickrage.core.helpers import encryption
from sickrage.core.websession import WebSession
def safe_getattr(object, name, default=None):
......@@ -1761,7 +1762,10 @@ def get_extension(filename):
def get_external_ip():
"""Return external IP of system."""
return requests.get('https://api.ipify.org').text
resp = WebSession().get('https://api.ipify.org')
if not resp or not resp.text:
return ''
return resp.text
def get_internal_ip():
......
......@@ -263,9 +263,9 @@ class UpdateManager(object):
output, err = p.communicate()
exit_status = p.returncode
if output:
if output is not None:
output = output.decode("utf-8", "ignore").strip() if isinstance(output, bytes) else output.strip()
except OSError:
except (RuntimeError, OSError):
sickrage.app.log.info("Command " + ' '.join(cmd) + " didn't work")
exit_status = 1
......@@ -306,7 +306,7 @@ class UpdateManager(object):
output, err = p.communicate()
exit_status = p.returncode
except OSError:
except (RuntimeError, OSError):
sickrage.app.log.info("Command " + ' '.join(cmd) + " didn't work")
exit_status = 1
......
......@@ -278,6 +278,10 @@ class QuicksearchDotJsonHandler(BaseHandler, ABC):
})
for result in session.query(MainDB.TVEpisode).filter(MainDB.TVEpisode.name.like('%{}%'.format(term))).all():
show_object = find_show(result.showid)
if not show_object:
continue
episodes.append({
'category': 'episodes',
'showid': result.showid,
......@@ -285,7 +289,7 @@ class QuicksearchDotJsonHandler(BaseHandler, ABC):
'season': result.season,
'episode': result.episode,
'name': result.name,
'showname': find_show(result.showid).name,
'showname': show_object.name,
'img': sickrage.app.config.web_root + showImage(result.showid, 'poster_thumb').url
})
......
......@@ -499,33 +499,25 @@ class GenericProvider(object):
if self.cookies:
result = self.add_cookies_from_ui()
if not result['result']:
if not result.get('result'):
sickrage.app.alerts.message(result['message'])
sickrage.app.log.warning(result['message'])
return False
else:
sickrage.app.log.warning('Failed to login, you will need to add your cookies in the provider '
'settings')
sickrage.app.log.warning('Failed to login, you will need to add your cookies in the provider settings')
sickrage.app.alerts.error(
'Failed to auth with {provider}'.format(provider=self.name),
'You will need to add your cookies in the provider settings')
sickrage.app.alerts.error('Failed to auth with {provider}'.format(provider=self.name),
'You will need to add your cookies in the provider settings')
return False
response = self.session.get(check_url)
if any([not response, not (response.text and response.status_code == 200),
check_login_text.lower() in response.text.lower()]):
sickrage.app.log.warning('Please configure the required cookies for this provider. Check your '
'provider settings')
sickrage.app.alerts.error(
'Wrong cookies for {}'.format(self.name),
'Check your provider settings'
)
if not response or not response.text or not response.status_code == 200 or not check_login_text.lower() in response.text.lower():
sickrage.app.log.warning('Please configure the required cookies for this provider. Check your provider settings')
sickrage.app.alerts.error('Wrong cookies for {}'.format(self.name), 'Check your provider settings')
self.session.cookies.clear()
return False
else:
return True
return True
@classmethod
def getDefaultProviders(cls):
......
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