From a2c5074d6616edea12718be5d6ec93ace04a177f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Sat, 16 Nov 2013 02:58:29 +0100 Subject: [PATCH] fixed bithdtv provider --- .../core/providers/torrent/bithdtv/__init__.py | 3 +- couchpotato/core/providers/torrent/bithdtv/main.py | 47 +++++++++++++--------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/couchpotato/core/providers/torrent/bithdtv/__init__.py b/couchpotato/core/providers/torrent/bithdtv/__init__.py index bc94e6b..7803419 100644 --- a/couchpotato/core/providers/torrent/bithdtv/__init__.py +++ b/couchpotato/core/providers/torrent/bithdtv/__init__.py @@ -8,7 +8,6 @@ config = [{ 'groups': [ { 'tab': 'searcher', - 'subtab': 'providers', 'list': 'torrent_providers', 'name': 'BiT-HDTV', 'description': 'See BiT-HDTV', @@ -53,4 +52,4 @@ config = [{ ], }, ], -}] +}] \ No newline at end of file diff --git a/couchpotato/core/providers/torrent/bithdtv/main.py b/couchpotato/core/providers/torrent/bithdtv/main.py index d07e11f..6faa20c 100644 --- a/couchpotato/core/providers/torrent/bithdtv/main.py +++ b/couchpotato/core/providers/torrent/bithdtv/main.py @@ -1,4 +1,3 @@ -from datetime import datetime from bs4 import BeautifulSoup from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.helpers.variable import tryInt @@ -8,34 +7,33 @@ import traceback log = CPLog(__name__) - class BiTHDTV(TorrentProvider): urls = { 'test' : 'http://www.bit-hdtv.com/', 'login' : 'http://www.bit-hdtv.com/takelogin.php', + 'login_check': 'http://www.bit-hdtv.com/messages.php', 'detail' : 'http://www.bit-hdtv.com/details.php?id=%s', - 'search' : 'http://www.bit-hdtv.com/torrents.php?search=%s&cat=%s&sub=%s', + 'search' : 'http://www.bit-hdtv.com/torrents.php?', } # Searches for movies only - BiT-HDTV's subcategory and resolution search filters appear to be broken cat_id_movies = 7 - cat_ids = [ - ([16], ['720p', '1080p', 'brrip']), - ([17], ['cam', 'r5', 'scr', 'dvdrip', 'dvdr']), - ([19], ['ts', 'tc']), - ] http_time_between_calls = 1 #seconds - cat_backup_id = None def _searchOnTitle(self, title, movie, quality, results): - url = self.urls['search'] % (tryUrlencode('%s %s' % (title.replace(':', ''), movie['library']['year'])), self.cat_id_movies, self.getCatId(quality['identifier'])[0]) + arguments = tryUrlencode({ + 'search': '%s %s' % (title.replace(':', ''), movie['library']['year']), + 'cat': self.cat_id_movies + }) + + url = "%s&%s" % (self.urls['search'], arguments) + data = self.getHTMLData(url, opener = self.login_opener) if data: - # Remove BiT-HDTV's output garbage so outdated BS4 versions successfully parse the HTML split_data = data.partition('-->') if '## SELECT COUNT(' in split_data[0]: @@ -44,17 +42,16 @@ class BiTHDTV(TorrentProvider): html = BeautifulSoup(data) try: - result_table = html.find('table', attrs = {'width' : '750', 'class' : ''}) - if not result_table: + result_table = html.find('table', attrs = {'width' : '750', 'class' : ''}) + if result_table is None: return - entries = result_table.find_all('tr') - + entries = result_table.find_all('tr') for result in entries[1:]: + cells = result.find_all('td') link = cells[2].find('a') torrent_id = link['href'].replace('/details.php?id=', '') - torrent_age = datetime.now() - datetime.strptime(cells[5].get_text(), '%Y-%m-%d %H:%M:%S') results.append({ 'id': torrent_id, @@ -62,20 +59,30 @@ class BiTHDTV(TorrentProvider): 'url': cells[0].find('a')['href'], 'detail_url': self.urls['detail'] % torrent_id, 'size': self.parseSize(cells[6].get_text()), - 'age': torrent_age.days, 'seeders': tryInt(cells[8].string), 'leechers': tryInt(cells[9].string), + 'get_more_info': self.getMoreInfo, }) - except: - log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) + except: + log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) def getLoginParams(self): return tryUrlencode({ 'username': self.conf('username'), 'password': self.conf('password'), - 'login': 'submit', }) + def getMoreInfo(self, item): + full_description = self.getCache('bithdtv.%s' % item['id'], item['detail_url'], cache_timeout = 25920000) + html = BeautifulSoup(full_description) + nfo_pre = html.find('table', attrs = {'class':'detail'}) + description = toUnicode(nfo_pre.text) if nfo_pre else '' + + item['description'] = description + return item + def loginSuccess(self, output): return 'logout.php' in output.lower() + + loginCheckSuccess = loginSuccess