mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 08:53:37 +00:00
Re-coded the Indexer cache, cache lookups are only performed for existing shows and we don't add any cache entries unless we are Indexing the show in our database so we don't waste cpu cycles and memory.
Manual and backlog searches both search the cache first before even attempting to send a search request to a provider. More bugs have been worked out.
This commit is contained in:
parent
dbee4b6dbf
commit
87b752b4e5
29 changed files with 427 additions and 581 deletions
|
@ -54,7 +54,7 @@ class FailedProcessor(object):
|
||||||
|
|
||||||
parser = NameParser(False)
|
parser = NameParser(False)
|
||||||
try:
|
try:
|
||||||
parsed = parser.parse(releaseName, True)
|
parsed = parser.parse(releaseName)
|
||||||
except InvalidNameException:
|
except InvalidNameException:
|
||||||
self._log(u"Error: release name is invalid: " + releaseName, logger.WARNING)
|
self._log(u"Error: release name is invalid: " + releaseName, logger.WARNING)
|
||||||
raise exceptions.FailedProcessingFailed()
|
raise exceptions.FailedProcessingFailed()
|
||||||
|
|
|
@ -255,8 +255,12 @@ def download_file(url, filename):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def findCertainShow(showList, indexerid):
|
def findCertainShow(showList, indexerid=None):
|
||||||
results = filter(lambda x: x.indexerid == indexerid, showList)
|
if indexerid:
|
||||||
|
results = filter(lambda x: x.indexerid == indexerid, showList)
|
||||||
|
else:
|
||||||
|
results = filter(lambda x: x.indexerid == indexerid, showList)
|
||||||
|
|
||||||
if len(results) == 0:
|
if len(results) == 0:
|
||||||
return None
|
return None
|
||||||
elif len(results) > 1:
|
elif len(results) > 1:
|
||||||
|
@ -276,7 +280,7 @@ def makeDir(path):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def searchDBForShow(regShowName, indexer_id=None):
|
def searchDBForShow(regShowName):
|
||||||
showNames = list(set([re.sub('[. -]', ' ', regShowName), regShowName]))
|
showNames = list(set([re.sub('[. -]', ' ', regShowName), regShowName]))
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
@ -319,38 +323,36 @@ def searchDBForShow(regShowName, indexer_id=None):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def searchIndexerForShowID(regShowName, indexer=None, indexer_id=None, ui=True):
|
def searchIndexerForShowID(regShowName, indexer=None, indexer_id=None, ui=None):
|
||||||
showNames = list(set([re.sub('[. -]', ' ', regShowName), regShowName]))
|
showNames = list(set([re.sub('[. -]', ' ', regShowName), regShowName]))
|
||||||
|
|
||||||
# Query Indexers for each search term and build the list of results
|
# Query Indexers for each search term and build the list of results
|
||||||
for indexer in sickbeard.indexerApi().indexers if not indexer else [int(indexer)]:
|
for indexer in sickbeard.indexerApi().indexers if not indexer else [int(indexer)]:
|
||||||
# Query Indexers for each search term and build the list of results
|
# Query Indexers for each search term and build the list of results
|
||||||
lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
|
lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
|
||||||
if ui:lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
|
if ui:lINDEXER_API_PARMS['custom_ui'] = ui
|
||||||
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
|
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
|
||||||
|
|
||||||
for name in showNames:
|
for name in showNames:
|
||||||
logger.log(u"Trying to find " + name + " on " + sickbeard.indexerApi(indexer).name, logger.DEBUG)
|
logger.log(u"Trying to find " + name + " on " + sickbeard.indexerApi(indexer).name, logger.DEBUG)
|
||||||
try:
|
try:
|
||||||
if indexer_id:
|
search = t[indexer_id] if indexer_id else t[name]
|
||||||
search = t[indexer_id]
|
|
||||||
else:
|
|
||||||
search = t[name]
|
|
||||||
|
|
||||||
if isinstance(search, dict):
|
|
||||||
search = [search]
|
|
||||||
|
|
||||||
# add search results
|
# add search results
|
||||||
for i in range(len(search)):
|
for i in range(len(search)):
|
||||||
part = search[i]
|
part = search[i]
|
||||||
seriesname = part['seriesname'].encode('UTF-8').lower()
|
seriesname = part['seriesname'].lower()
|
||||||
name = name.encode('UTF-8').lower()
|
|
||||||
|
|
||||||
if (name in seriesname) or (indexer_id is not None and part['id'] == indexer_id):
|
if str(name).lower() == seriesname or (indexer_id and part['id'] == indexer_id):
|
||||||
return [sickbeard.indexerApi(indexer).config['id'], part['id']]
|
return [sickbeard.indexerApi(indexer).config['id'], part['id']]
|
||||||
|
|
||||||
except KeyError:break
|
except KeyError:
|
||||||
except Exception:continue
|
if indexer:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
|
||||||
def sizeof_fmt(num):
|
def sizeof_fmt(num):
|
||||||
'''
|
'''
|
||||||
|
@ -950,8 +952,6 @@ def _check_against_names(name, show):
|
||||||
|
|
||||||
|
|
||||||
def get_show_by_name(name, showList, useIndexer=False):
|
def get_show_by_name(name, showList, useIndexer=False):
|
||||||
logger.log(u"Trying to get the indexerid for " + name, logger.DEBUG)
|
|
||||||
|
|
||||||
if showList:
|
if showList:
|
||||||
for show in showList:
|
for show in showList:
|
||||||
if _check_against_names(name, show):
|
if _check_against_names(name, show):
|
||||||
|
|
|
@ -190,48 +190,49 @@ sports_regexs = [
|
||||||
('sports_event',
|
('sports_event',
|
||||||
# Show.Name.123.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
# Show.Name.123.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
||||||
'''
|
'''
|
||||||
^(?P<series_name>.*?)[. _-]+
|
^(?P<series_name>.*?)\W
|
||||||
(?P<parts>\d{1,3}\d{1,3}.*?)[. _-]+
|
(?P<parts>\d{1,3})\W
|
||||||
(?P<event>.*?)[. _-]+
|
(?P<event>.*?)\W
|
||||||
(?P<air_day>\d{1,2}).+
|
(?P<air_day>\d{1,2})(\w{2})\W
|
||||||
(?P<air_month>[a-zA-Z]{3,})[. _-]+
|
(?P<air_month>\w{3,})\W
|
||||||
(?P<air_year>\d{4})[. _-]+
|
(?P<air_year>\d{4})\W
|
||||||
(?P<extra_info>.*?(?<![. _-])(?<!WEB))[. _-]+
|
(?P<extra_info>.*?)\W
|
||||||
(?P<release_group>.*?)$
|
(?P<release_group>.*?)$
|
||||||
'''),
|
'''),
|
||||||
|
|
||||||
('sports_event_without_parts',
|
('sports_event_without_parts',
|
||||||
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
||||||
'''
|
'''
|
||||||
^(?P<series_name>.*?)[. _-]+
|
^(?P<series_name>.*?)\W
|
||||||
(?P<event>.*?)[. _-]+
|
(?P<event>.*?)\W
|
||||||
(?P<air_day>\d{1,2}).+
|
(?P<air_day>\d{1,2})(\w{2})\W
|
||||||
(?P<air_month>[a-zA-Z]{3,})[. _-]+
|
(?P<air_month>\w{3,})\W
|
||||||
(?P<air_year>\d{4})[. _-]+
|
(?P<air_year>\d{4})\W
|
||||||
(?P<extra_info>.*?(?<![. _-])(?<!WEB))[. _-]+
|
(?P<extra_info>.*?)\W
|
||||||
(?P<release_group>.*?)$
|
(?P<release_group>.*?)$
|
||||||
|
|
||||||
'''),
|
'''),
|
||||||
|
|
||||||
('sports_parts_without_event',
|
('sports_parts_without_event',
|
||||||
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
||||||
'''
|
'''
|
||||||
^(?P<series_name>.*?)[. _-]+
|
^(?P<series_name>.*?)\W
|
||||||
(?P<parts>\d{1,3}\d{1,3}.*?)[. _-]+
|
(?P<parts>\d{1,3})\W
|
||||||
(?P<air_day>\d{1,2}).+
|
(?P<air_day>\d{1,2})(\w{2})\W
|
||||||
(?P<air_month>[a-zA-Z]{3,})[. _-]+
|
(?P<air_month>\w{3,})\W
|
||||||
(?P<air_year>\d{4})[. _-]+
|
(?P<air_year>\d{4})\W
|
||||||
(?P<extra_info>.*?(?<![. _-])(?<!WEB))[. _-]+
|
(?P<extra_info>.*?)\W
|
||||||
(?P<release_group>.*?)$
|
(?P<release_group>.*?)$
|
||||||
'''),
|
'''),
|
||||||
|
|
||||||
('sports_date_only',
|
('sports_date_only',
|
||||||
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
|
||||||
'''
|
'''
|
||||||
^(?P<series_name>.*?)[. _-]+
|
^(?P<series_name>.*?)\W
|
||||||
(?P<air_day>\d{1,2})[. _-]+
|
(?P<air_day>\d{1,2})(\w{2})\W
|
||||||
(?P<air_month>[a-zA-Z]{3,})[. _-]+
|
(?P<air_month>\w{3,})\W
|
||||||
(?P<air_year>\d{4})[. _-]+
|
(?P<air_year>\d{4})\W
|
||||||
(?P<extra_info>.*?(?<![. _-])(?<!WEB))[. _-]+
|
(?P<extra_info>.*?)\W
|
||||||
(?P<release_group>.*?)$
|
(?P<release_group>.*?)$
|
||||||
'''),
|
'''),
|
||||||
]
|
]
|
|
@ -538,7 +538,7 @@ class PostProcessor(object):
|
||||||
|
|
||||||
# see if we can find the name on the Indexer
|
# see if we can find the name on the Indexer
|
||||||
for cur_name in name_list:
|
for cur_name in name_list:
|
||||||
foundInfo = helpers.searchIndexerForShowID(cur_name)
|
foundInfo = helpers.searchIndexerForShowID(cur_name, ui=classes.ShowListUI)
|
||||||
if foundInfo:
|
if foundInfo:
|
||||||
indexer_id = foundInfo[1]
|
indexer_id = foundInfo[1]
|
||||||
self._log(
|
self._log(
|
||||||
|
|
|
@ -37,7 +37,6 @@ import math
|
||||||
|
|
||||||
class BTNProvider(generic.TorrentProvider):
|
class BTNProvider(generic.TorrentProvider):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
generic.TorrentProvider.__init__(self, "BTN")
|
generic.TorrentProvider.__init__(self, "BTN")
|
||||||
|
|
||||||
self.supportsBacklog = True
|
self.supportsBacklog = True
|
||||||
|
@ -191,58 +190,55 @@ class BTNProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_params = []
|
search_params = []
|
||||||
|
|
||||||
name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid) + [show.name]
|
name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name]
|
||||||
for name in name_exceptions:
|
for name in name_exceptions:
|
||||||
|
|
||||||
current_params = {}
|
current_params = {}
|
||||||
|
|
||||||
if show.indexer == 1:
|
if self.show.indexer == 1:
|
||||||
current_params['tvdb'] = show.indexerid
|
current_params['tvdb'] = self.show.indexerid
|
||||||
elif show.indexer == 2:
|
elif self.show.indexer == 2:
|
||||||
current_params['tvrage'] = show.indexerid
|
current_params['tvrage'] = self.show.indexerid
|
||||||
else:
|
else:
|
||||||
# Search by name if we don't have tvdb or tvrage id
|
# Search by name if we don't have tvdb or tvrage id
|
||||||
current_params['series'] = sanitizeSceneName(name)
|
current_params['series'] = sanitizeSceneName(name)
|
||||||
|
|
||||||
whole_season_params = current_params.copy()
|
whole_season_params = current_params.copy()
|
||||||
partial_season_params = current_params.copy()
|
|
||||||
# Search for entire seasons: no need to do special things for air by date shows
|
# Search for entire seasons: no need to do special things for air by date shows
|
||||||
whole_season_params['category'] = 'Season'
|
whole_season_params['category'] = 'Season'
|
||||||
whole_season_params['name'] = 'Season ' + str(season)
|
whole_season_params['name'] = 'Season ' + str(season)
|
||||||
search_params.append(whole_season_params)
|
search_params.append(whole_season_params)
|
||||||
|
|
||||||
# Search for episodes in the season
|
# Search for episodes in the season
|
||||||
search_params.append(self._get_episode_search_strings(show, season, episode)[0])
|
search_params.append(self._get_episode_search_strings(season, episode)[0])
|
||||||
|
|
||||||
return search_params
|
return search_params
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return [{}]
|
return [{}]
|
||||||
|
|
||||||
search_params = {'category': 'Episode'}
|
search_params = {'category': 'Episode'}
|
||||||
|
|
||||||
if show.indexer == 1:
|
if self.show.indexer == 1:
|
||||||
search_params['tvdb'] = show.indexerid
|
search_params['tvdb'] = self.show.indexerid
|
||||||
elif show.indexer == 2:
|
elif self.show.indexer == 2:
|
||||||
search_params['tvrage'] = show.indexerid
|
search_params['tvrage'] = self.show.indexerid
|
||||||
else:
|
else:
|
||||||
search_params['series'] = sanitizeSceneName(show.name)
|
search_params['series'] = sanitizeSceneName(self.show.name)
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
date_str = str(episode)
|
date_str = str(episode)
|
||||||
|
|
||||||
# BTN uses dots in dates, we just search for the date since that
|
# BTN uses dots in dates, we just search for the date since that
|
||||||
# combined with the series identifier should result in just one episode
|
# combined with the series identifier should result in just one episode
|
||||||
search_params['name'] = date_str.replace('-', '.')
|
search_params['name'] = date_str.replace('-', '.')
|
||||||
if show.sports:
|
if self.show.sports:
|
||||||
date_str = str(episode)
|
date_str = str(episode)
|
||||||
|
|
||||||
# BTN uses dots in dates, we just search for the date since that
|
# BTN uses dots in dates, we just search for the date since that
|
||||||
|
@ -258,11 +254,11 @@ class BTNProvider(generic.TorrentProvider):
|
||||||
if 'series' in search_params:
|
if 'series' in search_params:
|
||||||
|
|
||||||
# add new query string for every exception
|
# add new query string for every exception
|
||||||
name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid)
|
name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid)
|
||||||
for cur_exception in name_exceptions:
|
for cur_exception in name_exceptions:
|
||||||
|
|
||||||
# don't add duplicates
|
# don't add duplicates
|
||||||
if cur_exception == show.name:
|
if cur_exception == self.show.name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# copy all other parameters before setting the show name for this exception
|
# copy all other parameters before setting the show name for this exception
|
||||||
|
|
|
@ -52,21 +52,21 @@ class DTTProvider(generic.TorrentProvider):
|
||||||
def _dtt_show_id(self, show_name):
|
def _dtt_show_id(self, show_name):
|
||||||
return sanitizeSceneName(show_name).replace('.', '-').lower()
|
return sanitizeSceneName(show_name).replace('.', '-').lower()
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
search_string = []
|
search_string = []
|
||||||
|
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
show_string = sanitizeSceneName(show_name).replace('.', '-').lower()
|
show_string = sanitizeSceneName(show_name).replace('.', '-').lower()
|
||||||
search_string.append(show_string)
|
search_string.append(show_string)
|
||||||
|
|
||||||
return search_string
|
return search_string
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return self._get_season_search_strings(show, season, episode)
|
return self._get_season_search_strings(season, episode)
|
||||||
|
|
||||||
def _doSearch(self, search_params, show=None, age=None):
|
def _doSearch(self, search_params, show=None, age=None):
|
||||||
|
|
||||||
# show_id = self._dtt_show_id(show.name)
|
# show_id = self._dtt_show_id(self.show.name)
|
||||||
|
|
||||||
params = {"items": "all"}
|
params = {"items": "all"}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class EZRSSProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
if show.air_by_date or show.sports:
|
if self.show.air_by_date or show.sports:
|
||||||
logger.log(self.name + u" doesn't support air-by-date or sports backloging because of limitations on their RSS search.",
|
logger.log(self.name + u" doesn't support air-by-date or sports backloging because of limitations on their RSS search.",
|
||||||
logger.WARNING)
|
logger.WARNING)
|
||||||
return results
|
return results
|
||||||
|
@ -70,33 +70,30 @@ class EZRSSProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
if not show:
|
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
||||||
return params
|
|
||||||
|
|
||||||
params['show_name'] = helpers.sanitizeSceneName(show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
|
||||||
|
|
||||||
params['season'] = season
|
params['season'] = season
|
||||||
|
|
||||||
params['episode'] = self._get_episode_search_strings(show, season, episode)[0]['episode']
|
params['episode'] = self._get_episode_search_strings(season, episode)[0]['episode']
|
||||||
|
|
||||||
return [params]
|
return [params]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return params
|
return params
|
||||||
|
|
||||||
params['show_name'] = helpers.sanitizeSceneName(show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
params['date'] = str(episode)
|
params['date'] = str(episode)
|
||||||
if show.sports:
|
if self.show.sports:
|
||||||
params['date'] = str(episode)
|
params['date'] = str(episode)
|
||||||
else:
|
else:
|
||||||
params['season'] = season
|
params['season'] = season
|
||||||
|
|
|
@ -21,14 +21,8 @@ from __future__ import with_statement
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
import urllib2
|
|
||||||
|
|
||||||
import itertools
|
|
||||||
import operator
|
|
||||||
import collections
|
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
@ -36,13 +30,13 @@ import sickbeard
|
||||||
from lib import requests
|
from lib import requests
|
||||||
from lib.feedparser import feedparser
|
from lib.feedparser import feedparser
|
||||||
from sickbeard import helpers, classes, logger, db
|
from sickbeard import helpers, classes, logger, db
|
||||||
from sickbeard.common import Quality, MULTI_EP_RESULT, SEASON_RESULT #, SEED_POLICY_TIME, SEED_POLICY_RATIO
|
from sickbeard.common import MULTI_EP_RESULT, SEASON_RESULT #, SEED_POLICY_TIME, SEED_POLICY_RATIO
|
||||||
from sickbeard import tvcache
|
from sickbeard import tvcache
|
||||||
from sickbeard import encodingKludge as ek
|
from sickbeard import encodingKludge as ek
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
from lib.hachoir_parser import createParser
|
from lib.hachoir_parser import createParser
|
||||||
from sickbeard.name_parser.parser import NameParser, InvalidNameException
|
from sickbeard.name_parser.parser import NameParser, InvalidNameException
|
||||||
from sickbeard.common import Quality, Overview
|
from sickbeard.common import Quality
|
||||||
|
|
||||||
class GenericProvider:
|
class GenericProvider:
|
||||||
NZB = "nzb"
|
NZB = "nzb"
|
||||||
|
@ -54,8 +48,8 @@ class GenericProvider:
|
||||||
self.providerType = None
|
self.providerType = None
|
||||||
self.name = name
|
self.name = name
|
||||||
self.url = ''
|
self.url = ''
|
||||||
self.session = None
|
|
||||||
|
|
||||||
|
self.show = None
|
||||||
self.supportsBacklog = False
|
self.supportsBacklog = False
|
||||||
|
|
||||||
self.cache = tvcache.TVCache(self)
|
self.cache = tvcache.TVCache(self)
|
||||||
|
@ -64,6 +58,7 @@ class GenericProvider:
|
||||||
self.session.verify = False
|
self.session.verify = False
|
||||||
self.session.headers.update({'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'})
|
self.session.headers.update({'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'})
|
||||||
|
|
||||||
|
|
||||||
def getID(self):
|
def getID(self):
|
||||||
return GenericProvider.makeID(self.name)
|
return GenericProvider.makeID(self.name)
|
||||||
|
|
||||||
|
@ -225,10 +220,10 @@ class GenericProvider:
|
||||||
def _doSearch(self, search_params, show=None, age=None):
|
def _doSearch(self, search_params, show=None, age=None):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_title_and_url(self, item):
|
def _get_title_and_url(self, item):
|
||||||
|
@ -255,40 +250,24 @@ class GenericProvider:
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
self._checkAuth()
|
self._checkAuth()
|
||||||
|
self.show = show
|
||||||
|
|
||||||
regexMode = 0
|
regexMode = 0
|
||||||
if show.sports:
|
if show.sports:
|
||||||
regexMode = 1
|
regexMode = 2
|
||||||
|
|
||||||
# update cache
|
|
||||||
self.cache.updateCache()
|
|
||||||
|
|
||||||
for ep_obj in ep_objs:
|
for ep_obj in ep_objs:
|
||||||
# get scene season/episode info
|
if show.sports:
|
||||||
scene_season = ep_obj.scene_season
|
logger.log(
|
||||||
scene_episode = ep_obj.scene_episode
|
u'Searching "%s" for "%s" as "%s"' % (self.name, ep_obj.prettyName(), ep_obj.sports_prettyName()))
|
||||||
if show.air_by_date or show.sports:
|
else:
|
||||||
scene_episode = ep_obj.airdate
|
logger.log(u'Searching "%s" for "%s" as "%s"' % (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
||||||
|
|
||||||
if not seasonSearch:
|
|
||||||
logger.log(u'Searching "%s" for "%s" as "%s"'
|
|
||||||
% (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
|
||||||
|
|
||||||
results = self.cache.searchCache(ep_obj, manualSearch)
|
|
||||||
logger.log(u"Cache results: " + str(results), logger.DEBUG)
|
|
||||||
logger.log(u"manualSearch: " + str(manualSearch), logger.DEBUG)
|
|
||||||
|
|
||||||
# if we got some results then use them no matter what.
|
|
||||||
# OR
|
|
||||||
# return anyway unless we're doing a manual search
|
|
||||||
if results:
|
|
||||||
return results
|
|
||||||
|
|
||||||
if seasonSearch:
|
if seasonSearch:
|
||||||
for curString in self._get_season_search_strings(show, scene_season, scene_episode):
|
for curString in self._get_season_search_strings(ep_obj.scene_season, ep_obj.scene_episode):
|
||||||
itemList += self._doSearch(curString, show=show)
|
itemList += self._doSearch(curString, show=show)
|
||||||
else:
|
else:
|
||||||
for curString in self._get_episode_search_strings(show, scene_season, scene_episode):
|
for curString in self._get_episode_search_strings(ep_obj.scene_season, ep_obj.scene_episode):
|
||||||
itemList += self._doSearch(curString, show=show)
|
itemList += self._doSearch(curString, show=show)
|
||||||
|
|
||||||
for item in itemList:
|
for item in itemList:
|
||||||
|
|
|
@ -74,8 +74,8 @@ class HDBitsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
# gather all episodes for season and then pick out the wanted episodes and compare to determin if we want whole season or just a few episodes
|
# gather all episodes for season and then pick out the wanted episodes and compare to determin if we want whole season or just a few episodes
|
||||||
if episode is None:
|
if episode is None:
|
||||||
seasonEps = show.getAllEpisodes(season)
|
seasonEps = self.show.getAllEpisodes(season)
|
||||||
wantedEps = [x for x in seasonEps if show.getOverview(x.status) in (Overview.WANTED, Overview.QUAL)]
|
wantedEps = [x for x in seasonEps if self.show.getOverview(x.status) in (Overview.WANTED, Overview.QUAL)]
|
||||||
else:
|
else:
|
||||||
wantedEps = [show.getEpisode(season, episode)]
|
wantedEps = [show.getEpisode(season, episode)]
|
||||||
|
|
||||||
|
|
|
@ -110,39 +110,37 @@ class HDTorrentsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode}
|
'episodenumber': episode}
|
||||||
|
@ -177,7 +175,7 @@ class HDTorrentsProvider(generic.TorrentProvider):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Remove HDTorrents NEW list
|
# Remove HDTorrents NEW list
|
||||||
split_data = data.partition('<!-- Show New Torrents After Last Visit -->\n\n\n\n')
|
split_data = data.partition('<!-- show New Torrents After Last Visit -->\n\n\n\n')
|
||||||
data = split_data[2]
|
data = split_data[2]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -307,18 +305,13 @@ class HDTorrentsProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
episode = curEp.scene_episode
|
|
||||||
if curShow.air_by_date or curShow.sports:
|
|
||||||
episode = curEp.airdate
|
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -92,40 +92,38 @@ class IPTorrentsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
if show.sports:
|
if self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode} + ' %s' % add_string
|
'episodenumber': episode} + ' %s' % add_string
|
||||||
|
@ -256,12 +254,12 @@ class IPTorrentsProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
searchString = self._get_episode_search_strings(curShow, curEp.scene_season, curEp.scene_episode, curShow.air_by_date or curShow.sports, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, curshow.air_by_date or curshow.sports, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -164,46 +164,36 @@ class KATProvider(generic.TorrentProvider):
|
||||||
logger.log(u"Failed parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR)
|
logger.log(u"Failed parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR)
|
||||||
|
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
|
|
||||||
if not show:
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
return []
|
ep_string = show_name + ' S%02d' % int(season) + ' -S%02d' % int(season) + 'E' + ' category:tv' #1) showName SXX -SXXE
|
||||||
|
|
||||||
self.show = show
|
|
||||||
|
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
|
||||||
ep_string = show_name + ' S%02d' % int(season) + ' -S%02d' % int(season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE
|
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
ep_string = show_name + ' Season ' + str(season) + ' -Ep*' + ' category:tv' #2) ShowName Season X
|
ep_string = show_name + ' Season ' + str(season) + ' -Ep*' + ' category:tv' #2) showName Season X
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not show:
|
if self.show.air_by_date:
|
||||||
return []
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
|
|
||||||
self.show = show
|
|
||||||
|
|
||||||
if show.air_by_date:
|
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
|
||||||
|
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-','|') + '|' + \
|
str(episode).replace('-','|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
if show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode} + '|' + \
|
'episodenumber': episode} + '|' + \
|
||||||
|
@ -389,18 +379,13 @@ class KATProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
episode = curEp.scene_episode
|
|
||||||
if curShow.air_by_date or curShow.sports:
|
|
||||||
episode = curEp.airdate
|
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -251,11 +251,11 @@ class NewzbinProvider(generic.NZBProvider):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSearchString(show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _doSearch(self, searchStr, show=None, age=None):
|
def _doSearch(self, searchStr, show=None, age=None):
|
||||||
|
|
||||||
|
|
|
@ -80,15 +80,12 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
def isEnabled(self):
|
def isEnabled(self):
|
||||||
return self.enabled
|
return self.enabled
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return [{}]
|
|
||||||
|
|
||||||
to_return = []
|
to_return = []
|
||||||
|
|
||||||
# add new query strings for exceptions
|
# add new query strings for exceptions
|
||||||
name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid) + [show.name]
|
name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name]
|
||||||
for cur_exception in name_exceptions:
|
for cur_exception in name_exceptions:
|
||||||
|
|
||||||
cur_params = {}
|
cur_params = {}
|
||||||
|
@ -100,13 +97,13 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
cur_params['season'] = str(season)
|
cur_params['season'] = str(season)
|
||||||
|
|
||||||
# episode
|
# episode
|
||||||
cur_params['episode'] = self._get_episode_search_strings(show, season, episode)[0]['ep']
|
cur_params['episode'] = self._get_episode_search_strings(season, episode)[0]['ep']
|
||||||
|
|
||||||
to_return.append(cur_params)
|
to_return.append(cur_params)
|
||||||
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
|
@ -114,14 +111,14 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
return [params]
|
return [params]
|
||||||
|
|
||||||
# search
|
# search
|
||||||
params['q'] = helpers.sanitizeSceneName(show.name)
|
params['q'] = helpers.sanitizeSceneName(self.show.name)
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
date_str = str(episode)
|
date_str = str(episode)
|
||||||
|
|
||||||
params['season'] = date_str.partition('-')[0]
|
params['season'] = date_str.partition('-')[0]
|
||||||
params['ep'] = date_str.partition('-')[2].replace('-', '/')
|
params['ep'] = date_str.partition('-')[2].replace('-', '/')
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
date_str = str(episode)
|
date_str = str(episode)
|
||||||
|
|
||||||
params['season'] = date_str.partition('-')[0]
|
params['season'] = date_str.partition('-')[0]
|
||||||
|
@ -136,11 +133,11 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
if 'q' in params:
|
if 'q' in params:
|
||||||
|
|
||||||
# add new query strings for exceptions
|
# add new query strings for exceptions
|
||||||
name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid)
|
name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid)
|
||||||
for cur_exception in name_exceptions:
|
for cur_exception in name_exceptions:
|
||||||
|
|
||||||
# don't add duplicates
|
# don't add duplicates
|
||||||
if cur_exception == show.name:
|
if cur_exception == self.show.name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cur_return = params.copy()
|
cur_return = params.copy()
|
||||||
|
|
|
@ -131,41 +131,38 @@ class NextGenProvider(generic.TorrentProvider):
|
||||||
logger.log(u'Failed to login:' + str(error), logger.ERROR)
|
logger.log(u'Failed to login:' + str(error), logger.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode}
|
'episodenumber': episode}
|
||||||
|
@ -305,12 +302,12 @@ class NextGenProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
searchString = self._get_episode_search_strings(curShow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -58,13 +58,13 @@ class NyaaProvider(generic.TorrentProvider):
|
||||||
results = generic.TorrentProvider.getSearchResults(self, show, season, ep_objs, seasonSearch, manualSearch)
|
results = generic.TorrentProvider.getSearchResults(self, show, season, ep_objs, seasonSearch, manualSearch)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
names = []
|
names = []
|
||||||
names.extend(show_name_helpers.makeSceneShowSearchStrings(show))
|
names.extend(show_name_helpers.makeSceneshowSearchStrings(self.show))
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return self._get_season_search_strings(show, season, episode)
|
return self._get_season_search_strings(season, episode)
|
||||||
|
|
||||||
def _doSearch(self, search_string, show=None, age=None):
|
def _doSearch(self, search_string, show=None, age=None):
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,11 @@ class NZBsProvider(generic.NZBProvider):
|
||||||
if sickbeard.NZBS_UID in (None, "") or sickbeard.NZBS_HASH in (None, ""):
|
if sickbeard.NZBS_UID in (None, "") or sickbeard.NZBS_HASH in (None, ""):
|
||||||
raise exceptions.AuthException("NZBs.org authentication details are empty, check your config")
|
raise exceptions.AuthException("NZBs.org authentication details are empty, check your config")
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSearchString(show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _doSearch(self, curString, show=None, age=None):
|
def _doSearch(self, curString, show=None, age=None):
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,11 @@ class NZBsRUSProvider(generic.NZBProvider):
|
||||||
if sickbeard.NZBSRUS_UID in (None, "") or sickbeard.NZBSRUS_HASH in (None, ""):
|
if sickbeard.NZBSRUS_UID in (None, "") or sickbeard.NZBSRUS_HASH in (None, ""):
|
||||||
raise exceptions.AuthException("NZBs'R'US authentication details are empty, check your config")
|
raise exceptions.AuthException("NZBs'R'US authentication details are empty, check your config")
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSearchString(show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _doSearch(self, search, show=None, age=None):
|
def _doSearch(self, search, show=None, age=None):
|
||||||
params = {'uid': sickbeard.NZBSRUS_UID,
|
params = {'uid': sickbeard.NZBSRUS_UID,
|
||||||
|
|
|
@ -85,11 +85,11 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
return [x for x in show_name_helpers.makeSceneSeasonSearchString(show, season, episode)]
|
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
return [x for x in show_name_helpers.makeSceneSearchString(show, season, episode)]
|
return [x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
||||||
|
|
||||||
def _get_title_and_url(self, item):
|
def _get_title_and_url(self, item):
|
||||||
return (item['release'], item['getnzb'])
|
return (item['release'], item['getnzb'])
|
||||||
|
|
|
@ -72,44 +72,41 @@ class PublicHDProvider(generic.TorrentProvider):
|
||||||
quality = Quality.sceneQuality(item[0])
|
quality = Quality.sceneQuality(item[0])
|
||||||
return quality
|
return quality
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX -SXXE
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX -SXXE
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
ep_string = show_name + ' Season ' + str(season) #2) ShowName Season X
|
ep_string = show_name + ' Season ' + str(season) #2) showName Season X
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode}
|
'episodenumber': episode}
|
||||||
|
@ -277,18 +274,18 @@ class PublicHDProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
season = curEp.scene_season
|
||||||
episode = curEp.scene_episode
|
episode = curEp.scene_episode
|
||||||
if curShow.air_by_date or curShow.sports:
|
if curshow.air_by_date or curshow.sports:
|
||||||
episode = curEp.airdate
|
episode = curEp.airdate
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -99,41 +99,38 @@ class SCCProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode}
|
'episodenumber': episode}
|
||||||
|
@ -279,18 +276,18 @@ class SCCProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
season = curEp.scene_season
|
||||||
episode = curEp.scene_episode
|
episode = curEp.scene_episode
|
||||||
if curShow.air_by_date or curShow.sports:
|
if curshow.air_by_date or curshow.sports:
|
||||||
episode = curEp.airdate
|
episode = curEp.airdate
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -90,43 +90,40 @@ class SpeedCDProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
#If Every episode in Season is a wanted Episode then search for Season first
|
#If Every episode in Season is a wanted Episode then search for Season first
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name +' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name +' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
#Building the search string with the episodes we need
|
#Building the search string with the episodes we need
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) +' '+ \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) +' '+ \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season, 'episodenumber': episode}
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season, 'episodenumber': episode}
|
||||||
|
|
||||||
|
@ -235,18 +232,18 @@ class SpeedCDProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
season = curEp.scene_season
|
||||||
episode = curEp.scene_episode
|
episode = curEp.scene_episode
|
||||||
if curShow.air_by_date or curShow.sports:
|
if curshow.air_by_date or curshow.sports:
|
||||||
episode = curEp.airdate
|
episode = curEp.airdate
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode,add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curshow, season, episode,add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -169,48 +169,38 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
self.show = show
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
ep_string = show_name + ' Season ' + str(season) + ' -Ep*' #2) ShowName Season X
|
ep_string = show_name + ' Season ' + str(season) + ' -Ep*' #2) showName Season X
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not show:
|
if self.show.air_by_date:
|
||||||
return []
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
|
|
||||||
self.show = show
|
|
||||||
|
|
||||||
if show.air_by_date:
|
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode} + '|' + \
|
'episodenumber': episode} + '|' + \
|
||||||
|
@ -382,18 +372,13 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
episode = curEp.scene_episode
|
|
||||||
if curShow.air_by_date or curShow.sports:
|
|
||||||
episode = curEp.airdate
|
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -112,41 +112,38 @@ class TorrentDayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
if show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode}
|
'episodenumber': episode}
|
||||||
|
@ -162,6 +159,9 @@ class TorrentDayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
freeleech = '&free=on' if sickbeard.TORRENTDAY_FREELEECH else ''
|
freeleech = '&free=on' if sickbeard.TORRENTDAY_FREELEECH else ''
|
||||||
|
|
||||||
|
if not self.session:
|
||||||
|
self._doLogin()
|
||||||
|
|
||||||
if not self._doLogin():
|
if not self._doLogin():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -251,18 +251,18 @@ class TorrentDayProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
season = curEp.scene_season
|
||||||
episode = curEp.scene_episode
|
episode = curEp.scene_episode
|
||||||
if curShow.air_by_date or curShow.sports:
|
if curshow.air_by_date or curshow.sports:
|
||||||
episode = curEp.airdate
|
episode = curEp.airdate
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -94,41 +94,38 @@ class TorrentLeechProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, show, season, episode):
|
def _get_season_search_strings(self, season, episode):
|
||||||
|
|
||||||
if not show:
|
|
||||||
return []
|
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) ShowName SXX
|
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(show, season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, show, season, episode, add_string=''):
|
def _get_episode_search_strings(self, season, episode, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not episode:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
if show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(episode).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
episode.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
||||||
'episodenumber': episode}
|
'episodenumber': episode}
|
||||||
|
@ -255,18 +252,13 @@ class TorrentLeechProvider(generic.TorrentProvider):
|
||||||
if not sqlResults:
|
if not sqlResults:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlShow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
curShow = helpers.findCertainShow(sickbeard.showList, int(sqlShow["showid"]))
|
curshow = helpers.findCertainshow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curShow.getEpisode(int(sqlShow["season"]), int(sqlShow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
season = curEp.scene_season
|
searchString = self._get_episode_search_strings(curshow, curEp.scene_season, curEp.scene_episode, add_string='PROPER|REPACK')
|
||||||
episode = curEp.scene_episode
|
|
||||||
if curShow.air_by_date or curShow.sports:
|
|
||||||
episode = curEp.airdate
|
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curShow, season, episode, add_string='PROPER|REPACK')
|
for item in self._doSearch(searchString[0], show=curshow):
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curShow):
|
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@ from sickbeard import encodingKludge as ek
|
||||||
from sickbeard import providers
|
from sickbeard import providers
|
||||||
from sickbeard import failed_history
|
from sickbeard import failed_history
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
from sickbeard.providers.generic import GenericProvider
|
from sickbeard.providers.generic import GenericProvider, tvcache
|
||||||
|
|
||||||
|
|
||||||
def _downloadResult(result):
|
def _downloadResult(result):
|
||||||
"""
|
"""
|
||||||
|
@ -351,7 +350,7 @@ def isFirstBestMatch(result):
|
||||||
|
|
||||||
def searchProviders(show, season, episode=None, manualSearch=False):
|
def searchProviders(show, season, episode=None, manualSearch=False):
|
||||||
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
|
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
|
||||||
|
curResults = {}
|
||||||
foundResults = {}
|
foundResults = {}
|
||||||
|
|
||||||
didSearch = False
|
didSearch = False
|
||||||
|
@ -367,35 +366,56 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
||||||
ep_obj = show.getEpisode(season, episode)
|
ep_obj = show.getEpisode(season, episode)
|
||||||
wantedEps = [ep_obj]
|
wantedEps = [ep_obj]
|
||||||
|
|
||||||
for curProvider in providers.sortedProviderList():
|
|
||||||
|
|
||||||
|
|
||||||
|
for curProvider in providers.sortedProviderList():
|
||||||
if not curProvider.isActive():
|
if not curProvider.isActive():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
# update cache
|
||||||
curResults = curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch)
|
if manualSearch:
|
||||||
|
curProvider.cache.updateCache()
|
||||||
|
|
||||||
# make a list of all the results for this provider
|
# search cache first for wanted episodes
|
||||||
for curEp in curResults:
|
for ep_obj in wantedEps:
|
||||||
|
curResults.update(curProvider.cache.searchCache(ep_obj, manualSearch))
|
||||||
|
|
||||||
# skip non-tv crap
|
# did we find our results ?
|
||||||
curResults[curEp] = filter(
|
if curResults:
|
||||||
lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name,show),curResults[curEp])
|
logger.log(u"Cache results: " + str(curResults), logger.DEBUG)
|
||||||
|
didSearch = True
|
||||||
|
break
|
||||||
|
|
||||||
if curEp in foundResults:
|
if not curResults:
|
||||||
foundResults[curEp] += curResults[curEp]
|
for curProvider in providers.sortedProviderList():
|
||||||
else:
|
if not curProvider.isActive():
|
||||||
foundResults[curEp] = curResults[curEp]
|
continue
|
||||||
|
|
||||||
except exceptions.AuthException, e:
|
try:
|
||||||
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
|
if not curResults:
|
||||||
continue
|
curResults = curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch)
|
||||||
except Exception, e:
|
|
||||||
logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
|
|
||||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
|
||||||
continue
|
|
||||||
|
|
||||||
didSearch = True
|
# make a list of all the results for this provider
|
||||||
|
for curEp in curResults:
|
||||||
|
|
||||||
|
# skip non-tv crap
|
||||||
|
curResults[curEp] = filter(
|
||||||
|
lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name,show),curResults[curEp])
|
||||||
|
|
||||||
|
if curEp in foundResults:
|
||||||
|
foundResults[curEp] += curResults[curEp]
|
||||||
|
else:
|
||||||
|
foundResults[curEp] = curResults[curEp]
|
||||||
|
|
||||||
|
except exceptions.AuthException, e:
|
||||||
|
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
|
||||||
|
continue
|
||||||
|
except Exception, e:
|
||||||
|
logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
|
||||||
|
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||||
|
continue
|
||||||
|
|
||||||
|
didSearch = True
|
||||||
|
|
||||||
if not didSearch:
|
if not didSearch:
|
||||||
logger.log(u"No NZB/Torrent providers found or enabled in the sickbeard config. Please check your settings.",
|
logger.log(u"No NZB/Torrent providers found or enabled in the sickbeard config. Please check your settings.",
|
||||||
|
|
|
@ -1815,6 +1815,16 @@ class TVEpisode(object):
|
||||||
|
|
||||||
return self._format_pattern('%SN - %XMSx%0XME - %EN')
|
return self._format_pattern('%SN - %XMSx%0XME - %EN')
|
||||||
|
|
||||||
|
def sports_prettyName(self):
|
||||||
|
"""
|
||||||
|
Returns the name of this episode in a "pretty" human-readable format. Used for logging
|
||||||
|
and notifications and such.
|
||||||
|
|
||||||
|
Returns: A string representing the episode's name and season/ep numbers
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self._format_pattern('%SN - %A-D - %EN')
|
||||||
|
|
||||||
def _ep_name(self):
|
def _ep_name(self):
|
||||||
"""
|
"""
|
||||||
Returns the name of the episode to use during renaming. Combines the names of related episodes.
|
Returns the name of the episode to use during renaming. Combines the names of related episodes.
|
||||||
|
|
|
@ -183,175 +183,109 @@ class TVCache():
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _addCacheEntry(self, name, url, season=None, episodes=None, indexer_id=0, quality=None, extraNames=[]):
|
def _addCacheEntry(self, name, url):
|
||||||
|
|
||||||
myDB = self._getDB()
|
|
||||||
|
|
||||||
|
cacheDB = self._getDB()
|
||||||
parse_result = None
|
parse_result = None
|
||||||
|
from_cache = False
|
||||||
|
indexer_id = None
|
||||||
|
|
||||||
# if we don't have complete info then parse the filename to get it
|
# if we don't have complete info then parse the filename to get it
|
||||||
for curName in [name] + extraNames:
|
while(True):
|
||||||
try:
|
try:
|
||||||
myParser = NameParser()
|
myParser = NameParser()
|
||||||
parse_result = myParser.parse(curName)
|
parse_result = myParser.parse(name)
|
||||||
except InvalidNameException:
|
except InvalidNameException:
|
||||||
logger.log(u"Unable to parse the filename " + curName + " into a valid episode", logger.DEBUG)
|
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
|
||||||
continue
|
return None
|
||||||
|
|
||||||
if not parse_result:
|
if not parse_result:
|
||||||
logger.log(u"Giving up because I'm unable to parse this name: " + name, logger.DEBUG)
|
logger.log(u"Giving up because I'm unable to parse this name: " + name, logger.DEBUG)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not parse_result.series_name:
|
if not parse_result.series_name:
|
||||||
logger.log(u"No series name retrieved from " + name + ", unable to cache it", logger.DEBUG)
|
logger.log(u"No series name retrieved from " + name + ", unable to cache it", logger.DEBUG)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
indexer_lang = None
|
|
||||||
|
|
||||||
if indexer_id:
|
|
||||||
# if we have only the indexer_id, use the database
|
|
||||||
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
|
|
||||||
if showObj:
|
|
||||||
self.indexer = int(showObj.indexer)
|
|
||||||
indexer_lang = showObj.lang
|
|
||||||
else:
|
|
||||||
logger.log(u"We were given a Indexer ID " + str(indexer_id) + " but it doesn't match a show we have in our list, so leaving indexer_id empty",logger.DEBUG)
|
|
||||||
indexer_id = 0
|
|
||||||
|
|
||||||
# if no indexerID then fill out as much info as possible by searching the show name
|
|
||||||
if not indexer_id:
|
|
||||||
from_cache = False
|
|
||||||
|
|
||||||
# check the name cache and see if we already know what show this is
|
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Checking the cache for Indexer ID of " + parse_result.series_name,
|
u"Checking the cahe for show:" + str(parse_result.series_name),
|
||||||
logger.DEBUG)
|
logger.DEBUG)
|
||||||
|
|
||||||
# remember if the cache lookup worked or not so we know whether we should bother updating it later
|
# remember if the cache lookup worked or not so we know whether we should bother updating it later
|
||||||
indexer_id = name_cache.retrieveNameFromCache(parse_result.series_name)
|
cache_id = name_cache.retrieveNameFromCache(parse_result.series_name)
|
||||||
if indexer_id:
|
if cache_id:
|
||||||
logger.log(u"Cache lookup found " + repr(indexer_id) + ", using that", logger.DEBUG)
|
logger.log(u"Cache lookup found Indexer ID:" + repr(indexer_id) + ", using that for " + parse_result.series_name, logger.DEBUG)
|
||||||
from_cache = True
|
from_cache = True
|
||||||
|
indexer_id = cache_id
|
||||||
|
break
|
||||||
|
|
||||||
# if the cache failed, try looking up the show name in the database
|
# if the cache failed, try looking up the show name in the database
|
||||||
if not indexer_id:
|
logger.log(
|
||||||
|
u"Checking the database for show:" + str(parse_result.series_name),
|
||||||
|
logger.DEBUG)
|
||||||
|
|
||||||
|
showResult = helpers.searchDBForShow(parse_result.series_name)
|
||||||
|
if showResult:
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Checking the database for Indexer ID of " + str(parse_result.series_name),
|
u"Database lookup found Indexer ID:" + str(showResult[1]) + ", using that for " + parse_result.series_name, logger.DEBUG)
|
||||||
logger.DEBUG)
|
indexer_id = showResult[1]
|
||||||
|
break
|
||||||
|
|
||||||
showResult = helpers.searchDBForShow(parse_result.series_name)
|
# if we didn't find a Indexer ID return None
|
||||||
if showResult:
|
if not indexer_id:
|
||||||
logger.log(
|
return None
|
||||||
u"" + parse_result.series_name + " was found to be show " + showResult[2] + " (" + str(
|
|
||||||
showResult[1]) + ") in our DB.", logger.DEBUG)
|
|
||||||
indexer_id = showResult[1]
|
|
||||||
|
|
||||||
# if the database failed, try looking up the show name from scene exceptions list
|
# if the show isn't in out database then return None
|
||||||
if not indexer_id:
|
try:showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
|
||||||
logger.log(
|
except:return None
|
||||||
u"Checking the scene exceptions list for Indexer ID of " + parse_result.series_name,
|
|
||||||
logger.DEBUG)
|
|
||||||
sceneResult = sickbeard.scene_exceptions.get_scene_exception_by_name(parse_result.series_name)
|
|
||||||
if sceneResult:
|
|
||||||
logger.log(
|
|
||||||
u"" + str(parse_result.series_name) + " was found in scene exceptions list with Indexer ID: " + str(sceneResult), logger.DEBUG)
|
|
||||||
indexer_id = sceneResult
|
|
||||||
|
|
||||||
# if the DB lookup fails then do a comprehensive regex search
|
|
||||||
if not indexer_id:
|
|
||||||
logger.log(
|
|
||||||
u"Checking the shows list for Indexer ID of " + str(parse_result.series_name),
|
|
||||||
logger.DEBUG)
|
|
||||||
for curShow in sickbeard.showList:
|
|
||||||
if show_name_helpers.isGoodResult(name, curShow, False):
|
|
||||||
logger.log(u"Successfully matched " + name + " to " + curShow.name + " from shows list",
|
|
||||||
logger.DEBUG)
|
|
||||||
indexer_id = curShow.indexerid
|
|
||||||
indexer_lang = curShow.lang
|
|
||||||
break
|
|
||||||
|
|
||||||
# if the database failed, try looking up the show name from scene exceptions list
|
|
||||||
if not indexer_id:
|
|
||||||
logger.log(
|
|
||||||
u"Checking Indexers for Indexer ID of " + parse_result.series_name,
|
|
||||||
logger.DEBUG)
|
|
||||||
|
|
||||||
# check indexers
|
|
||||||
try:indexerResult = helpers.searchIndexerForShowID(parse_result.series_name)
|
|
||||||
except:indexerResult = None
|
|
||||||
|
|
||||||
if indexerResult:
|
|
||||||
logger.log(
|
|
||||||
u"" + str(parse_result.series_name) + " was found on " + str(sickbeard.indexerApi(indexerResult[0]).name) + " with Indexer ID: " + str(indexerResult[1]), logger.DEBUG)
|
|
||||||
indexer_id = indexerResult[1]
|
|
||||||
|
|
||||||
# if indexer_id was anything but None (0 or a number) then
|
|
||||||
if not from_cache:
|
|
||||||
name_cache.addNameToCache(parse_result.series_name, indexer_id)
|
|
||||||
|
|
||||||
# if we came out with indexer_id = None it means we couldn't figure it out at all, just use 0 for that
|
|
||||||
if indexer_id == None:
|
|
||||||
indexer_id = 0
|
|
||||||
|
|
||||||
# if we found the show then retrieve the show object
|
|
||||||
if indexer_id:
|
|
||||||
try:
|
|
||||||
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
|
|
||||||
except (MultipleShowObjectsException):
|
|
||||||
showObj = None
|
|
||||||
if showObj:
|
|
||||||
self.indexer = int(showObj.indexer)
|
|
||||||
indexer_lang = showObj.lang
|
|
||||||
|
|
||||||
# if we weren't provided with season/episode information then get it from the name that we parsed
|
# if we weren't provided with season/episode information then get it from the name that we parsed
|
||||||
if not season:
|
season = None
|
||||||
season = parse_result.season_number if parse_result.season_number != None else 1
|
episodes = None
|
||||||
if not episodes:
|
myDB = db.DBConnection()
|
||||||
|
if parse_result.air_by_date:
|
||||||
|
sql_results = myDB.select("SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
|
||||||
|
[showObj.indexerid, parse_result.air_date.toordinal()])
|
||||||
|
if sql_results > 0:
|
||||||
|
season = int(sql_results[0]["season"])
|
||||||
|
episodes = [int(sql_results[0]["episode"])]
|
||||||
|
elif parse_result.sports:
|
||||||
|
sql_results = myDB.select("SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
|
||||||
|
[showObj.indexerid, parse_result.sports_date.toordinal()])
|
||||||
|
if sql_results > 0:
|
||||||
|
season = int(sql_results[0]["season"])
|
||||||
|
episodes = [int(sql_results[0]["episode"])]
|
||||||
|
else:
|
||||||
|
season = parse_result.season_number
|
||||||
episodes = parse_result.episode_numbers
|
episodes = parse_result.episode_numbers
|
||||||
|
|
||||||
# if we have an air-by-date show then get the real season/episode numbers
|
if not (season and episodes):
|
||||||
if (parse_result.air_by_date or parse_result.sports) and indexer_id:
|
return None
|
||||||
try:
|
|
||||||
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
|
|
||||||
if not (indexer_lang == "" or indexer_lang == "en" or indexer_lang == None):
|
|
||||||
lINDEXER_API_PARMS['language'] = indexer_lang
|
|
||||||
|
|
||||||
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
|
# convert scene numbered releases before storing to cache
|
||||||
|
convertedEps = {}
|
||||||
epObj = None
|
for curEp in episodes:
|
||||||
if parse_result.air_by_date:
|
epObj = showObj.getEpisode(season, curEp, sceneConvert=True)
|
||||||
epObj = t[indexer_id].airedOn(parse_result.air_date)[0]
|
if not epObj:
|
||||||
elif parse_result.sports:
|
|
||||||
epObj = t[indexer_id].airedOn(parse_result.sports_date)[0]
|
|
||||||
|
|
||||||
if epObj is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
season = int(epObj["seasonnumber"])
|
|
||||||
episodes = [int(epObj["episodenumber"])]
|
|
||||||
except sickbeard.indexer_episodenotfound:
|
|
||||||
logger.log(u"Unable to find episode with date " + str(
|
|
||||||
parse_result.air_date) + " for show " + parse_result.series_name + ", skipping", logger.WARNING)
|
|
||||||
return None
|
return None
|
||||||
except sickbeard.indexer_error, e:
|
if not epObj.season in convertedEps:
|
||||||
logger.log(u"Unable to contact " + sickbeard.indexerApi(self.indexer).name + ": " + ex(e),
|
convertedEps[epObj.season] = []
|
||||||
logger.WARNING)
|
convertedEps[epObj.season].append(epObj.episode)
|
||||||
return None
|
|
||||||
|
|
||||||
episodeText = "|" + "|".join(map(str, episodes)) + "|"
|
|
||||||
|
|
||||||
# get the current timestamp
|
# get the current timestamp
|
||||||
curTimestamp = int(time.mktime(datetime.datetime.today().timetuple()))
|
curTimestamp = int(time.mktime(datetime.datetime.today().timetuple()))
|
||||||
|
|
||||||
if not quality:
|
# get quality of release
|
||||||
quality = Quality.sceneQuality(name)
|
quality = Quality.sceneQuality(name)
|
||||||
|
|
||||||
if not isinstance(name, unicode):
|
if not isinstance(name, unicode):
|
||||||
name = unicode(name, 'utf-8')
|
name = unicode(name, 'utf-8')
|
||||||
|
|
||||||
myDB.action(
|
for season, episodes in convertedEps.items():
|
||||||
"INSERT INTO [" + self.providerID + "] (name, season, episodes, indexerid, url, time, quality) VALUES (?,?,?,?,?,?,?)",
|
episodeText = "|" + "|".join(map(str, episodes)) + "|"
|
||||||
[name, season, episodeText, indexer_id, url, curTimestamp, quality])
|
cacheDB.action(
|
||||||
|
"INSERT INTO [" + self.providerID + "] (name, season, episodes, indexerid, url, time, quality) VALUES (?,?,?,?,?,?,?)",
|
||||||
|
[name, season, episodeText, indexer_id, url, curTimestamp, quality])
|
||||||
|
|
||||||
|
|
||||||
def searchCache(self, episode, manualSearch=False):
|
def searchCache(self, episode, manualSearch=False):
|
||||||
|
@ -415,35 +349,34 @@ class TVCache():
|
||||||
curEp = int(curEp)
|
curEp = int(curEp)
|
||||||
curQuality = int(curResult["quality"])
|
curQuality = int(curResult["quality"])
|
||||||
|
|
||||||
# items stored in cache are scene numbered, convert before lookups
|
|
||||||
epObj = showObj.getEpisode(curSeason, curEp, sceneConvert=True)
|
|
||||||
|
|
||||||
# if the show says we want that episode then add it to the list
|
# if the show says we want that episode then add it to the list
|
||||||
if not showObj.wantEpisode(epObj.season, epObj.episode, curQuality, manualSearch):
|
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch):
|
||||||
logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " +
|
logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " +
|
||||||
Quality.qualityStrings[curQuality], logger.DEBUG)
|
Quality.qualityStrings[curQuality], logger.DEBUG)
|
||||||
else:
|
else:
|
||||||
|
epObj = None
|
||||||
if episode:
|
if episode:
|
||||||
epObj = episode
|
epObj = episode
|
||||||
|
|
||||||
# build a result object
|
if epObj:
|
||||||
title = curResult["name"]
|
# build a result object
|
||||||
url = curResult["url"]
|
title = curResult["name"]
|
||||||
|
url = curResult["url"]
|
||||||
|
|
||||||
logger.log(u"Found result " + title + " at " + url)
|
logger.log(u"Found result " + title + " at " + url)
|
||||||
|
|
||||||
result = self.provider.getResult([epObj])
|
result = self.provider.getResult([epObj])
|
||||||
result.url = url
|
result.url = url
|
||||||
result.name = title
|
result.name = title
|
||||||
result.quality = curQuality
|
result.quality = curQuality
|
||||||
result.content = self.provider.getURL(url) \
|
result.content = self.provider.getURL(url) \
|
||||||
if self.provider.providerType == sickbeard.providers.generic.GenericProvider.TORRENT \
|
if self.provider.providerType == sickbeard.providers.generic.GenericProvider.TORRENT \
|
||||||
and not url.startswith('magnet') else None
|
and not url.startswith('magnet') else None
|
||||||
|
|
||||||
# add it to the list
|
# add it to the list
|
||||||
if epObj not in neededEps:
|
if epObj not in neededEps:
|
||||||
neededEps[epObj] = [result]
|
neededEps[epObj] = [result]
|
||||||
else:
|
else:
|
||||||
neededEps[epObj].append(result)
|
neededEps[epObj].append(result)
|
||||||
|
|
||||||
return neededEps
|
return neededEps
|
||||||
|
|
|
@ -2064,7 +2064,7 @@ class NewHomeAddShows:
|
||||||
# default to TVDB if indexer was not detected
|
# default to TVDB if indexer was not detected
|
||||||
if show_name and (indexer is None or indexer_id is None):
|
if show_name and (indexer is None or indexer_id is None):
|
||||||
for idx in sickbeard.indexerApi().indexers:
|
for idx in sickbeard.indexerApi().indexers:
|
||||||
found_info = helpers.searchIndexerForShowID(show_name, idx, indexer_id)
|
found_info = helpers.searchIndexerForShowID(show_name, idx, indexer_id, ui=classes.ShowListUI)
|
||||||
if found_info:
|
if found_info:
|
||||||
# set indexer and indexer_id from found info
|
# set indexer and indexer_id from found info
|
||||||
if indexer is None:
|
if indexer is None:
|
||||||
|
@ -3414,12 +3414,6 @@ class Home:
|
||||||
if isinstance(ep_obj, str):
|
if isinstance(ep_obj, str):
|
||||||
return json.dumps({'result': 'failure'})
|
return json.dumps({'result': 'failure'})
|
||||||
|
|
||||||
# figure out what segment the episode is in and remember it so we can backlog it
|
|
||||||
if ep_obj.show.air_by_date or ep_obj.show.sports:
|
|
||||||
segment = str(ep_obj.airdate)[:7]
|
|
||||||
else:
|
|
||||||
segment = ep_obj.season
|
|
||||||
|
|
||||||
# make a queue item for it and put it on the queue
|
# make a queue item for it and put it on the queue
|
||||||
ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, {ep_obj.season: ep_obj.episode})
|
ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, {ep_obj.season: ep_obj.episode})
|
||||||
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
|
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
|
||||||
|
@ -3444,28 +3438,6 @@ class Home:
|
||||||
|
|
||||||
return json.dumps({'result': 'failure'})
|
return json.dumps({'result': 'failure'})
|
||||||
|
|
||||||
|
|
||||||
# try:
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# ui.notifications.message('Info', pp.log)
|
|
||||||
# except exceptions.FailedHistoryNotFoundException:
|
|
||||||
# ui.notifications.error('Not Found Error', 'Couldn\'t find release in history. (Has it been over 30 days?)\n'
|
|
||||||
# 'Can\'t mark it as bad.')
|
|
||||||
# return json.dumps({'result': 'failure'})
|
|
||||||
# except exceptions.FailedHistoryMultiSnatchException:
|
|
||||||
# ui.notifications.error('Multi-Snatch Error', 'The same episode was snatched again before the first one was done.\n'
|
|
||||||
# 'Please cancel any downloads of this episode and then set it back to wanted.\n Can\'t continue.')
|
|
||||||
# return json.dumps({'result': 'failure'})
|
|
||||||
# except exceptions.FailedProcessingFailed:
|
|
||||||
# ui.notifications.error('Processing Failed', pp.log)
|
|
||||||
# return json.dumps({'result': 'failure'})
|
|
||||||
# except Exception as e:
|
|
||||||
# ui.notifications.error('Unknown Error', 'Unknown exception: ' + str(e))
|
|
||||||
# return json.dumps({'result': 'failure'})
|
|
||||||
#
|
|
||||||
# return json.dumps({'result': 'success'})
|
|
||||||
|
|
||||||
class UI:
|
class UI:
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def add_message(self):
|
def add_message(self):
|
||||||
|
|
Loading…
Reference in a new issue