mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-06 19:38:01 -05:00
Fix for startup issue when using python 2.6
This commit is contained in:
parent
271afb8c5d
commit
3cefc5be86
@ -283,7 +283,7 @@ def makeDir(path):
|
|||||||
|
|
||||||
|
|
||||||
def searchDBForShow(regShowName):
|
def searchDBForShow(regShowName):
|
||||||
showNames = list({re.sub('[. -]', ' ', regShowName), regShowName})
|
showNames = list(set([re.sub('[. -]', ' ', regShowName), regShowName]))
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ def searchDBForShow(regShowName):
|
|||||||
return (int(sqlResults[0]["indexer"]), int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])
|
return (int(sqlResults[0]["indexer"]), int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])
|
||||||
|
|
||||||
def searchIndexerForShowID(regShowName, indexer=None, indexer_id=None, ui=None):
|
def searchIndexerForShowID(regShowName, indexer=None, indexer_id=None, ui=None):
|
||||||
showNames = list({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 i in sickbeard.indexerApi().indexers if not indexer else int(indexer or []):
|
for i in sickbeard.indexerApi().indexers if not indexer else int(indexer or []):
|
||||||
@ -942,7 +942,7 @@ def _check_against_names(name, show):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_show_by_name(name, useIndexer=False):
|
def get_show_by_name(name, checkExceptions=False, checkIndexers=False):
|
||||||
in_cache = False
|
in_cache = False
|
||||||
foundResult = None
|
foundResult = None
|
||||||
|
|
||||||
@ -952,9 +952,9 @@ def get_show_by_name(name, useIndexer=False):
|
|||||||
|
|
||||||
cacheResult = sickbeard.name_cache.retrieveNameFromCache(name)
|
cacheResult = sickbeard.name_cache.retrieveNameFromCache(name)
|
||||||
if cacheResult:
|
if cacheResult:
|
||||||
in_cache = True
|
|
||||||
foundResult = findCertainShow(sickbeard.showList, cacheResult)
|
foundResult = findCertainShow(sickbeard.showList, cacheResult)
|
||||||
if foundResult:
|
if foundResult:
|
||||||
|
in_cache = True
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Cache lookup found Indexer ID:" + repr(
|
u"Cache lookup found Indexer ID:" + repr(
|
||||||
foundResult.indexerid) + ", using that for " + name,
|
foundResult.indexerid) + ", using that for " + name,
|
||||||
@ -962,19 +962,7 @@ def get_show_by_name(name, useIndexer=False):
|
|||||||
|
|
||||||
if not foundResult:
|
if not foundResult:
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Checking the showlist for:" + str(name),
|
u"Checking the database for:" + str(name),
|
||||||
logger.DEBUG)
|
|
||||||
|
|
||||||
for show in sickbeard.showList:
|
|
||||||
if _check_against_names(name, show):
|
|
||||||
logger.log(
|
|
||||||
u"Showlist lookup found Indexer ID:" + str(show.indexerid) + ", using that for " + name,
|
|
||||||
logger.DEBUG)
|
|
||||||
foundResult = show
|
|
||||||
|
|
||||||
if not foundResult:
|
|
||||||
logger.log(
|
|
||||||
u"Checking the database for show:" + str(name),
|
|
||||||
logger.DEBUG)
|
logger.DEBUG)
|
||||||
|
|
||||||
dbResult = searchDBForShow(name)
|
dbResult = searchDBForShow(name)
|
||||||
@ -985,7 +973,20 @@ def get_show_by_name(name, useIndexer=False):
|
|||||||
u"Database lookup found Indexer ID:" + str(
|
u"Database lookup found Indexer ID:" + str(
|
||||||
foundResult.indexerid) + ", using that for " + name, logger.DEBUG)
|
foundResult.indexerid) + ", using that for " + name, logger.DEBUG)
|
||||||
|
|
||||||
if not foundResult and useIndexer:
|
if not foundResult and checkExceptions:
|
||||||
|
if not foundResult:
|
||||||
|
logger.log(
|
||||||
|
u"Checking the scene exceptions list for:" + str(name),
|
||||||
|
logger.DEBUG)
|
||||||
|
|
||||||
|
for show in sickbeard.showList:
|
||||||
|
if _check_against_names(name, show):
|
||||||
|
logger.log(
|
||||||
|
u"Scene exceptions lookup found Indexer ID:" + str(show.indexerid) + ", using that for " + name,
|
||||||
|
logger.DEBUG)
|
||||||
|
foundResult = show
|
||||||
|
|
||||||
|
if not foundResult and checkIndexers:
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Checking the Indexers for:" + str(name),
|
u"Checking the Indexers for:" + str(name),
|
||||||
logger.DEBUG)
|
logger.DEBUG)
|
||||||
@ -1005,7 +1006,7 @@ def get_show_by_name(name, useIndexer=False):
|
|||||||
foundResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
|
foundResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
|
||||||
if foundResult:
|
if foundResult:
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Indexer lookup found Indexer ID:" + str(
|
u"Indexers lookup found Indexer ID:" + str(
|
||||||
foundResult.indexerid) + ", using that for " + name, logger.DEBUG)
|
foundResult.indexerid) + ", using that for " + name, logger.DEBUG)
|
||||||
|
|
||||||
# add to name cache if we didn't get it from the cache
|
# add to name cache if we didn't get it from the cache
|
||||||
|
@ -361,34 +361,34 @@ class ParseResult(object):
|
|||||||
if len(self.episode_numbers) == 0: return self # need at least one episode
|
if len(self.episode_numbers) == 0: return self # need at least one episode
|
||||||
|
|
||||||
# convert scene numbered releases before storing to cache
|
# convert scene numbered releases before storing to cache
|
||||||
showObj = helpers.get_show_by_name(self.series_name)
|
self.show = helpers.get_show_by_name(self.series_name)
|
||||||
if showObj:
|
if not self.show:
|
||||||
self.show = showObj
|
return self
|
||||||
|
|
||||||
new_episode_numbers = []
|
new_episode_numbers = []
|
||||||
new_season_numbers = []
|
new_season_numbers = []
|
||||||
for epNo in self.episode_numbers:
|
for epNo in self.episode_numbers:
|
||||||
(s, e) = scene_numbering.get_indexer_numbering(showObj.indexerid, self.season_number, epNo)
|
(s, e) = scene_numbering.get_indexer_numbering(self.show.indexerid, self.season_number, epNo)
|
||||||
new_episode_numbers.append(e)
|
new_episode_numbers.append(e)
|
||||||
new_season_numbers.append(s)
|
new_season_numbers.append(s)
|
||||||
|
|
||||||
# need to do a quick sanity check here. It's possible that we now have episodes
|
# need to do a quick sanity check here. It's possible that we now have episodes
|
||||||
# from more than one season (by tvdb numbering), and this is just too much
|
# from more than one season (by tvdb numbering), and this is just too much
|
||||||
# for sickbeard, so we'd need to flag it.
|
# for sickbeard, so we'd need to flag it.
|
||||||
new_season_numbers = list(set(new_season_numbers)) # remove duplicates
|
new_season_numbers = list(set(new_season_numbers)) # remove duplicates
|
||||||
if len(new_season_numbers) > 1:
|
if len(new_season_numbers) > 1:
|
||||||
raise InvalidNameException("Scene numbering results episodes from "
|
raise InvalidNameException("Scene numbering results episodes from "
|
||||||
"seasons %s, (i.e. more than one) and "
|
"seasons %s, (i.e. more than one) and "
|
||||||
"sickbeard does not support this. "
|
"sickbeard does not support this. "
|
||||||
"Sorry." % (str(new_season_numbers)))
|
"Sorry." % (str(new_season_numbers)))
|
||||||
|
|
||||||
# I guess it's possible that we'd have duplicate episodes too, so lets
|
# I guess it's possible that we'd have duplicate episodes too, so lets
|
||||||
# eliminate them
|
# eliminate them
|
||||||
new_episode_numbers = list(set(new_episode_numbers))
|
new_episode_numbers = list(set(new_episode_numbers))
|
||||||
new_episode_numbers.sort()
|
new_episode_numbers.sort()
|
||||||
|
|
||||||
self.episode_numbers = new_episode_numbers
|
self.episode_numbers = new_episode_numbers
|
||||||
self.season_number = new_season_numbers[0]
|
self.season_number = new_season_numbers[0]
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -28,9 +28,8 @@ sys.path.append(os.path.abspath('../lib'))
|
|||||||
|
|
||||||
import test_lib as test
|
import test_lib as test
|
||||||
import sickbeard
|
import sickbeard
|
||||||
from sickbeard.helpers import get_show_by_name
|
from sickbeard.helpers import sanitizeSceneName, custom_strftime
|
||||||
from sickbeard.tv import TVShow
|
from sickbeard.tv import TVShow
|
||||||
from sickbeard.name_parser.parser import NameParser, InvalidNameException
|
|
||||||
|
|
||||||
class XEMBasicTests(test.SickbeardTestDBCase):
|
class XEMBasicTests(test.SickbeardTestDBCase):
|
||||||
def loadFromDB(self):
|
def loadFromDB(self):
|
||||||
@ -48,44 +47,41 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "There was an error creating the show"
|
print "There was an error creating the show"
|
||||||
|
|
||||||
def test_parsing_scene_release(self):
|
def test_formating(self):
|
||||||
self.loadFromDB()
|
self.loadFromDB()
|
||||||
|
show = sickbeard.helpers.findCertainShow(sickbeard.showList, 75978)
|
||||||
|
ep = show.getEpisode(7, 6)
|
||||||
|
ep.airdate = datetime.datetime.now()
|
||||||
|
|
||||||
# parse the file name
|
print format(ep.episode, '02d')
|
||||||
scene_parsse_results1 = ''
|
print format(ep.scene_episode, '02d')
|
||||||
scene_parsse_results2 = ''
|
|
||||||
scene_release = 'Pawn Stars S08E41 Field Trip HDTV x264-tNe'
|
|
||||||
try:
|
|
||||||
myParser = NameParser(False, 1)
|
|
||||||
scene_parsse_results1 = myParser.parse(scene_release)
|
|
||||||
scene_parsse_results2 = myParser.parse(scene_release).convert()
|
|
||||||
except InvalidNameException:
|
|
||||||
print(u"Unable to parse the filename " + scene_release + " into a valid episode")
|
|
||||||
|
|
||||||
print scene_parsse_results1
|
search_string = {'Episode':[]}
|
||||||
print scene_parsse_results2
|
episode = ep.airdate
|
||||||
|
str(episode).replace('-', '|')
|
||||||
|
ep_string = sanitizeSceneName(show.name) + ' ' + \
|
||||||
|
str(episode).replace('-', '|') + '|' + \
|
||||||
|
sickbeard.helpers.custom_strftime('%b', episode)
|
||||||
|
|
||||||
sports_release = 'UFC.168.Weidman.vs.Silva.II.28th.Dec.2013.HDTV.x264-Sir.Paul'
|
search_string['Episode'].append(ep_string)
|
||||||
try:
|
|
||||||
myParser = NameParser(False, 2)
|
|
||||||
parse_result = myParser.parse(sports_release)
|
|
||||||
|
|
||||||
test = sickbeard.show_name_helpers.allPossibleShowNames(parse_result.series_name)
|
scene_ep_string = sanitizeSceneName(show.name) + ' ' + \
|
||||||
show = get_show_by_name(parse_result.series_name)
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep.scene_season,
|
||||||
if show:
|
'episodenumber': ep.scene_episode} + '|' + \
|
||||||
sql_results = test.db.DBConnection().select(
|
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep.scene_season,
|
||||||
"SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
|
'episodenumber': ep.scene_episode} + '|' + \
|
||||||
[show.indexerid, parse_result.sports_event_date.toordinal()])
|
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep.scene_season,
|
||||||
|
'episodenumber': ep.scene_episode} + ' %s category:tv' % ''
|
||||||
|
|
||||||
actual_season = int(sql_results[0]["season"])
|
scene_season_string = show.name + ' S%02d' % int(ep.scene_season) + ' -S%02d' % int(ep.scene_season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE
|
||||||
actual_episodes = [int(sql_results[0]["episode"])]
|
|
||||||
|
|
||||||
print actual_season
|
|
||||||
print actual_episodes
|
|
||||||
except InvalidNameException:
|
|
||||||
print(u"Unable to parse the filename " + scene_release + " into a valid episode")
|
|
||||||
|
|
||||||
print scene_parsse_results1
|
print(
|
||||||
|
u'Searching "%s" for "%s" as "%s"' % (show.name, ep.prettyName(), ep.scene_prettyName()))
|
||||||
|
|
||||||
|
print('Scene episode search strings: %s' % (scene_ep_string))
|
||||||
|
|
||||||
|
print('Scene season search strings: %s' % (scene_season_string))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print "=================="
|
print "=================="
|
||||||
|
Loading…
Reference in New Issue
Block a user