Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7236 from fiLLLip/develop
Browse files Browse the repository at this point in the history
Fix login problems with BitHDTV provider
  • Loading branch information
RuudBurger committed Nov 4, 2017
2 parents 0186d12 + 1310050 commit 7abc56b
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions couchpotato/core/media/_base/providers/torrent/bithdtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
class Base(TorrentProvider):

urls = {
'test': 'https://www.bit-hdtv.com/',
'login': 'https://www.bit-hdtv.com/takelogin.php',
'login_check': 'https://www.bit-hdtv.com/messages.php',
'detail': 'https://www.bit-hdtv.com/details.php?id=%s',
'search': 'https://www.bit-hdtv.com/torrents.php?',
'download': 'https://www.bit-hdtv.com/download.php?id=%s',
Expand All @@ -31,7 +28,7 @@ def _search(self, media, quality, results):

url = "%s&%s" % (self.urls['search'], query)

data = self.getHTMLData(url)
data = self.getHTMLData(url, headers = self.getRequestHeaders())

if data:
# Remove BiT-HDTV's output garbage so outdated BS4 versions successfully parse the HTML
Expand All @@ -42,11 +39,12 @@ def _search(self, media, quality, results):
html = BeautifulSoup(data, 'html.parser')

try:
result_tables = html.find_all('table', attrs = {'width': '750', 'class': ''})
result_tables = html.find_all('table', attrs = {'width': '800', 'class': ''})
if result_tables is None:
return

result_table = result_tables[1]
# Take first result
result_table = result_tables[0]

if result_table is None:
return
Expand All @@ -72,10 +70,10 @@ def _search(self, media, quality, results):
except:
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))

def getLoginParams(self):
def getRequestHeaders(self):
cookies = 'h_sl={};h_sp={};h_su={}'.format(self.conf('cookiesettingsl') or '', self.conf('cookiesettingsp') or '', self.conf('cookiesettingsu') or '')
return {
'username': self.conf('username'),
'password': self.conf('password'),
'Cookie': cookies
}

def getMoreInfo(self, item):
Expand All @@ -87,11 +85,13 @@ def getMoreInfo(self, item):
item['description'] = description
return item

def loginSuccess(self, output):
return 'logout.php' in output.lower()

loginCheckSuccess = loginSuccess
def download(self, url = '', nzb_id = ''):
try:
return self.urlopen(url, headers=self.getRequestHeaders())
except:
log.error('Failed getting release from %s: %s', (self.getName(), traceback.format_exc()))

return 'try_next'

config = [{
'name': 'bithdtv',
Expand All @@ -110,13 +110,22 @@ def loginSuccess(self, output):
'default': False,
},
{
'name': 'username',
'name': 'cookiesettingsl',
'label': 'Cookies (h_sl)',
'default': '',
'description': 'Cookie h_sl from session',
},
{
'name': 'cookiesettingsp',
'label': 'Cookies (h_sp)',
'default': '',
'description': 'Cookie h_sp from session',
},
{
'name': 'password',
'name': 'cookiesettingsu',
'label': 'Cookies (h_su)',
'default': '',
'type': 'password',
'description': 'Cookie h_su from session',
},
{
'name': 'seed_ratio',
Expand Down

0 comments on commit 7abc56b

Please sign in to comment.