From 923a58b2ab19350979a84c0188f7692bfef13bb7 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 11 Jul 2014 17:52:44 +0800 Subject: [PATCH] Add animezb provider --- gui/slick/images/providers/animezb.png | Bin 0 -> 5186 bytes sickbeard/__init__.py | 2 +- sickbeard/providers/__init__.py | 3 +- sickbeard/providers/animezb.py | 153 +++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 gui/slick/images/providers/animezb.png create mode 100644 sickbeard/providers/animezb.py diff --git a/gui/slick/images/providers/animezb.png b/gui/slick/images/providers/animezb.png new file mode 100644 index 0000000000000000000000000000000000000000..bf2d900c15e0307361eb78194be370f9eff54193 GIT binary patch literal 5186 zcmd5=`8yQs_nwlxO(9vc)oaPVWC<}8gJcgW`@V#+8-t-p8f%n2CL=o|WSy}kOAOPH zWiUnyBWsMMF_^FS`&WE^c+PWO=ZE{c?{huRx$bii7G{R5Kz<+q0AMw`2YzsRr~Y>? zpFfQ!7DaFXfa`)0_^x&2+jY_f2kX6s^MA+yR4wX9yi0>*+tahC%C`86L$?w%uS<&q zlOI7mePC-j`HrI|qqSgW-Z%Qp+`--T1tlVyXxV3y@75cs!nI%20=pbFDM4Pau9zc9 zJ#7kEorE-0q^b<=tOCA zxJ^A80N!Q;SlltGulxse9$?`h$p=_u1)c{)Cd8isEWC38JXQOjPnF)-1$bmf;rZL^L{4pQ5}TTD?hTVApS1HpM2iX}p3jIN$BXep+YKKJH}UU^acU(&nN` z#~wEC6|RwQ6j*D}+|>+GSBl0}%e;w{;f@IHsP95K9FMgw0Qr@Y;R}66-rhQqy1OG1 z4Ml-X8LtI+cyQF#XK=IOKjxnl97U=%ZA?_xf1X?^zgK^Ka|Jdgio|H`$*dYqLOI%5 zFxeRXklY&oOADbYs_pvkb6tPWPa3Qcdj2Ej5t(@$ONW3#tgI3IN3ZEIMiSffVzqX> z4gXIcA!>>Vls3xO_Tt`8i9YtQ)aSxnSRim&+-Ww8wOErjqPDFzrpzY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zU$W zL>54cAwg#?M<)wdRC7-!oaFjjF~@sTAaJzdhST4l)?R6!A9_eD!H)$4paE6^LLy{= zg#<6we-EEUBqf!&Jo59eT_9cVttEUjjI1c**dyL%WR5}=HU+Ev&ml!LD$MNEf)7%7 zwd^sR2M!CE6serws&iabkKRMV&3+d~y^@@~z7fgK60NZCWJ||$L1G3z+Po9~o1;Gm z%)DkE18-$TD~Q#cQ{ejo4vtzAS0Gk@t>Lr1nX&SeQL>+DOQd}15VbAUb2Iq=4qNK3ly`^>;ly)Bhw-(#=nJsoN&vM%%2%jib@Go6F$khrAXd#J-b?xk?S zVk?QYb2530eJPN0!Rm15*Nk?#S<9*!IK&C!15SBgG>+V{Cw4BxN`d(qLR(Wux_ zc%iH=kV1_}TQ?&)F2G4qFK3Qb7@JE2;pE34N_6Z5 zGa}8q<+7*K=V`i!zoI!5glHtp38cUH#D8KyE$38a1-jr-h{X0I@Km6T{ZYXqs@Bx zSKwPxQGQjeSJgmp8v6{T7wHE?BLY8oOo447HQf-?Z$3^|q*t=Lm2DGV%%V3>-B3tS z!)6v*Jmr21M^U)O0iH^lp-2@}5(sMU5si4ld|ms4Q29*qG7%HQ9m(zVP(`aU5|a)C zQMiP)vKOKtJsO9vxE5iQPM7mrO^zPXxjuIuFtScEPc=)Zn=S*-K&eXT+H~v zY0jo)gRc#dnDUtRXu=mx!^TXy`@uq8TZ$N_BnfISGCE40_NjCZoG68m*^=oYu|(?F z+=-5#l9Y2tZR`eQ6rGRLsi1jL6P8)PnaqYQhHxD54_A8F!QN`dv{ z9HMrNmcbNoE>$gCo%kJf8jx3gSy{o%cr$G9bndZwWvVNnckf41_4I;W?;0gOZ@) +# URL: http://code.google.com/p/sickbeard/ +# +# This file is part of Sick Beard. +# +# Sick Beard 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, +# 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 . + +import urllib +import datetime + +import sickbeard +import generic + +from sickbeard import classes, show_name_helpers, helpers + +from sickbeard import exceptions, logger +from sickbeard.common import * +from sickbeard import tvcache +from lib.dateutil.parser import parse as parseDate + +class Animezb(generic.NZBProvider): + + def __init__(self): + + generic.NZBProvider.__init__(self, "Animezb") + + self.supportsBacklog = False + self.supportsAbsoluteNumbering = True + self.anime_only = True + + self.enabled = False + + self.cache = AnimezbCache(self) + + self.url = 'http://animezb.com/' + + def isEnabled(self): + return self.enabled + + def imageName(self): + return 'animezb.png' + + def _checkAuth(self): + return True + + def _get_season_search_strings(self, ep_obj): + return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)] + + def _get_episode_search_strings(self, ep_obj, add_string=''): + search_string = [] + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = '+'.join([helpers.sanitizeSceneName(show_name).replace('.', '+'), str(ep_obj.scene_absolute_number).zfill(2)]) + search_string.append(ep_string) + return search_string + + def _doSearch(self, search_string, epcount=0, age=0): + if self.show and not self.show.is_anime: + logger.log(u"" + str(self.show.name) + " is not an anime skiping ...") + return [] + + params = { + "cat": "anime", + "q": search_string.encode('utf-8'), + "max": "100" + } + + search_url = self.url + "rss?" + urllib.urlencode(params) + + logger.log(u"Search url: " + search_url, logger.DEBUG) + + data = self.cache.getRSSFeed(search_url) + if not data: + return [] + + if 'entries' in data: + + items = data.entries + results = [] + + for curItem in items: + (title, url) = self._get_title_and_url(curItem) + + if title and url: + results.append(curItem) + else: + logger.log( + u"The data returned from the " + self.name + " is incomplete, this result is unusable", + logger.DEBUG) + + return results + + return [] + + def findPropers(self, date=None): + + results = [] + + for i in [2, 3, 4]: # we will look for a version 2, 3 and 4 + for item in self._doSearch("v" + str(i)): + + (title, url) = self._get_title_and_url(item) + + if item.has_key('published_parsed') and item['published_parsed']: + result_date = item.published_parsed + if result_date: + result_date = datetime.datetime(*result_date[0:6]) + else: + logger.log(u"Unable to figure out the date for entry " + title + ", skipping it") + continue + + if not date or result_date > date: + search_result = classes.Proper(title, url, result_date) + results.append(search_result) + + return results + +class AnimezbCache(tvcache.TVCache): + + def __init__(self, provider): + + tvcache.TVCache.__init__(self, provider) + + # only poll Animezb every 20 minutes max + # we get 100 post each call ! + self.minTime = 20 + + def _getRSSData(self): + + params = {"cat": "anime".encode('utf-8'), + "max": "100".encode('utf-8') + } + + rss_url = self.provider.url + 'rss?' + urllib.urlencode(params) + + logger.log(self.provider.name + u" cache update URL: " + rss_url, logger.DEBUG) + + return self.getRSSFeed(rss_url) + + def _checkItemAuth(self, title, url): + return True + +provider = Animezb()