Commit f8d4e264 authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

Why use requests if we arent going to verify anyways? Maybe requests is broken with verify off

parent bf923144
......@@ -57,6 +57,14 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
if sys.hexversion >= 0x020600F0:
from multiprocessing import freeze_support # @UnresolvedImport
import certifi
for env_cert_var in ['REQUESTS_CA_BUNDLE', 'CURL_CA_BUNDLE']:
ca_cert_loc = os.environ.get(env_cert_var)
if (not isinstance(ca_cert_loc, basestring)) or (not os.path.isfile(ca_cert_loc)):
os.environ[env_cert_var] = certifi.where()
if sys.version_info >= (2, 7, 9):
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
......
......@@ -43,6 +43,7 @@ import sickbeard
import subliminal
import adba
from lib import requests
import certifi
import xmltodict
import subprocess
......@@ -1281,7 +1282,7 @@ def codeDescription(status_code):
logger.log(u"Unknown error code. Please submit an issue", logger.WARNING)
return 'unknown'
def getURL(url, post_data=None, params=None, headers={}, timeout=30, session=None, json=False, proxyGlypeProxySSLwarning=None):
def getURL(url, post_data=None, params={}, headers={}, timeout=30, session=None, json=False, proxyGlypeProxySSLwarning=None):
"""
Returns a byte-string retrieved from the url provider.
"""
......@@ -1295,7 +1296,7 @@ def getURL(url, post_data=None, params=None, headers={}, timeout=30, session=Non
session.headers.update(headers)
# request session ssl verify
session.verify = False
session.verify = certifi.where()
# request session paramaters
session.params = params
......@@ -1353,7 +1354,7 @@ def download_file(url, filename, session=None):
session.headers.update({'User-Agent': USER_AGENT, 'Accept-Encoding': 'gzip,deflate'})
# request session ssl verify
session.verify = False
session.verify = certifi.where()
# request session streaming
session.stream = True
......
......@@ -89,7 +89,7 @@ class AlphaRatioProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -91,7 +91,7 @@ class BitSoupProvider(generic.TorrentProvider):
self.session = requests.session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -104,7 +104,7 @@ class FreshOnTVProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -107,7 +107,7 @@ class HDTorrentsProvider(generic.TorrentProvider):
}
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -88,8 +88,8 @@ class HoundDawgsProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
self.session.get(self.urls['base_url'], timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
self.session.get(self.urls['base_url'], timeout=30)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -93,7 +93,7 @@ class IPTorrentsProvider(generic.TorrentProvider):
}
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -107,7 +107,7 @@ class MoreThanTVProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -118,7 +118,7 @@ class NextGenProvider(generic.TorrentProvider):
self.session = requests.Session()
self.session.headers.update(
{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20130519 Firefox/24.0)'})
data = self.session.get(self.urls['login_page'], verify=False)
data = self.session.get(self.urls['login_page'])
with BS4Parser(data.content.decode('iso-8859-1')) as bs:
csrfraw = bs.find('form', attrs={'id': 'login'})['action']
output = self.session.post(self.urls['base_url'] + csrfraw, data=login_params)
......
......@@ -109,7 +109,7 @@ class RarbgProvider(generic.TorrentProvider):
resp_json = None
try:
response = self.session.get(self.urls['token'], timeout=30, verify=False, headers=self.headers)
response = self.session.get(self.urls['token'], timeout=30, headers=self.headers)
response.raise_for_status()
resp_json = response.json()
except (RequestException, BaseSSLError) as e:
......
......@@ -92,7 +92,8 @@ class SCCProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, headers=self.headers, timeout=30, verify=False)
from lib import certifi
response = self.session.post(self.urls['login'], data=login_params, headers=self.headers, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -87,7 +87,7 @@ class SceneTimeProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -85,7 +85,7 @@ class SpeedCDProvider(generic.TorrentProvider):
}
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -151,7 +151,7 @@ class TNTVillageProvider(generic.TorrentProvider):
}
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except RequestException as e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -88,7 +88,7 @@ class TorrentBytesProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -97,7 +97,7 @@ class TorrentDayProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -92,7 +92,7 @@ class TorrentLeechProvider(generic.TorrentProvider):
self.session = requests.Session()
try:
response = self.session.post(self.urls['login'], data=login_params, timeout=30, verify=False)
response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
logger.log(u'Unable to connect to ' + self.name + ' provider: ' + ex(e), logger.ERROR)
return False
......
......@@ -191,7 +191,7 @@ class CheckVersion():
def getDBcompare(self, branchDest):
try:
response = requests.get("https://raw.githubusercontent.com/SICKRAGETV/SickRage/" + str(branchDest) +"/sickbeard/databases/mainDB.py", verify=False)
response = requests.get("https://raw.githubusercontent.com/SICKRAGETV/SickRage/" + str(branchDest) +"/sickbeard/databases/mainDB.py")
response.raise_for_status()
match = re.search(r"MAX_DB_VERSION\s=\s(?P<version>\d{2,3})",response.text)
branchDestDBversion = int(match.group('version'))
......
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