diff --git a/gui/slick/images/providers/binsearch.png b/gui/slick/images/providers/binsearch.png new file mode 100644 index 00000000..890ff858 Binary files /dev/null and b/gui/slick/images/providers/binsearch.png differ diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 1963036c..935f6c20 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -34,7 +34,7 @@ from sickbeard import providers, metadata, config, webserveInit from sickbeard.providers.generic import GenericProvider from providers import ezrss, btn, newznab, womble, thepiratebay, oldpiratebay, torrentleech, kat, iptorrents, \ omgwtfnzbs, scc, hdtorrents, torrentday, hdbits, hounddawgs, nextgen, speedcd, nyaatorrents, fanzub, torrentbytes, animezb, \ - freshontv, bitsoup, t411, tokyotoshokan + freshontv, bitsoup, t411, tokyotoshokan, binsearch from sickbeard.config import CheckSection, check_setting_int, check_setting_str, check_setting_float, ConfigMigrator, \ naming_ep_type from sickbeard import searchBacklog, showUpdater, versionChecker, properFinder, autoPostProcesser, \ @@ -254,6 +254,8 @@ NZBS_HASH = None WOMBLE = False +BINSEARCH = False + OMGWTFNZBS = False OMGWTFNZBS_USERNAME = None OMGWTFNZBS_APIKEY = None @@ -524,7 +526,7 @@ def initialize(consoleLogging=True): showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, TIMEZONE_DISPLAY, \ NAMING_PATTERN, NAMING_MULTI_EP, NAMING_ANIME_MULTI_EP, NAMING_FORCE_FOLDERS, NAMING_ABD_PATTERN, NAMING_CUSTOM_ABD, NAMING_SPORTS_PATTERN, NAMING_CUSTOM_SPORTS, NAMING_ANIME_PATTERN, NAMING_CUSTOM_ANIME, NAMING_STRIP_YEAR, \ RENAME_EPISODES, AIRDATE_EPISODES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \ - WOMBLE, OMGWTFNZBS, OMGWTFNZBS_USERNAME, OMGWTFNZBS_APIKEY, providerList, newznabProviderList, torrentRssProviderList, \ + WOMBLE, BINSEARCH, OMGWTFNZBS, OMGWTFNZBS_USERNAME, OMGWTFNZBS_APIKEY, providerList, newznabProviderList, torrentRssProviderList, \ EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, DAILYSEARCH_FREQUENCY, \ USE_BOXCAR, BOXCAR_USERNAME, BOXCAR_PASSWORD, BOXCAR_NOTIFY_ONDOWNLOAD, BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD, BOXCAR_NOTIFY_ONSNATCH, \ USE_BOXCAR2, BOXCAR2_ACCESSTOKEN, BOXCAR2_NOTIFY_ONDOWNLOAD, BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD, BOXCAR2_NOTIFY_ONSNATCH, \ diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py index a1d5474c..0e256d4d 100755 --- a/sickbeard/providers/__init__.py +++ b/sickbeard/providers/__init__.py @@ -40,6 +40,7 @@ __all__ = ['ezrss', 'bitsoup', 't411', 'tokyotoshokan', + 'binsearch', ] import sickbeard diff --git a/sickbeard/providers/binsearch.py b/sickbeard/providers/binsearch.py new file mode 100644 index 00000000..a0ae8995 --- /dev/null +++ b/sickbeard/providers/binsearch.py @@ -0,0 +1,119 @@ +# Author: moparisthebest +# +# 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 re +import time + +import sickbeard + +import generic + +from sickbeard import logger +from sickbeard import tvcache +from sickbeard.exceptions import AuthException + +class BinSearchProvider(generic.NZBProvider): + def __init__(self): + generic.NZBProvider.__init__(self, "BinSearch") + self.enabled = False + self.cache = BinSearchCache(self) + self.urls = {'base_url': 'https://www.binsearch.info/'} + self.url = self.urls['base_url'] + + def isEnabled(self): + return self.enabled + +class BinSearchCache(tvcache.TVCache): + def __init__(self, provider): + tvcache.TVCache.__init__(self, provider) + # only poll Binsearch every 30 minutes max + self.minTime = 30 + + # compile and save our regular expressions + + # this pulls the title from the URL in the description + self.descTitleStart = re.compile('^.*https?://www\.binsearch\.info/.b=') + self.descTitleEnd = re.compile('&.*$') + + # these clean up the horrible mess of a title if the above fail + self.titleCleaners = [ + re.compile('.?yEnc.?\(\d+/\d+\)$'), + re.compile(' \[\d+/\d+\] '), + ] + + def _get_title_and_url(self, item): + """ + Retrieves the title and URL data from the item XML node + + item: An elementtree.ElementTree element representing the tag of the RSS feed + + Returns: A tuple containing two strings representing title and URL respectively + """ + + title = item.get('description') + if title: + title = u'' + title + if self.descTitleStart.match(title): + title = self.descTitleStart.sub('', title) + title = self.descTitleEnd.sub('', title) + title = title.replace('+', '.') + else: + # just use the entire title, looks hard/impossible to parse + title = item.get('title') + if title: + for titleCleaner in self.titleCleaners: + title = titleCleaner.sub('', title) + + url = item.get('link') + if url: + url = url.replace('&', '&') + + return (title, url) + + def updateCache(self): + # check if we should update + if not self.shouldUpdate(): + return + + # clear cache + self._clearCache() + + # set updated + self.setLastUpdate() + + cl = [] + for group in ['alt.binaries.boneless','alt.binaries.misc','alt.binaries.hdtv','alt.binaries.hdtv.x264','alt.binaries.tv','alt.binaries.tvseries']: + url = self.provider.url + 'rss.php?' + urlArgs = {'max': 1000,'g': group} + + url += urllib.urlencode(urlArgs) + + logger.log(u"BinSearch cache update URL: " + url, logger.DEBUG) + + for item in self.getRSSFeed(url)['entries'] or []: + ci = self._parseItem(item) + if ci is not None: + cl.append(ci) + + if len(cl) > 0: + myDB = self._getDB() + myDB.mass_action(cl) + + def _checkAuth(self, data): + return data if data['feed'] and data['feed']['title'] != 'Invalid Link' else None + +provider = BinSearchProvider()