From afbe99da65ccc49689b387f1efe992933ef4e4db Mon Sep 17 00:00:00 2001 From: vergessen Date: Thu, 19 Mar 2015 11:43:36 -0500 Subject: [PATCH 1/2] add animenzb provider --- gui/slick/images/providers/animenzb.gif | Bin 0 -> 5430 bytes sickbeard/__init__.py | 2 +- sickbeard/providers/__init__.py | 1 + sickbeard/providers/animenzb.py | 149 ++++++++++++++++++++++++ 4 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 gui/slick/images/providers/animenzb.gif create mode 100644 sickbeard/providers/animenzb.py diff --git a/gui/slick/images/providers/animenzb.gif b/gui/slick/images/providers/animenzb.gif new file mode 100644 index 0000000000000000000000000000000000000000..7a8bfeb9b27dc6c93d1997c594f1c8db94030936 GIT binary patch literal 5430 zcmeGgX;73$wn5{83Ihy>V312h0p-3G5FEMhfN~Bn+}D7^C^sUviUNvU0R%-CY|8re>q~Fm zylEg_d-LYa^zrd=DQpiPKAeB|?p-~RNTl)0FTc!09HcpP=#XzqOG{LLe?RBvpMO>m z(|&AE_g-Kwr^95$r+10>wl%Z5mdK55<3>id&z-3-rZrO;v}dV~EmGBd&JB;))!yD7 zt}%nntWYq7Wh{L#Ra^K1=RTG<;$OXb)g)-46Ku>b=*02%?b{RW6!amL6Z%wr7JIbJ zA`13+=0S&J7PQ*)VTW5L80as)mtyP-)gI|kY99mJmc~Hfr?#WFZ{ODc*fU(Zbjc#h z!~@EUORI;6hvoFtwTB8#LO~dr{D5QYbg9lI4fM2hhBzx+2AoW6zOz|q^2*ZO;!2WL z0K~<`HB?nq36|R}`+B2OETBC;mjBtaXB`qOe4(neyd;yKQSCj?3J!P`f*?HceqUdo zN3gmb6K?D}B5C8I!lDg{+OA-#v1rJ`%_ZE;^nyNe5ElL^44WniT5tdFDNduihy>Aq19aSzmwpQ;rTsn2;fFsdhDY8033K{)qBp z3v}~7USSvkF`tDU#@Jh^ru9s)A{_4DzppbmIB4XoWBy~brT24Olid45;GUiye|NSC z9Pr%$Nx@M+J%9dO(cRYhQl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vG4#E{TE`dY1^r2SpAI9Ip6yp6jiyeHQ_9J(6YH$)k^|8)1x zUA=*G=N!_O_>HbMa31O0{(0s5=r^V1?+#tMiV1ZO7(Bk`aK_HEZTXd4VQ*(!M^qk{ zKadlUaK5kmP{jM_^P~9PJ5o2^X=`kWugomio6bvW4N|jZxV~%p3q0d)WF(|C9%=3> zeINayj&9z?ufFCSJ$S@F*+24HoW9$yLYolg=)Qx={FPysGwjxk-ne$%b~3$W%pr_* zA=R@g#-lh#;G7tiq{rITdY!|?lV?t?tln3Xt`}+eH>4Bp%&9DHEzPrzUv?2|*@#Us zZS7xnMmVnLoLf?6eWSjoF&_7!_1$dQ+W8}7E4`n#DljsU?AQJ0PjKkn%2*dWU6_}; z;8A9oV6*m4;|IPSAqS_%%8e~ATQz`pusGj@?T+n?&g3;ODYw3X_)BVR2T1`7%!}+V z^GXw%*!=m=r3G>fU3)CcR~xBqt4o%Af9W`}Crmj*>si6!k^{trym1P8amn z8Q-aItdGaKz))!MtznVnw`#?DkEd3!$FN4cedqSX|EcJEkp{(K&R_bAt!&-=k +# 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 animenzb(generic.NZBProvider): + + def __init__(self): + + generic.NZBProvider.__init__(self, "animenzb") + + self.supportsBacklog = False + self.supportsAbsoluteNumbering = True + self.anime_only = True + + self.enabled = False + + self.cache = animenzbCache(self) + + self.url = 'http://animenzb.com/' + + def isEnabled(self): + return self.enabled + + def imageName(self): + return 'animenzb.gif' + + 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=''): + return [x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)] + + def _doSearch(self, search_string, search_mode='eponly', 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 " + self.name + " is incomplete, this result is unusable", + logger.DEBUG) + + return results + + return [] + + def findPropers(self, date=None): + + results = [] + + for item in self._doSearch("v2|v3|v4|v5"): + + (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, self.show) + results.append(search_result) + + return results + + +class animenzbCache(tvcache.TVCache): + + def __init__(self, provider): + + tvcache.TVCache.__init__(self, provider) + + + 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) + + data = self.getRSSFeed(rss_url) + + if data and 'entries' in data: + return data.entries + else: + return [] + + +provider = animenzb() From 9384447b85ef838aa1d6e4bc29cf819ae673561a Mon Sep 17 00:00:00 2001 From: vergessen Date: Wed, 25 Mar 2015 08:11:07 -0500 Subject: [PATCH 2/2] code cleanup --- sickbeard/providers/animenzb.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sickbeard/providers/animenzb.py b/sickbeard/providers/animenzb.py index fee21a6e..0236b79b 100644 --- a/sickbeard/providers/animenzb.py +++ b/sickbeard/providers/animenzb.py @@ -33,7 +33,7 @@ class animenzb(generic.NZBProvider): def __init__(self): - generic.NZBProvider.__init__(self, "animenzb") + generic.NZBProvider.__init__(self, 'animenzb') self.supportsBacklog = False self.supportsAbsoluteNumbering = True @@ -59,18 +59,18 @@ class animenzb(generic.NZBProvider): def _doSearch(self, search_string, search_mode='eponly', 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 ...") + logger.log(u'%s is not an anime skipping ...' % self.show.name) return [] params = { - "cat": "anime", - "q": search_string.encode('utf-8'), - "max": "100" + 'cat': 'anime', + 'q': search_string.encode('utf-8'), + 'max': '100' } - search_url = self.url + "rss?" + urllib.urlencode(params) + search_url = self.url + 'rss?' + urllib.urlencode(params) - logger.log(u"Search url: " + search_url, logger.DEBUG) + logger.log(u'Search url: %s' % search_url, logger.DEBUG) data = self.cache.getRSSFeed(search_url) if not data: @@ -88,7 +88,7 @@ class animenzb(generic.NZBProvider): results.append(curItem) else: logger.log( - u"The data returned from " + self.name + " is incomplete, this result is unusable", + u'The data returned from %s is incomplete, this result is unusable' % self.name, logger.DEBUG) return results @@ -99,7 +99,7 @@ class animenzb(generic.NZBProvider): results = [] - for item in self._doSearch("v2|v3|v4|v5"): + for item in self._doSearch('v2|v3|v4|v5'): (title, url) = self._get_title_and_url(item) @@ -108,7 +108,7 @@ class animenzb(generic.NZBProvider): 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") + logger.log(u'Unable to figure out the date for entry %s, skipping it' % title) continue if not date or result_date > date: @@ -130,13 +130,13 @@ class animenzbCache(tvcache.TVCache): def _getRSSData(self): params = { - "cat": "anime".encode('utf-8'), - "max": "100".encode('utf-8') + '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) + logger.log(u'%s cache update URL: %s' % (self.provider.name, rss_url), logger.DEBUG) data = self.getRSSFeed(rss_url)