Commit f298b171 authored by echel0n's avatar echel0n

Refactored speed.cd torrent provider to use cookie login.

parent c84cb033
# Changelog
- * fa636d3 - 2018-11-12: Release v9.4.31
- * 65b6699 - 2018-11-12: Refactored speed.cd torrent provider to use cookie login.
- * 2abdafe - 2018-11-12: Release v9.4.31
- * fcdd0e0 - 2018-11-12: Added more UI notifications for version updater.
- * 971fc67 - 2018-11-12: Pre-Release v9.4.31.dev5
- * 4d0d839 - 2018-11-12: Pre-Release v9.4.31.dev4
......
......@@ -18,11 +18,8 @@
from __future__ import unicode_literals
import re
from urlparse import urljoin
from requests.utils import dict_from_cookiejar
import sickrage
from sickrage.core.caches.tv_cache import TVCache
from sickrage.core.helpers import bs4_parser, try_int, convert_size
......@@ -38,37 +35,47 @@ class SpeedCDProvider(TorrentProvider):
'search': '{base_url}/browse.php'.format(**self.urls),
})
self.username = None
self.password = None
# self.username = None
# self.password = None
self.freeleech = False
self.minseed = None
self.minleech = None
self.enable_cookies = True
self.required_cookies = ('inSpeed_uid', 'inSpeed_speedian')
self.proper_strings = ['PROPER', 'REPACK', 'REAL', 'RERIP']
self.cache = TVCache(self, min_time=20)
def login(self):
if any(dict_from_cookiejar(self.session.cookies).values()):
return True
login_params = {'username': self.username,
'password': self.password}
try:
data = bs4_parser(self.session.get(self.urls['login']).text)
login_url = data.soup.find('form', id='loginform').get('action')
response = self.session.post(login_url, data=login_params, timeout=30).text
except Exception:
sickrage.app.log.warning("Unable to connect to provider")
return False
if re.search('Incorrect username or Password. Please try again.', response):
sickrage.app.log.warning("Invalid username or password. Check your settings")
return False
return True
return self.cookie_login('log in')
# def login(self):
# if any(dict_from_cookiejar(self.session.cookies).values()):
# return True
#
# login_params = {
# 'username': self.username,
# 'password': self.password
# }
#
# try:
# with bs4_parser(self.session.get(self.urls['login']).text) as html:
# login_url = urljoin(self.urls['base_url'], html.find('form', id='loginform').get('action'))
# response = self.session.post(login_url, data=login_params, timeout=30).text
# except Exception:
# sickrage.app.log.warning("Unable to connect to provider")
# self.session.cookies.clear()
# return False
#
# if 'logout.php' not in response.lower():
# sickrage.app.log.warning("Invalid username or password, check your settings.")
# self.session.cookies.clear()
# return False
#
# return True
def search(self, search_strings, age=0, ep_obj=None, **kwargs):
results = []
......
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