2014-04-22 04:02:43 -04:00
|
|
|
# coding=utf-8
|
2014-03-10 01:18:05 -04:00
|
|
|
# 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-03-10 01:18:05 -04:00
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# SickRage is free software: you can redistribute it and/or modify
|
2014-03-10 01:18:05 -04: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 08:37:22 -04:00
|
|
|
# SickRage is distributed in the hope that it will be useful,
|
2014-03-10 01:18:05 -04: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 08:37:22 -04:00
|
|
|
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
from __future__ import with_statement
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
import os
|
|
|
|
import re
|
2014-07-21 20:55:45 -04:00
|
|
|
import itertools
|
2014-03-10 01:18:05 -04:00
|
|
|
import sickbeard
|
2014-07-24 00:44:11 -04:00
|
|
|
import requests
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
from sickbeard import helpers, classes, logger, db
|
2014-07-24 00:44:11 -04:00
|
|
|
from sickbeard.common import MULTI_EP_RESULT, SEASON_RESULT
|
2014-03-10 01:18:05 -04:00
|
|
|
from sickbeard import tvcache
|
|
|
|
from sickbeard import encodingKludge as ek
|
|
|
|
from sickbeard.exceptions import ex
|
2014-07-06 09:11:04 -04:00
|
|
|
from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException
|
2014-04-29 09:14:19 -04:00
|
|
|
from sickbeard.common import Quality
|
2014-07-28 15:19:41 -04:00
|
|
|
from sickbeard import clients
|
2014-04-30 18:07:18 -04:00
|
|
|
|
2014-07-27 10:04:37 -04:00
|
|
|
from hachoir_parser import createParser
|
2014-07-27 06:59:21 -04:00
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
class GenericProvider:
|
2014-03-10 01:18:05 -04:00
|
|
|
NZB = "nzb"
|
|
|
|
TORRENT = "torrent"
|
|
|
|
|
|
|
|
def __init__(self, name):
|
|
|
|
# these need to be set in the subclass
|
|
|
|
self.providerType = None
|
|
|
|
self.name = name
|
|
|
|
self.url = ''
|
|
|
|
|
2014-04-29 09:14:19 -04:00
|
|
|
self.show = None
|
2014-05-17 01:23:11 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
self.supportsBacklog = False
|
2014-05-26 02:29:22 -04:00
|
|
|
self.supportsAbsoluteNumbering = False
|
2014-05-27 03:44:23 -04:00
|
|
|
self.anime_only = False
|
2014-05-17 01:23:11 -04:00
|
|
|
|
2014-05-16 05:16:01 -04:00
|
|
|
self.search_mode = None
|
|
|
|
self.search_fallback = False
|
2014-05-18 12:39:30 -04:00
|
|
|
self.backlog_only = False
|
2014-05-27 03:44:23 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
self.cache = tvcache.TVCache(self)
|
|
|
|
|
2014-04-28 05:15:29 -04:00
|
|
|
self.session = requests.session()
|
2014-07-27 10:04:37 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
self.headers = {
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'}
|
2014-04-28 05:15:29 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def getID(self):
|
|
|
|
return GenericProvider.makeID(self.name)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def makeID(name):
|
2014-03-25 01:57:24 -04:00
|
|
|
return re.sub("[^\w\d_]", "_", name.strip().lower())
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
def imageName(self):
|
|
|
|
return self.getID() + '.png'
|
|
|
|
|
|
|
|
def _checkAuth(self):
|
2014-08-12 06:09:11 -04:00
|
|
|
return True
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
def _doLogin(self):
|
|
|
|
return True
|
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def isActive(self):
|
|
|
|
if self.providerType == GenericProvider.NZB and sickbeard.USE_NZBS:
|
|
|
|
return self.isEnabled()
|
|
|
|
elif self.providerType == GenericProvider.TORRENT and sickbeard.USE_TORRENTS:
|
|
|
|
return self.isEnabled()
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def isEnabled(self):
|
|
|
|
"""
|
|
|
|
This should be overridden and should return the config setting eg. sickbeard.MYPROVIDER
|
|
|
|
"""
|
|
|
|
return False
|
|
|
|
|
|
|
|
def getResult(self, episodes):
|
|
|
|
"""
|
|
|
|
Returns a result of the correct type for this provider
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.providerType == GenericProvider.NZB:
|
|
|
|
result = classes.NZBSearchResult(episodes)
|
|
|
|
elif self.providerType == GenericProvider.TORRENT:
|
|
|
|
result = classes.TorrentSearchResult(episodes)
|
|
|
|
else:
|
|
|
|
result = classes.SearchResult(episodes)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
|
|
|
result.provider = self
|
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
return result
|
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
def getURL(self, url, post_data=None, params=None, timeout=30, json=False):
|
2014-03-10 01:18:05 -04:00
|
|
|
"""
|
|
|
|
By default this is just a simple urlopen call but this method should be overridden
|
|
|
|
for providers with special URL requirements (like cookies)
|
|
|
|
"""
|
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
# check for auth
|
|
|
|
if not self._doLogin():
|
|
|
|
return
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
return helpers.getURL(url, post_data=post_data, params=params, headers=self.headers, timeout=timeout,
|
|
|
|
session=self.session, json=json)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
def downloadResult(self, result):
|
|
|
|
"""
|
|
|
|
Save the result to disk.
|
|
|
|
"""
|
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
# check for auth
|
|
|
|
if not self._doLogin():
|
2014-07-27 10:04:37 -04:00
|
|
|
return False
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
if self.providerType == GenericProvider.TORRENT:
|
2014-07-27 10:04:37 -04:00
|
|
|
try:
|
|
|
|
torrent_hash = re.findall('urn:btih:([\w]{32,40})', result.url)[0].upper()
|
|
|
|
if not torrent_hash:
|
|
|
|
logger.log("Unable to extract torrent hash from link: " + ex(result.url), logger.ERROR)
|
|
|
|
return False
|
|
|
|
|
|
|
|
urls = [
|
|
|
|
'http://torcache.net/torrent/' + torrent_hash + '.torrent',
|
|
|
|
'http://torrage.com/torrent/' + torrent_hash + '.torrent',
|
|
|
|
'http://zoink.it/torrent/' + torrent_hash + '.torrent',
|
|
|
|
]
|
|
|
|
except:
|
|
|
|
urls = [result.url]
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
filename = ek.ek(os.path.join, sickbeard.TORRENT_DIR,
|
|
|
|
helpers.sanitizeFileName(result.name) + '.' + self.providerType)
|
|
|
|
elif self.providerType == GenericProvider.NZB:
|
|
|
|
urls = [result.url]
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
filename = ek.ek(os.path.join, sickbeard.NZB_DIR,
|
|
|
|
helpers.sanitizeFileName(result.name) + '.' + self.providerType)
|
|
|
|
else:
|
|
|
|
return
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
for url in urls:
|
|
|
|
if helpers.download_file(url, filename, session=self.session):
|
|
|
|
logger.log(u"Downloading a result from " + self.name + " at " + url)
|
|
|
|
|
|
|
|
if self.providerType == GenericProvider.TORRENT:
|
|
|
|
logger.log(u"Saved magnet link to " + filename, logger.MESSAGE)
|
|
|
|
else:
|
|
|
|
logger.log(u"Saved result to " + filename, logger.MESSAGE)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-27 06:59:21 -04:00
|
|
|
return self._verify_download(filename)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
def _verify_download(self, file_name=None):
|
|
|
|
"""
|
|
|
|
Checks the saved file to see if it was actually valid, if not then consider the download a failure.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# primitive verification of torrents, just make sure we didn't get a text file or something
|
|
|
|
if self.providerType == GenericProvider.TORRENT:
|
|
|
|
parser = createParser(file_name)
|
|
|
|
if parser:
|
|
|
|
mime_type = parser._getMimeType()
|
|
|
|
try:
|
|
|
|
parser.stream._input.close()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if mime_type != 'application/x-bittorrent':
|
|
|
|
logger.log(u"Result is not a valid torrent file", logger.WARNING)
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2014-05-18 08:59:42 -04:00
|
|
|
def searchRSS(self, episodes):
|
|
|
|
return self.cache.findNeededEpisodes(episodes)
|
2014-05-15 00:16:46 -04:00
|
|
|
|
2014-05-26 02:29:22 -04:00
|
|
|
def getQuality(self, item, anime=False):
|
2014-03-10 01:18:05 -04:00
|
|
|
"""
|
|
|
|
Figures out the quality of the given RSS item node
|
|
|
|
|
|
|
|
item: An elementtree.ElementTree element representing the <item> tag of the RSS feed
|
|
|
|
|
|
|
|
Returns a Quality value obtained from the node's data
|
|
|
|
"""
|
2014-03-25 01:57:24 -04:00
|
|
|
(title, url) = self._get_title_and_url(item) # @UnusedVariable
|
2014-05-26 02:29:22 -04:00
|
|
|
quality = Quality.sceneQuality(title, anime)
|
2014-03-10 01:18:05 -04:00
|
|
|
return quality
|
|
|
|
|
2014-07-21 01:47:13 -04:00
|
|
|
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
|
2014-03-10 01:18:05 -04:00
|
|
|
return []
|
|
|
|
|
2014-04-30 09:49:50 -04:00
|
|
|
def _get_season_search_strings(self, episode):
|
2014-03-10 01:18:05 -04:00
|
|
|
return []
|
|
|
|
|
2014-04-30 09:49:50 -04:00
|
|
|
def _get_episode_search_strings(self, eb_obj, add_string=''):
|
2014-03-10 01:18:05 -04:00
|
|
|
return []
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
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 <item> tag of the RSS feed
|
|
|
|
|
|
|
|
Returns: A tuple containing two strings representing title and URL respectively
|
|
|
|
"""
|
2014-05-05 09:26:02 -04:00
|
|
|
|
|
|
|
title = item.title if item.title else None
|
2014-03-10 01:18:05 -04:00
|
|
|
if title:
|
2014-07-14 22:00:53 -04:00
|
|
|
title = u'' + title
|
2014-03-10 01:18:05 -04:00
|
|
|
title = title.replace(' ', '.')
|
|
|
|
|
2014-05-05 09:26:02 -04:00
|
|
|
url = item.link if item.link else None
|
2014-03-10 01:18:05 -04:00
|
|
|
if url:
|
|
|
|
url = url.replace('&', '&')
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
return (title, url)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-05-17 01:23:11 -04:00
|
|
|
def findSearchResults(self, show, season, episodes, search_mode, manualSearch=False):
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-04-30 21:20:53 -04:00
|
|
|
self._checkAuth()
|
|
|
|
self.show = show
|
|
|
|
|
2014-04-27 06:31:54 -04:00
|
|
|
results = {}
|
2014-07-21 01:07:53 -04:00
|
|
|
itemList = []
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-05-16 01:40:49 -04:00
|
|
|
searched_scene_season = None
|
2014-05-03 05:23:26 -04:00
|
|
|
for epObj in episodes:
|
2014-07-21 01:07:53 -04:00
|
|
|
# check cache for results
|
|
|
|
cacheResult = self.cache.searchCache([epObj], manualSearch)
|
|
|
|
if len(cacheResult):
|
|
|
|
results.update({epObj.episode: cacheResult[epObj]})
|
|
|
|
continue
|
|
|
|
|
|
|
|
# skip if season already searched
|
|
|
|
if len(episodes) > 1 and searched_scene_season == epObj.scene_season:
|
|
|
|
continue
|
2014-05-16 01:40:49 -04:00
|
|
|
|
2014-05-16 05:16:01 -04:00
|
|
|
# mark season searched for season pack searches so we can skip later on
|
|
|
|
searched_scene_season = epObj.scene_season
|
|
|
|
|
2014-07-21 01:07:53 -04:00
|
|
|
if len(episodes) > 1:
|
|
|
|
# get season search results
|
2014-05-05 09:26:02 -04:00
|
|
|
for curString in self._get_season_search_strings(epObj):
|
2014-07-21 01:47:13 -04:00
|
|
|
itemList += self._doSearch(curString, search_mode, len(episodes))
|
2014-05-16 01:16:35 -04:00
|
|
|
else:
|
2014-07-21 01:07:53 -04:00
|
|
|
# get single episode search results
|
2014-05-16 01:16:35 -04:00
|
|
|
for curString in self._get_episode_search_strings(epObj):
|
2014-07-21 01:47:13 -04:00
|
|
|
itemList += self._doSearch(curString, 'eponly', len(episodes))
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-07-21 01:07:53 -04:00
|
|
|
# if we found what we needed already from cache then return results and exit
|
|
|
|
if len(results) == len(episodes):
|
2014-05-30 03:36:47 -04:00
|
|
|
return results
|
2014-05-12 15:48:47 -04:00
|
|
|
|
2014-07-21 02:43:52 -04:00
|
|
|
# sort list by quality
|
|
|
|
if len(itemList):
|
|
|
|
items = {}
|
2014-07-21 02:59:57 -04:00
|
|
|
itemsUnknown = []
|
2014-07-21 02:43:52 -04:00
|
|
|
for item in itemList:
|
|
|
|
quality = self.getQuality(item, anime=show.is_anime)
|
2014-07-21 02:59:57 -04:00
|
|
|
if quality == Quality.UNKNOWN:
|
2014-07-21 21:48:16 -04:00
|
|
|
itemsUnknown += [item]
|
2014-07-21 02:59:57 -04:00
|
|
|
else:
|
2014-07-21 11:38:56 -04:00
|
|
|
if quality not in items:
|
|
|
|
items[quality] = [item]
|
|
|
|
else:
|
|
|
|
items[quality].append(item)
|
2014-07-21 20:55:45 -04:00
|
|
|
|
|
|
|
itemList = list(itertools.chain(*[v for (k, v) in sorted(items.items(), reverse=True)]))
|
|
|
|
itemList += itemsUnknown if itemsUnknown else []
|
2014-07-21 02:43:52 -04:00
|
|
|
|
2014-07-21 01:07:53 -04:00
|
|
|
# filter results
|
2014-07-22 02:00:58 -04:00
|
|
|
cl = []
|
2014-07-21 01:07:53 -04:00
|
|
|
for item in itemList:
|
|
|
|
(title, url) = self._get_title_and_url(item)
|
2014-05-08 10:03:50 -04:00
|
|
|
|
2014-07-21 01:07:53 -04:00
|
|
|
# parse the file name
|
|
|
|
try:
|
2014-07-25 00:29:03 -04:00
|
|
|
myParser = NameParser(False, convert=True)
|
2014-07-21 01:07:53 -04:00
|
|
|
parse_result = myParser.parse(title)
|
|
|
|
except InvalidNameException:
|
|
|
|
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.DEBUG)
|
|
|
|
continue
|
|
|
|
except InvalidShowException:
|
|
|
|
logger.log(u"Unable to parse the filename " + title + " into a valid show", logger.DEBUG)
|
|
|
|
continue
|
2014-05-04 08:05:27 -04:00
|
|
|
|
2014-07-21 01:07:53 -04:00
|
|
|
showObj = parse_result.show
|
|
|
|
quality = parse_result.quality
|
|
|
|
release_group = parse_result.release_group
|
2014-07-22 00:53:32 -04:00
|
|
|
version = parse_result.version
|
2014-07-21 01:07:53 -04:00
|
|
|
|
2014-07-22 02:00:58 -04:00
|
|
|
addCacheEntry = False
|
2014-07-21 01:07:53 -04:00
|
|
|
if not (showObj.air_by_date or showObj.sports):
|
|
|
|
if search_mode == 'sponly' and len(parse_result.episode_numbers):
|
|
|
|
logger.log(
|
|
|
|
u"This is supposed to be a season pack search but the result " + title + " is not a valid season pack, skipping it",
|
|
|
|
logger.DEBUG)
|
2014-07-22 02:00:58 -04:00
|
|
|
addCacheEntry = True
|
|
|
|
else:
|
|
|
|
if not len(parse_result.episode_numbers) and (
|
|
|
|
parse_result.season_number and parse_result.season_number != season) or (
|
|
|
|
not parse_result.season_number and season != 1):
|
2014-07-27 06:59:21 -04:00
|
|
|
logger.log(
|
|
|
|
u"The result " + title + " doesn't seem to be a valid season that we are trying to snatch, ignoring",
|
|
|
|
logger.DEBUG)
|
2014-07-22 02:00:58 -04:00
|
|
|
addCacheEntry = True
|
|
|
|
elif len(parse_result.episode_numbers) and (
|
|
|
|
parse_result.season_number != season or not [ep for ep in episodes if
|
|
|
|
ep.scene_episode in parse_result.episode_numbers]):
|
2014-07-27 06:59:21 -04:00
|
|
|
logger.log(
|
|
|
|
u"The result " + title + " doesn't seem to be a valid episode that we are trying to snatch, ignoring",
|
|
|
|
logger.DEBUG)
|
2014-07-22 02:00:58 -04:00
|
|
|
addCacheEntry = True
|
|
|
|
|
|
|
|
if not addCacheEntry:
|
|
|
|
# we just use the existing info for normal searches
|
|
|
|
actual_season = season
|
|
|
|
actual_episodes = parse_result.episode_numbers
|
2014-07-21 01:07:53 -04:00
|
|
|
else:
|
|
|
|
if not (parse_result.is_air_by_date or parse_result.is_sports):
|
2014-03-25 01:57:24 -04:00
|
|
|
logger.log(
|
2014-07-21 01:07:53 -04:00
|
|
|
u"This is supposed to be a date search but the result " + title + " didn't parse as one, skipping it",
|
|
|
|
logger.DEBUG)
|
2014-07-22 02:00:58 -04:00
|
|
|
addCacheEntry = True
|
|
|
|
else:
|
|
|
|
airdate = parse_result.air_date.toordinal() if parse_result.air_date else parse_result.sports_air_date.toordinal()
|
|
|
|
myDB = db.DBConnection()
|
|
|
|
sql_results = myDB.select(
|
|
|
|
"SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
|
|
|
|
[showObj.indexerid, airdate])
|
|
|
|
|
|
|
|
if len(sql_results) != 1:
|
|
|
|
logger.log(
|
|
|
|
u"Tried to look up the date for the episode " + title + " but the database didn't give proper results, skipping it",
|
|
|
|
logger.WARNING)
|
|
|
|
addCacheEntry = True
|
|
|
|
|
|
|
|
if not addCacheEntry:
|
|
|
|
actual_season = int(sql_results[0]["season"])
|
|
|
|
actual_episodes = [int(sql_results[0]["episode"])]
|
|
|
|
|
|
|
|
# add parsed result to cache for usage later on
|
|
|
|
if addCacheEntry:
|
|
|
|
logger.log(u"Adding item from search to cache: " + title, logger.DEBUG)
|
|
|
|
ci = self.cache._addCacheEntry(title, url, parse_result=parse_result)
|
|
|
|
if ci is not None:
|
|
|
|
cl.append(ci)
|
|
|
|
continue
|
2014-07-21 01:07:53 -04:00
|
|
|
|
|
|
|
# make sure we want the episode
|
|
|
|
wantEp = True
|
|
|
|
for epNo in actual_episodes:
|
|
|
|
if not showObj.wantEpisode(actual_season, epNo, quality, manualSearch):
|
|
|
|
wantEp = False
|
|
|
|
break
|
|
|
|
|
|
|
|
if not wantEp:
|
|
|
|
logger.log(
|
|
|
|
u"Ignoring result " + title + " because we don't want an episode that is " +
|
|
|
|
Quality.qualityStrings[
|
|
|
|
quality], logger.DEBUG)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
logger.log(u"Found result " + title + " at " + url, logger.DEBUG)
|
|
|
|
|
|
|
|
# make a result object
|
|
|
|
epObj = []
|
|
|
|
for curEp in actual_episodes:
|
|
|
|
epObj.append(showObj.getEpisode(actual_season, curEp))
|
|
|
|
|
|
|
|
result = self.getResult(epObj)
|
|
|
|
result.show = showObj
|
|
|
|
result.url = url
|
|
|
|
result.name = title
|
|
|
|
result.quality = quality
|
|
|
|
result.release_group = release_group
|
|
|
|
result.content = None
|
2014-07-22 00:53:32 -04:00
|
|
|
result.version = version
|
2014-07-21 01:07:53 -04:00
|
|
|
|
|
|
|
if len(epObj) == 1:
|
|
|
|
epNum = epObj[0].episode
|
|
|
|
logger.log(u"Single episode result.", logger.DEBUG)
|
|
|
|
elif len(epObj) > 1:
|
|
|
|
epNum = MULTI_EP_RESULT
|
|
|
|
logger.log(u"Separating multi-episode result to check for later - result contains episodes: " + str(
|
|
|
|
parse_result.episode_numbers), logger.DEBUG)
|
|
|
|
elif len(epObj) == 0:
|
|
|
|
epNum = SEASON_RESULT
|
|
|
|
logger.log(u"Separating full season result to check for later", logger.DEBUG)
|
|
|
|
|
2014-07-21 09:29:07 -04:00
|
|
|
if epNum not in results:
|
2014-07-21 01:07:53 -04:00
|
|
|
results[epNum] = [result]
|
2014-07-21 09:29:07 -04:00
|
|
|
else:
|
|
|
|
results[epNum].append(result)
|
2014-05-03 19:26:12 -04:00
|
|
|
|
2014-07-22 02:00:58 -04:00
|
|
|
# check if we have items to add to cache
|
|
|
|
if len(cl) > 0:
|
|
|
|
myDB = self.cache._getDB()
|
|
|
|
myDB.mass_action(cl)
|
|
|
|
|
2014-05-03 19:26:12 -04:00
|
|
|
return results
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
def findPropers(self, search_date=None):
|
|
|
|
|
|
|
|
results = self.cache.listPropers(search_date)
|
|
|
|
|
2014-07-14 22:00:53 -04:00
|
|
|
return [classes.Proper(x['name'], x['url'], datetime.datetime.fromtimestamp(x['time']), self.show) for x in
|
|
|
|
results]
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-05-08 18:28:28 -04:00
|
|
|
def seedRatio(self):
|
|
|
|
'''
|
|
|
|
Provider should override this value if custom seed ratio enabled
|
|
|
|
It should return the value of the provider seed ratio
|
|
|
|
'''
|
|
|
|
return ''
|
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
class NZBProvider(GenericProvider):
|
|
|
|
def __init__(self, name):
|
|
|
|
GenericProvider.__init__(self, name)
|
|
|
|
|
|
|
|
self.providerType = GenericProvider.NZB
|
|
|
|
|
2014-07-14 22:00:53 -04:00
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
class TorrentProvider(GenericProvider):
|
2014-03-10 01:18:05 -04:00
|
|
|
def __init__(self, name):
|
|
|
|
GenericProvider.__init__(self, name)
|
|
|
|
|
2014-07-25 00:29:03 -04:00
|
|
|
self.providerType = GenericProvider.TORRENT
|