2014-03-10 05:18:05 +00:00
|
|
|
# Author: Harm van Tilborg <harm@zeroxcool.net>
|
|
|
|
# URL: https://github.com/hvt/Sick-Beard/tree/dtt
|
|
|
|
#
|
2014-05-23 12:37:22 +00:00
|
|
|
# This file is part of SickRage.
|
2014-03-10 05:18:05 +00:00
|
|
|
#
|
2014-05-23 12:37:22 +00:00
|
|
|
# SickRage is free software: you can redistribute it and/or modify
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-05-23 12:37:22 +00:00
|
|
|
# SickRage is distributed in the hope that it will be useful,
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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
|
2014-05-23 12:37:22 +00:00
|
|
|
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
import urllib
|
|
|
|
import sickbeard
|
|
|
|
import generic
|
|
|
|
|
|
|
|
from sickbeard.common import Quality
|
|
|
|
from sickbeard import logger
|
|
|
|
from sickbeard import tvcache
|
2014-04-26 01:49:38 +00:00
|
|
|
from sickbeard.helpers import sanitizeSceneName
|
2014-03-10 05:18:05 +00:00
|
|
|
from sickbeard import show_name_helpers
|
|
|
|
from sickbeard.exceptions import ex
|
|
|
|
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
class DTTProvider(generic.TorrentProvider):
|
2014-03-10 05:18:05 +00:00
|
|
|
def __init__(self):
|
|
|
|
generic.TorrentProvider.__init__(self, "DailyTvTorrents")
|
|
|
|
self.supportsBacklog = True
|
2014-05-17 05:23:11 +00:00
|
|
|
|
|
|
|
self.enabled = False
|
|
|
|
self.ratio = None
|
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
self.cache = DTTCache(self)
|
2014-05-17 05:23:11 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
self.url = 'http://www.dailytvtorrents.org/'
|
|
|
|
|
|
|
|
def isEnabled(self):
|
2014-05-17 05:23:11 +00:00
|
|
|
return self.enabled
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
def imageName(self):
|
|
|
|
return 'dailytvtorrents.gif'
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-05-26 06:29:22 +00:00
|
|
|
def getQuality(self, item, anime=False):
|
2014-04-26 01:49:38 +00:00
|
|
|
url = item.enclosures[0].href
|
2014-03-10 05:18:05 +00:00
|
|
|
quality = Quality.sceneQuality(url)
|
|
|
|
return quality
|
|
|
|
|
2014-05-17 05:23:11 +00:00
|
|
|
def findSearchResults(self, show, season, episodes, search_mode, manualSearch=False):
|
|
|
|
return generic.TorrentProvider.findSearchResults(self, show, season, episodes, search_mode, manualSearch)
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
def _dtt_show_id(self, show_name):
|
2014-03-25 05:57:24 +00:00
|
|
|
return sanitizeSceneName(show_name).replace('.', '-').lower()
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-04-30 13:49:50 +00:00
|
|
|
def _get_season_search_strings(self, ep_obj):
|
2014-03-10 05:18:05 +00:00
|
|
|
search_string = []
|
|
|
|
|
2014-04-29 13:14:19 +00:00
|
|
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
2014-03-25 05:57:24 +00:00
|
|
|
show_string = sanitizeSceneName(show_name).replace('.', '-').lower()
|
2014-03-10 05:18:05 +00:00
|
|
|
search_string.append(show_string)
|
|
|
|
|
|
|
|
return search_string
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-04-30 13:49:50 +00:00
|
|
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
|
|
|
return self._get_season_search_strings(ep_obj)
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-05-07 07:50:49 +00:00
|
|
|
def _doSearch(self, search_params, epcount=0, age=0):
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-04-29 13:14:19 +00:00
|
|
|
# show_id = self._dtt_show_id(self.show.name)
|
2014-03-25 05:57:24 +00:00
|
|
|
|
|
|
|
params = {"items": "all"}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
if sickbeard.DTT_NORAR:
|
2014-03-25 05:57:24 +00:00
|
|
|
params.update({"norar": "yes"})
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
if sickbeard.DTT_SINGLE:
|
2014-03-25 05:57:24 +00:00
|
|
|
params.update({"single": "yes"})
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
searchURL = self.url + "rss/show/" + search_params + "?" + urllib.urlencode(params)
|
|
|
|
|
|
|
|
logger.log(u"Search string: " + searchURL, logger.DEBUG)
|
|
|
|
|
2014-05-04 12:05:27 +00:00
|
|
|
data = self.cache.getRSSFeed(searchURL)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
if not data:
|
|
|
|
return []
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
try:
|
2014-04-26 01:39:43 +00:00
|
|
|
items = data.entries
|
2014-03-10 05:18:05 +00:00
|
|
|
except Exception, e:
|
2014-03-25 05:57:24 +00: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 05:18:05 +00: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-26 01:39:43 +00:00
|
|
|
title = item.title
|
2014-07-15 02:00:53 +00:00
|
|
|
if title:
|
|
|
|
title = u'' + title
|
|
|
|
title = title.replace(' ', '.')
|
|
|
|
|
2014-04-26 01:39:43 +00:00
|
|
|
url = item.enclosures[0].href
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
return (title, url)
|
|
|
|
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
class DTTCache(tvcache.TVCache):
|
2014-03-10 05:18:05 +00: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 05:57:24 +00:00
|
|
|
|
|
|
|
params = {"items": "all"}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
if sickbeard.DTT_NORAR:
|
2014-03-25 05:57:24 +00:00
|
|
|
params.update({"norar": "yes"})
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
if sickbeard.DTT_SINGLE:
|
2014-03-25 05:57:24 +00:00
|
|
|
params.update({"single": "yes"})
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
url = self.provider.url + 'rss/allshows?' + urllib.urlencode(params)
|
2014-03-25 05:57:24 +00:00
|
|
|
logger.log(u"DTT cache update URL: " + url, logger.DEBUG)
|
2014-05-04 12:05:27 +00:00
|
|
|
return self.getRSSFeed(url)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
def _parseItem(self, item):
|
|
|
|
title, url = self.provider._get_title_and_url(item)
|
2014-05-07 07:50:49 +00:00
|
|
|
logger.log(u"RSS Feed provider: [" + self.provider.name + "] Attempting to add item to cache: " + title, logger.DEBUG)
|
2014-03-10 05:18:05 +00:00
|
|
|
return self._addCacheEntry(title, url)
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
provider = DTTProvider()
|