1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-16 06:15:09 -05:00
SickRage/sickbeard/providers/tvtorrents.py

103 lines
3.1 KiB
Python
Raw Normal View History

# Author: Nic Wolfe <nic@wolfeden.ca>
# URL: http://code.google.com/p/sickbeard/
#
2014-05-23 08:37:22 -04:00
# This file is part of SickRage.
#
2014-05-23 08:37:22 -04:00
# SickRage 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.
#
2014-05-23 08:37:22 -04:00
# SickRage 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
2014-05-23 08:37:22 -04:00
# along with SickRage. 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.enabled = False
self.hash = None
self.digest = None
self.ratio = None
self.options = None
self.cache = TvTorrentsCache(self)
self.url = 'https://www.tvtorrents.com/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'tvtorrents.png'
def _checkAuth(self):
if not self.digest or not self.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):
if not (data['entries'] and data['feed']):
return self._checkAuth()
try:
title = data['feed']['title']
except:
return False
if title and ("User can't be found" in title or "Invalid Hash" in title):
logger.log(u"Incorrect authentication credentials for " + self.name + " : " + str(title),
logger.DEBUG)
raise AuthException(
u"Your authentication credentials for " + self.name + " are incorrect, check your config")
return True
2014-05-08 18:28:28 -04:00
def seedRatio(self):
return self.ratio
2014-05-08 18:28:28 -04:00
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=' + provider.digest + '&hash=' + provider.hash + '&fname=true&exclude=(' + ignore_regex + ')'
logger.log(self.provider.name + u" cache update URL: " + rss_url, logger.DEBUG)
return self.getRSSFeed(rss_url, items=['entries', 'feed'])
def _checkAuth(self, data):
return self.provider._checkAuthFromData(data)
provider = TvTorrentsProvider()