Skip to content

Commit

Permalink
Add Seeders/leechers to btdigg (#396)
Browse files Browse the repository at this point in the history
* Add Seeders/leechers to btdigg

* Update btdigg.py
  • Loading branch information
duramato authored and fernandog committed Apr 15, 2016
1 parent 5f4bd4e commit 9edb74e
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions sickbeard/providers/btdigg.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

from __future__ import unicode_literals

import validators

from sickbeard import logger, tvcache

from sickrage.helper.common import convert_size
Expand All @@ -29,13 +31,22 @@
class BTDiggProvider(TorrentProvider):

def __init__(self):


# Provider Init
TorrentProvider.__init__(self, "BTDigg")

self.public = True

# Torrent Stats
self.minseed = None
self.minleech = None

# URLs
self.url = "https://btdigg.org"
self.urls = {"api": "https://api.btdigg.org/api/private-341ada3245790954/s02"}

self.custom_url = None

# Proper Strings
self.proper_strings = ["PROPER", "REPACK"]

# Use this hacky way for RSS search since most results will use this codecs
Expand All @@ -58,8 +69,14 @@ def search(self, search_strings, age=0, ep_obj=None): # pylint: disable=too-man
logger.DEBUG)
else:
search_params["order"] = 2

jdata = self.get_url(self.urls["api"], params=search_params, returns="json")
if self.custom_url:
# if not validators.url(self.custom_url):
# logger.log("Invalid custom url set, please check your settings", logger.WARNING)
# return results
search_url = self.custom_url + "api/private-341ada3245790954/s02"
else:
search_url = self.urls["api"]
jdata = self.get_url(search_url, params=search_params, returns="json")
if not jdata:
logger.log("Provider did not return data", logger.DEBUG)
continue
Expand All @@ -80,11 +97,16 @@ def search(self, search_strings, age=0, ep_obj=None): # pylint: disable=too-man
logger.log("Ignoring result for {} because it has no files".format
(title), logger.DEBUG)
continue

# Provider doesn't provide seeders/leechers
seeders = 1
leechers = 0

leechers = torrent.pop("leechers", 0)
seeders = torrent.pop("seeders", 1)

# Filter unseeded torrent
if seeders < min(self.minseed, 1) or leechers < min(self.minleech, 0):
if mode != "RSS":
logger.log("Discarding torrent because it doesn't meet the"
" minimum seeders or leechers: {} (S:{} L:{})".format
(title, seeders, leechers), logger.DEBUG)
continue
torrent_size = torrent.pop("size")
size = convert_size(torrent_size) or -1

Expand Down

0 comments on commit 9edb74e

Please sign in to comment.