diff --git a/sickbeard/providers/btdigg.py b/sickbeard/providers/btdigg.py index 798b3614ffb512cb8abae73ea379e13a75cf6192..c463f97755b5c1baea76b15cd597c9524ca0a773 100644 --- a/sickbeard/providers/btdigg.py +++ b/sickbeard/providers/btdigg.py @@ -1,25 +1,26 @@ +# coding=utf-8 # Author: Jodi Jones <venom@gen-x.co.nz> # URL: http://code.google.com/p/sickbeard/ -# -# Ported to sickrage by: matigonkas +# Rewrite: Gonçalo <matigonkas@outlook.com> +# URL: https://github.com/SickRage/SickRage # # This file is part of SickRage. # -# Sick Beard is free software: you can redistribute it and/or modify +# SickRage is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# Sick Beard is distributed in the hope that it will be useful, +# SickRage is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. +# along with SickRage. If not, see <http://www.gnu.org/licenses/>. from sickbeard.providers import generic - +from urllib import urlencode from sickbeard import logger from sickbeard import tvcache @@ -32,16 +33,21 @@ class BTDIGGProvider(generic.TorrentProvider): self.public = True self.ratio = 0 self.urls = {'url': u'https://btdigg.org/', - 'api': u'https://api.btdigg.org/'} + 'api': u'https://api.btdigg.org/api/private-341ada3245790954/s02'} self.url = self.urls['url'] + # Unsupported + # self.minseed = 1 + # self.minleech = 0 + self.cache = BTDiggCache(self) def _doSearch(self, search_strings, search_mode='eponly', epcount=0, age=0, epObj=None): results = [] items = {'Season': [], 'Episode': [], 'RSS': []} + search_params = {'p': 1} for mode in search_strings.keys(): logger.log(u"Search Mode: %s" % mode, logger.DEBUG) @@ -50,7 +56,10 @@ class BTDIGGProvider(generic.TorrentProvider): if mode is not 'RSS': logger.log(u"Search string: %s" % search_string, logger.DEBUG) - searchURL = self.urls['api'] + "api/private-341ada3245790954/s02?q=" + search_string + "&p=0&order=1" + search_params['q'] = search_string.encode('utf-8') + search_params['order'] = '1' if mode is not 'RSS' else '2' + + searchURL = self.urls['api'] + '?' + urlencode(search_params) logger.log(u"Search URL: %s" % searchURL, logger.DEBUG) jdata = self.getURL(searchURL, json=True) @@ -70,7 +79,7 @@ class BTDIGGProvider(generic.TorrentProvider): if not all([title, download_url]): continue - # Filter unseeded torrent + # Filter unseeded torrent (Unsupported) # if seeders < self.minseed or leechers < self.minleech: # if mode is not 'RSS': # logger.log(u"Discarding torrent because it doesn't meet the minimum seeders or leechers: {0} (S:{1} L:{2})".format(title, seeders, leechers), logger.DEBUG) @@ -82,8 +91,8 @@ class BTDIGGProvider(generic.TorrentProvider): items[mode].append(item) - # For each search mode sort all the items by seeders if available - items[mode].sort(key=lambda tup: tup[3], reverse=True) + # For each search mode sort all the items by seeders if available (Unsupported) + # items[mode].sort(key=lambda tup: tup[3], reverse=True) results += items[mode] @@ -97,13 +106,13 @@ class BTDiggCache(tvcache.TVCache): tvcache.TVCache.__init__(self, provider_obj) - # Cache results for a hour ,since BTDigg takes some time to crawl - self.minTime = 60 + # Cache results for a 30min ,since BTDigg takes some time to crawl + self.minTime = 30 def _getRSSData(self): - # Use x264 for RSS search since most results will use that codec and since the site doesnt have latest results search - search_params = {'RSS': ['x264']} + # Use this hacky way for RSS search since most results will use this codecs + search_params = {'RSS': ['x264', 'x264.HDTV', '720.HDTV.x264']} return {'entries': self.provider._doSearch(search_params)} provider = BTDIGGProvider()