2014-03-10 01:18:05 -04:00
|
|
|
# Author: Harm van Tilborg <harm@zeroxcool.net>
|
|
|
|
# URL: https://github.com/hvt/Sick-Beard/tree/dtt
|
|
|
|
#
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import urllib
|
|
|
|
import sickbeard
|
|
|
|
import generic
|
|
|
|
|
|
|
|
from sickbeard.common import Quality
|
|
|
|
from sickbeard import logger
|
|
|
|
from sickbeard import tvcache
|
2014-04-25 21:49:38 -04:00
|
|
|
from sickbeard.helpers import sanitizeSceneName
|
2014-03-10 01:18:05 -04:00
|
|
|
from sickbeard import show_name_helpers
|
|
|
|
from sickbeard.exceptions import ex
|
|
|
|
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
class DTTProvider(generic.TorrentProvider):
|
2014-03-10 01:18:05 -04:00
|
|
|
def __init__(self):
|
|
|
|
generic.TorrentProvider.__init__(self, "DailyTvTorrents")
|
|
|
|
self.supportsBacklog = True
|
|
|
|
self.cache = DTTCache(self)
|
|
|
|
self.url = 'http://www.dailytvtorrents.org/'
|
|
|
|
|
|
|
|
def isEnabled(self):
|
|
|
|
return sickbeard.DTT
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def imageName(self):
|
|
|
|
return 'dailytvtorrents.gif'
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def getQuality(self, item):
|
2014-04-25 21:49:38 -04:00
|
|
|
url = item.enclosures[0].href
|
2014-03-10 01:18:05 -04:00
|
|
|
quality = Quality.sceneQuality(url)
|
|
|
|
return quality
|
|
|
|
|
2014-04-27 06:31:54 -04:00
|
|
|
def getSearchResults(self, show, season, ep_objs, seasonSearch=False, manualSearch=False):
|
|
|
|
return generic.TorrentProvider.getSearchResults(self, show, season, ep_objs, seasonSearch, manualSearch)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def _dtt_show_id(self, show_name):
|
2014-03-25 01:57:24 -04:00
|
|
|
return sanitizeSceneName(show_name).replace('.', '-').lower()
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-04-30 09:49:50 -04:00
|
|
|
def _get_season_search_strings(self, ep_obj):
|
2014-03-10 01:18:05 -04:00
|
|
|
search_string = []
|
|
|
|
|
2014-04-29 09:14:19 -04:00
|
|
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
2014-03-25 01:57:24 -04:00
|
|
|
show_string = sanitizeSceneName(show_name).replace('.', '-').lower()
|
2014-03-10 01:18:05 -04:00
|
|
|
search_string.append(show_string)
|
|
|
|
|
|
|
|
return search_string
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-04-30 09:49:50 -04:00
|
|
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
|
|
|
return self._get_season_search_strings(ep_obj)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-04-05 07:34:49 -04:00
|
|
|
def _doSearch(self, search_params, show=None, age=None):
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-04-29 09:14:19 -04:00
|
|
|
# show_id = self._dtt_show_id(self.show.name)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
|
|
|
params = {"items": "all"}
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if sickbeard.DTT_NORAR:
|
2014-03-25 01:57:24 -04:00
|
|
|
params.update({"norar": "yes"})
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if sickbeard.DTT_SINGLE:
|
2014-03-25 01:57:24 -04:00
|
|
|
params.update({"single": "yes"})
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
searchURL = self.url + "rss/show/" + search_params + "?" + urllib.urlencode(params)
|
|
|
|
|
|
|
|
logger.log(u"Search string: " + searchURL, logger.DEBUG)
|
|
|
|
|
2014-04-25 21:39:43 -04:00
|
|
|
data = self.getRSSFeed(searchURL)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if not data:
|
|
|
|
return []
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
try:
|
2014-04-25 21:39:43 -04:00
|
|
|
items = data.entries
|
2014-03-10 01:18:05 -04:00
|
|
|
except Exception, e:
|
2014-03-25 01:57:24 -04:00
|
|
|
logger.log(u"Error trying to load DTT RSS feed: " + ex(e), logger.ERROR)
|
|
|
|
logger.log(u"RSS data: " + data, logger.DEBUG)
|
2014-03-10 01:18:05 -04:00
|
|
|
return []
|
|
|
|
|
|
|
|
results = []
|
|
|
|
|
|
|
|
for curItem in items:
|
|
|
|
(title, url) = self._get_title_and_url(curItem)
|
|
|
|
results.append(curItem)
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
def _get_title_and_url(self, item):
|
2014-04-25 21:39:43 -04:00
|
|
|
title = item.title
|
|
|
|
url = item.enclosures[0].href
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
return (title, url)
|
|
|
|
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
class DTTCache(tvcache.TVCache):
|
2014-03-10 01:18:05 -04:00
|
|
|
def __init__(self, provider):
|
|
|
|
tvcache.TVCache.__init__(self, provider)
|
|
|
|
|
|
|
|
# only poll DTT every 30 minutes max
|
|
|
|
self.minTime = 30
|
|
|
|
|
|
|
|
def _getRSSData(self):
|
2014-03-25 01:57:24 -04:00
|
|
|
|
|
|
|
params = {"items": "all"}
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if sickbeard.DTT_NORAR:
|
2014-03-25 01:57:24 -04:00
|
|
|
params.update({"norar": "yes"})
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if sickbeard.DTT_SINGLE:
|
2014-03-25 01:57:24 -04:00
|
|
|
params.update({"single": "yes"})
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
url = self.provider.url + 'rss/allshows?' + urllib.urlencode(params)
|
2014-03-25 01:57:24 -04:00
|
|
|
logger.log(u"DTT cache update URL: " + url, logger.DEBUG)
|
2014-04-28 06:57:30 -04:00
|
|
|
return self.provider.getRSSFeed(url)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
def _parseItem(self, item):
|
|
|
|
title, url = self.provider._get_title_and_url(item)
|
2014-03-25 01:57:24 -04:00
|
|
|
logger.log(u"Adding item from RSS to cache: " + title, logger.DEBUG)
|
2014-03-10 01:18:05 -04:00
|
|
|
return self._addCacheEntry(title, url)
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
provider = DTTProvider()
|