From 8ad380adea5c66be9c442332919b130229034c91 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Thu, 9 Jun 2016 02:23:49 +0100 Subject: [PATCH] Add Bit-HDTV torrent provider. --- CHANGES.md | 1 + gui/slick/images/providers/bithdtv.png | Bin 0 -> 1245 bytes sickbeard/helpers.py | 4 + sickbeard/providers/__init__.py | 5 +- sickbeard/providers/bithdtv.py | 113 +++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 gui/slick/images/providers/bithdtv.png create mode 100644 sickbeard/providers/bithdtv.py diff --git a/CHANGES.md b/CHANGES.md index eba00b81..82575510 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -78,6 +78,7 @@ * Add provider Anizb * Change TorrentDay to use its 2.x interface * Add button 'Discover' Emby server to notifications +* Add Bit-HDTV torrent provider ### 0.11.11 (2016-04-05 19:20:00 UTC) diff --git a/gui/slick/images/providers/bithdtv.png b/gui/slick/images/providers/bithdtv.png new file mode 100644 index 0000000000000000000000000000000000000000..e2b2969ef636531dccd8abc1230b64311e9d8614 GIT binary patch literal 1245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GXl4m>B|mLR^8||NsAg>1O!(vFhIo zfsgauzFqPCv5(>FZsiXx2A}pN|GsMQp@8B4Yqw83oW3t%_%KEM?-hp6OVxf|koj>y z@YC+#w@WR)ZQ}fX*z(V1z7Ms`?`K$lo6hj-jO*vMdLQ}}KF!hod7AP2dWQcGM1D_X z_*TsLxryQDRfR7TL_Sq8e4oqk^OVfb!^}U9@_*ke`k{^C+eC)%`;|VHF#Ooe@NTKi z_tgxa>KHy&GyFWn@VSlQ$9cK$vlzZFWcaz3;rA7uulBACwhFFj#B-OdA*^J)SO(ArhC96I>W_^Arv?JUE>(^OXX3hK0p1Rxbt46T5fM z%-*Dwof!04%)#(*e4k*_3f. + +import re +import traceback + +from . import generic +from sickbeard import logger +from sickbeard.bs4_parser import BS4Parser +from sickbeard.helpers import tryInt +from lib.unidecode import unidecode + + +class BitHDTVProvider(generic.TorrentProvider): + + def __init__(self): + generic.TorrentProvider.__init__(self, 'BitHDTV', cache_update_freq=20) + + self.url_home = ['https://www.bit-hdtv.com/'] + + self.url_vars = {'login_action': 'login.php', 'search': 'torrents.php?search=%s&%s', 'get': '%s'} + self.url_tmpl = {'config_provider_home_uri': '%(home)s', 'login_action': '%(home)s%(vars)s', + 'search': '%(home)s%(vars)s', 'get': '%(home)s%(vars)s'} + + self.categories = {'Season': [12], 'Episode': [4, 5, 10], 'Anime': [1]} + self.categories['Cache'] = self.categories['Season'] + self.categories['Episode'] + + self.username, self.password, self.freeleech, self.minseed, self.minleech = 5 * [None] + + def _authorised(self, **kwargs): + + return super(BitHDTVProvider, self)._authorised( + logged_in=(lambda x=None: self.has_all_cookies(['h_sl', 'h_sp', 'h_su']))) and 'search' in self.urls + + @staticmethod + def _has_signature(data=None): + return generic.TorrentProvider._has_signature(data) or (data and re.search(r'(?sim) len(torrent_rows): + raise generic.HaltParseException + + for tr in torrent_rows[1:]: + try: + seeders, leechers, size = [tryInt(n, n) for n in [ + tr.find_all('td')[x].get_text().strip() for x in (-3, -2, -5)]] + if self.freeleech and not tr.attrs.get('bgcolor').endswith('FF99') or \ + self._peers_fail(mode, seeders, leechers): + continue + + info = tr.find('a', href=rc['info']) + title = (info.attrs.get('title') or info.contents[0].get_text()).strip() + download_url = self.urls['get'] % str(tr.find('a', href=rc['get'])['href']).lstrip('/') + except (AttributeError, TypeError, ValueError): + continue + + if title and download_url: + items[mode].append((title, download_url, seeders, self._bytesizer(size))) + + except generic.HaltParseException: + pass + except Exception: + logger.log(u'Failed to parse. Traceback: %s' % traceback.format_exc(), logger.ERROR) + + self._log_search(mode, len(items[mode]) - cnt, search_url) + + self._sort_seeders(mode, items) + + results = list(set(results + items[mode])) + + return results + + +provider = BitHDTVProvider()