2014-03-10 01:18:05 -04:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
try:
|
|
|
|
import xml.etree.cElementTree as etree
|
|
|
|
except ImportError:
|
|
|
|
import elementtree.ElementTree as etree
|
|
|
|
|
|
|
|
import sickbeard
|
|
|
|
import generic
|
|
|
|
|
|
|
|
from sickbeard.exceptions import ex, AuthException
|
|
|
|
from sickbeard import helpers
|
|
|
|
from sickbeard import logger
|
|
|
|
from sickbeard import tvcache
|
|
|
|
|
|
|
|
|
|
|
|
class TvTorrentsProvider(generic.TorrentProvider):
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
generic.TorrentProvider.__init__(self, "TvTorrents")
|
|
|
|
|
|
|
|
self.supportsBacklog = False
|
|
|
|
|
|
|
|
self.cache = TvTorrentsCache(self)
|
|
|
|
|
|
|
|
self.url = 'http://www.tvtorrents.com/'
|
|
|
|
|
|
|
|
def isEnabled(self):
|
|
|
|
return sickbeard.TVTORRENTS
|
|
|
|
|
|
|
|
def imageName(self):
|
|
|
|
return 'tvtorrents.png'
|
|
|
|
|
|
|
|
def _checkAuth(self):
|
|
|
|
|
|
|
|
if not sickbeard.TVTORRENTS_DIGEST or not sickbeard.TVTORRENTS_HASH:
|
|
|
|
raise AuthException("Your authentication credentials for " + self.name + " are missing, check your config.")
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2014-04-25 21:49:38 -04:00
|
|
|
def _checkAuthFromData(self, data):
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-04-27 06:31:54 -04:00
|
|
|
if data is None or data.feed is None:
|
2014-03-10 01:18:05 -04:00
|
|
|
return self._checkAuth()
|
|
|
|
|
2014-04-25 23:42:35 -04:00
|
|
|
description_text = data.feed.title
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if "User can't be found" in description_text or "Invalid Hash" in description_text:
|
2014-03-25 01:57:24 -04:00
|
|
|
logger.log(u"Incorrect authentication credentials for " + self.name + " : " + str(description_text),
|
|
|
|
logger.DEBUG)
|
|
|
|
raise AuthException(
|
|
|
|
u"Your authentication credentials for " + self.name + " are incorrect, check your config")
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class TvTorrentsCache(tvcache.TVCache):
|
|
|
|
def __init__(self, provider):
|
|
|
|
tvcache.TVCache.__init__(self, provider)
|
|
|
|
|
|
|
|
# only poll TvTorrents every 15 minutes max
|
|
|
|
self.minTime = 15
|
|
|
|
|
|
|
|
def _getRSSData(self):
|
|
|
|
# These will be ignored on the serverside.
|
|
|
|
ignore_regex = "all.month|month.of|season[\s\d]*complete"
|
|
|
|
|
|
|
|
rss_url = self.provider.url + 'RssServlet?digest=' + sickbeard.TVTORRENTS_DIGEST + '&hash=' + sickbeard.TVTORRENTS_HASH + '&fname=true&exclude=(' + ignore_regex + ')'
|
|
|
|
logger.log(self.provider.name + u" cache update URL: " + rss_url, logger.DEBUG)
|
|
|
|
|
2014-04-28 06:57:30 -04:00
|
|
|
return self.provider.getRSSFeed(rss_url)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-04-25 21:49:38 -04:00
|
|
|
def _checkAuth(self, data):
|
|
|
|
return self.provider._checkAuthFromData(data)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
provider = TvTorrentsProvider()
|