From d712bdd878e36efadd04cadc5e95ed22e673f7d3 Mon Sep 17 00:00:00 2001 From: supergonkas <duramato@users.noreply.github.com> Date: Thu, 24 Dec 2015 01:30:20 +0000 Subject: [PATCH] Add LimeTorrents --- gui/slick/images/providers/limetorrents.png | Bin 0 -> 536 bytes sickbeard/providers/__init__.py | 4 +- sickbeard/providers/limetorrents.py | 143 ++++++++++++++++++++ 3 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 gui/slick/images/providers/limetorrents.png create mode 100644 sickbeard/providers/limetorrents.py diff --git a/gui/slick/images/providers/limetorrents.png b/gui/slick/images/providers/limetorrents.png new file mode 100644 index 0000000000000000000000000000000000000000..88fd0c55395545e7ca963d0439980c56e6f9861b GIT binary patch literal 536 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4kiW$h6xih%orFL?|Zs9hG?8`ope4+I8o&2 z`JJDAmreGQnk|*-tk~t@%IaG1{1*F%i!~j;*meoH#B}V)ygG?1>3>3Urt{@xy`E{$ zcHb`*)V<njySn({9s7d%n%_Sq^`=+qE<ZQ%(|;Y#Q2VV7mV$A1|84jzK1}Kpn6luH zU5lPj#)i*-8yLN~95yo;NO&*`>TtYBOMiUJ$47`G&C5!`_whDI^{09Pv!*hfJi&8! z@jh$0d0V8e$AmC=s&Kn7RVb;eZk7^YUS-ymQe<HvEuPHYy}jB#Z~Lv*eiNCgw}h7| zN&1{E+Pc}}S*K*@>)CgEk4WX&W!KpLs90(he*RnCGv<jFrP{6k<qZ55z214>eE;mT zCfCdU6xhVX?b2@0xpq6>YJFAn6-&)88+h28|6G2VlKf^nvq{;_>Fd_!ufLyjkNx2u zv9DVy7yo?m^w#TWZ|(AF@<wh#=VykVnUr*?Zu{4Lx9?Z&`DEg`DvrDCTliV0qf47F z9&FFocl%jUw{2qRbDakzC70yO#Ix42zg5p%`pi_lb?)C#hO~pOq7zq`-?;fYU#_1o zG2%qj+tuG+T|F99%<E;ulA8Yi=THB{0=+^Z_F#r36}q(=9zrI@4C0Yp3>g}=8XW%` sJCvLb@Te@`@~`!h{ZrSp<-b_xl)bttI${1|1_lNOPgg&ebxsLQ0Ohmp;{X5v literal 0 HcmV?d00001 diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py index bd0f335b8..55c199366 100644 --- a/sickbeard/providers/__init__.py +++ b/sickbeard/providers/__init__.py @@ -26,7 +26,7 @@ from sickbeard import logger from sickbeard.providers import btn, newznab, rsstorrent, womble, thepiratebay, torrentleech, kat, iptorrents, torrentz, \ omgwtfnzbs, scc, hdtorrents, torrentday, hdbits, hounddawgs, speedcd, nyaatorrents, animenzb, bluetigers, cpasbien, fnt, xthor, torrentbytes, \ freshontv, titansoftv, morethantv, bitsoup, t411, tokyotoshokan, shazbat, rarbg, alpharatio, tntvillage, binsearch, torrentproject, extratorrent, \ - scenetime, btdigg, transmitthenet, tvchaosuk, bitcannon, pretome, gftracker, hdspace, newpct, elitetorrent, bitsnoop, danishbits, hd4free + scenetime, btdigg, transmitthenet, tvchaosuk, bitcannon, pretome, gftracker, hdspace, newpct, elitetorrent, bitsnoop, danishbits, hd4free, limetorrents __all__ = [ 'womble', 'btn', 'thepiratebay', 'kat', 'torrentleech', 'scc', 'hdtorrents', @@ -36,7 +36,7 @@ __all__ = [ 'shazbat', 'rarbg', 'tntvillage', 'binsearch', 'bluetigers', 'cpasbien', 'fnt', 'xthor', 'scenetime', 'btdigg', 'transmitthenet', 'tvchaosuk', 'torrentproject', 'extratorrent', 'bitcannon', 'torrentz', 'pretome', 'gftracker', - 'hdspace', 'newpct', 'elitetorrent', 'bitsnoop', 'danishbits', 'hd4free' + 'hdspace', 'newpct', 'elitetorrent', 'bitsnoop', 'danishbits', 'hd4free', 'limetorrents' ] diff --git a/sickbeard/providers/limetorrents.py b/sickbeard/providers/limetorrents.py new file mode 100644 index 000000000..88475d64f --- /dev/null +++ b/sickbeard/providers/limetorrents.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# Author: Gonçalo (aka duramato/supergonkas) <matigonkas@outlook.com> +# URL: https://github.com/SickRage/sickrage +# This file is part of SickRage. +# +# 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. +# +# 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 SickRage. If not, see <http://www.gnu.org/licenses/>. + +import traceback +from bs4 import BeautifulSoup +import sickbeard +from sickbeard import logger +from sickbeard import tvcache +from sickbeard.common import USER_AGENT +from sickrage.helper.common import try_int +from sickrage.providers.torrent.TorrentProvider import TorrentProvider + + +class LimeTorrentsProvider(TorrentProvider): # pylint: disable=too-many-instance-attributes + def __init__(self): + TorrentProvider.__init__(self, "LimeTorrents") + + self.urls = { + 'index': 'https://www.limetorrents.cc/', + 'search': 'https://www.limetorrents.cc/searchrss/20/', + 'rss': 'https://www.limetorrents.cc/rss/20/' + } + + self.url = self.urls['index'] + + self.public = True + self.ratio = None + self.minseed = None + self.minleech = None + self.headers.update({'User-Agent': USER_AGENT}) + self.proper_strings = ['PROPER', 'REPACK'] + + self.cache = LimeTorrentsCache(self) + + def search(self, search_strings, age=0, ep_obj=None): # pylint: disable=too-many-branches,too-many-locals + + results = [] + items = {'Season': [], 'Episode': [], 'RSS': []} + + for mode in search_strings.keys(): + logger.log(u"Search Mode: %s" % mode, logger.DEBUG) + for search_string in search_strings[mode]: + + if mode != 'RSS': + logger.log(u"Search string: %s " % search_string, logger.DEBUG) + + try: + url = (self.urls['rss'], self.urls['search'] + search_string)[mode != 'RSS'] + logger.log(u"URL: %r " % url, logger.DEBUG) + data = self.get_url(url) + if not data: + logger.log(u"No data returned from provider", logger.DEBUG) + continue + + if not data.startswith('<?xml'): + logger.log(u'Expected xml but got something else, is your mirror failing?', logger.INFO) + continue + + data = BeautifulSoup(data, 'html5lib') + + entries = entries = data.findAll('item') + + for item in entries: + try: + title = item.title.text + download_url = item.enclosure['url'] + + if not (title and download_url): + continue + #seeders and leechers are presented diferently when doing a search and when looking for newly added + if mode == 'RSS': + # <![CDATA[ + # Category: <a href="http://www.limetorrents.cc/browse-torrents/TV-shows/">TV shows</a><br /> Seeds: 1<br />Leechers: 0<br />Size: 7.71 GB<br /><br /><a href="http://www.limetorrents.cc/Owen-Hart-of-Gold-Djon91-torrent-7180661.html">More @ limetorrents.cc</a><br /> + # ]]> + description = item.find('description') + smtg = (description.find_all('br')[0].next_sibling).strip() + smtg2 = (description.find_all('br')[1].next_sibling).strip() + seeders = smtg.lstrip('Seeds: ') + leechers = smtg2.lstrip('Leechers: ') + else: + #<description>Seeds: 6982 , Leechers 734</description> + description = item.find('description').text + seeders = description.split("Seeds: ")[-1].split()[0] + leechers = description.split("Leechers ")[-1].split()[0] + size = try_int(item.find('size').text, -1) + + except (AttributeError, TypeError, KeyError, ValueError): + continue + + # Filter unseeded torrent + if seeders < self.minseed or leechers < self.minleech: + if mode != '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) + continue + + item = title, download_url, size, seeders, leechers + if mode != 'RSS': + logger.log(u"Found result: %s " % title, logger.DEBUG) + + items[mode].append(item) + + except (AttributeError, TypeError, KeyError, ValueError): + logger.log(u"Failed parsing provider. Traceback: %r" % traceback.format_exc(), logger.ERROR) + + # For each search mode sort all the items by seeders if available + items[mode].sort(key=lambda tup: tup[3], reverse=True) + + results += items[mode] + + return results + + def seed_ratio(self): + return self.ratio + + +class LimeTorrentsCache(tvcache.TVCache): + def __init__(self, provider_obj): + + tvcache.TVCache.__init__(self, provider_obj) + + self.minTime = 20 + + def _getRSSData(self): + search_strings = {'RSS': ['rss']} + return {'entries': self.provider.search(search_strings)} + + +provider = LimeTorrentsProvider() -- GitLab