本文整理汇总了Python中sickbeard.name_cache.addNameToCache函数的典型用法代码示例。如果您正苦于以下问题:Python addNameToCache函数的具体用法?Python addNameToCache怎么用?Python addNameToCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addNameToCache函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _test_invalid
def _test_invalid(self, name, show, indexerid, is_anime):
sickbeard.showList.append(TVShow(name=name, indexerid=indexerid, is_anime=is_anime))
name_cache.addNameToCache(show, indexerid)
invalidexception = False
try:
parse_result = parser.NameParser(True).parse(name)
except (parser.InvalidNameException, parser.InvalidShowException):
invalidexception = True
self.assertEqual(invalidexception, True)
开发者ID:JackDandy,项目名称:SickGear,代码行数:9,代码来源:name_parser_tests.py
示例2: test_sceneExceptionsResetNameCache
def test_sceneExceptionsResetNameCache(self):
# clear the exceptions
myDB = db.DBConnection("cache.db")
myDB.action("DELETE FROM scene_exceptions")
# put something in the cache
name_cache.addNameToCache('Cached Name', 0)
# updating should not clear the cache this time since our exceptions didn't change
scene_exceptions.retrieve_exceptions()
self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), 0)
开发者ID:coderbone,项目名称:SickRage,代码行数:11,代码来源:test_scene_helpers.py
示例3: test_scene_ex_reset_name_cache
def test_scene_ex_reset_name_cache(self):
"""
Test scene exceptions reset name cache
"""
# clear the exceptions
test_cache_db_con = db.DBConnection('cache.db')
test_cache_db_con.action("DELETE FROM scene_exceptions")
# put something in the cache
name_cache.addNameToCache('Cached Name', 0)
# updating should not clear the cache this time since our exceptions didn't change
scene_exceptions.retrieve_exceptions()
self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), 0)
开发者ID:Arcanemagus,项目名称:SickRage,代码行数:14,代码来源:scene_helpers_tests.py
示例4: test_process
def test_process(self):
show = TVShow(1, 3)
show.name = SHOWNAME
show.location = SHOWDIR
show.saveToDB()
sickbeard.showList = [show]
ep = TVEpisode(show, SEASON, EPISODE)
ep.name = "some ep name"
ep.saveToDB()
addNameToCache('show name', 3)
self.pp = PostProcessor(FILEPATH, process_method='move')
self.assertTrue(self.pp.process())
开发者ID:coderbone,项目名称:SickRage,代码行数:14,代码来源:test_pp.py
示例5: test_process
def test_process(self):
show = TVShow(1,3)
show.name = test.SHOWNAME
show.location = test.SHOWDIR
show.saveToDB()
sickbeard.showList = [show]
ep = TVEpisode(show, test.SEASON, test.EPISODE)
ep.name = "some ep name"
ep.saveToDB()
addNameToCache('show name', 3)
sickbeard.PROCESS_METHOD = 'move'
pp = PostProcessor(test.FILEPATH)
self.assertTrue(pp.process())
开发者ID:Boobahbaggins27,项目名称:SickRage,代码行数:16,代码来源:pp_tests.py
示例6: test_process
def test_process(self):
"""
Test process
"""
show = TVShow(1, 3)
show.name = test.SHOW_NAME
show.location = test.SHOW_DIR
show.saveToDB()
sickbeard.showList = [show]
episode = TVEpisode(show, test.SEASON, test.EPISODE)
episode.name = "some episode name"
episode.saveToDB()
addNameToCache('show name', 3)
sickbeard.PROCESS_METHOD = 'move'
post_processor = PostProcessor(test.FILE_PATH)
self.assertTrue(post_processor.process())
开发者ID:NickMolloy,项目名称:SickRage,代码行数:19,代码来源:pp_tests.py
示例7: _addCacheEntry
def _addCacheEntry(self, name, url, season=None, episodes=None, tvdb_id=0, tvrage_id=0, quality=None, extraNames=[]):
myDB = self._getDB()
parse_result = None
# if we don't have complete info then parse the filename to get it
for curName in [name] + extraNames:
try:
myParser = NameParser()
parse_result = myParser.parse(curName)
except InvalidNameException:
logger.log(u"Unable to parse the filename "+curName+" into a valid episode", logger.DEBUG)
continue
if not parse_result:
logger.log(u"Giving up because I'm unable to parse this name: "+name, logger.DEBUG)
return False
if not parse_result.series_name:
logger.log(u"No series name retrieved from "+name+", unable to cache it", logger.DEBUG)
return False
tvdb_lang = None
# if we need tvdb_id or tvrage_id then search the DB for them
if not tvdb_id or not tvrage_id:
# if we have only the tvdb_id, use the database
if tvdb_id:
showObj = helpers.findCertainShow(sickbeard.showList, tvdb_id)
if showObj:
tvrage_id = showObj.tvrid
tvdb_lang = showObj.lang
else:
logger.log(u"We were given a TVDB id "+str(tvdb_id)+" but it doesn't match a show we have in our list, so leaving tvrage_id empty", logger.DEBUG)
tvrage_id = 0
# if we have only a tvrage_id then use the database
elif tvrage_id:
showObj = helpers.findCertainTVRageShow(sickbeard.showList, tvrage_id)
if showObj:
tvdb_id = showObj.tvdbid
tvdb_lang = showObj.lang
else:
logger.log(u"We were given a TVRage id "+str(tvrage_id)+" but it doesn't match a show we have in our list, so leaving tvdb_id empty", logger.DEBUG)
tvdb_id = 0
# if they're both empty then fill out as much info as possible by searching the show name
else:
# check the name cache and see if we already know what show this is
logger.log(u"Checking the cache to see if we already know the tvdb id of "+parse_result.series_name, logger.DEBUG)
tvdb_id = name_cache.retrieveNameFromCache(parse_result.series_name)
# remember if the cache lookup worked or not so we know whether we should bother updating it later
if tvdb_id == None:
logger.log(u"No cache results returned, continuing on with the search", logger.DEBUG)
from_cache = False
else:
logger.log(u"Cache lookup found "+repr(tvdb_id)+", using that", logger.DEBUG)
from_cache = True
# if the cache failed, try looking up the show name in the database
if tvdb_id == None:
logger.log(u"Trying to look the show up in the show database", logger.DEBUG)
showResult = helpers.searchDBForShow(parse_result.series_name)
if showResult:
logger.log(parse_result.series_name+" was found to be show "+showResult[1]+" ("+str(showResult[0])+") in our DB.", logger.DEBUG)
tvdb_id = showResult[0]
# if the DB lookup fails then do a comprehensive regex search
if tvdb_id == None:
logger.log(u"Couldn't figure out a show name straight from the DB, trying a regex search instead", logger.DEBUG)
for curShow in sickbeard.showList:
if show_name_helpers.isGoodResult(name, curShow, False):
logger.log(u"Successfully matched "+name+" to "+curShow.name+" with regex", logger.DEBUG)
tvdb_id = curShow.tvdbid
tvdb_lang = curShow.lang
break
# if tvdb_id was anything but None (0 or a number) then
if not from_cache:
name_cache.addNameToCache(parse_result.series_name, tvdb_id)
# if we came out with tvdb_id = None it means we couldn't figure it out at all, just use 0 for that
if tvdb_id == None:
tvdb_id = 0
# if we found the show then retrieve the show object
if tvdb_id:
showObj = helpers.findCertainShow(sickbeard.showList, tvdb_id)
if showObj:
tvrage_id = showObj.tvrid
tvdb_lang = showObj.lang
# if we weren't provided with season/episode information then get it from the name that we parsed
if not season:
season = parse_result.season_number if parse_result.season_number != None else 1
if not episodes:
#.........这里部分代码省略.........
开发者ID:jesseward,项目名称:Sick-Beard,代码行数:101,代码来源:tvcache.py
示例8: len
else:
self.anidbEpisode = ep
#TODO: clean code. it looks like it's from hell
for name in ep.allNames:
indexer_id = name_cache.retrieveNameFromCache(name)
if not indexer_id:
show = helpers.get_show_by_name(name)
if show:
indexer_id = show.indexerid
else:
indexer_id = 0
if indexer_id:
name_cache.addNameToCache(name, indexer_id)
if indexer_id:
try:
show = helpers.findCertainShow(sickbeard.showList, indexer_id)
(season, episodes) = helpers.get_all_episodes_from_absolute_number(show, None, [ep.epno])
except exceptions.EpisodeNotFoundByAbsoluteNumberException:
self._log(str(indexer_id) + ": Indexer object absolute number " + str(
ep.epno) + " is incomplete, skipping this episode")
else:
if len(episodes):
self._log(u"Lookup successful from anidb. ", logger.DEBUG)
return (show, season, episodes, None)
if ep.anidb_file_name:
self._log(u"Lookup successful, using anidb filename " + str(ep.anidb_file_name), logger.DEBUG)
return self._analyze_name(ep.anidb_file_name)
开发者ID:dhellwich,项目名称:SickBeard-SickRage,代码行数:31,代码来源:postProcessor.py
示例9: len
else:
self.anidbEpisode = ep
#TODO: clean code. it looks like it's from hell
for name in ep.allNames:
tvdb_id = name_cache.retrieveNameFromCache(name)
if not tvdb_id:
show = helpers.get_show_by_name(name, sickbeard.showList, True)
if show:
tvdb_id = show.tvdbid
else:
tvdb_id = 0
if tvdb_id:
name_cache.addNameToCache(name, tvdb_id)
if tvdb_id:
try:
show = helpers.findCertainShow(sickbeard.showList, tvdb_id)
(season, episodes) = helpers.get_all_episodes_from_absolute_number(show, None, [ep.epno])
except exceptions.EpisodeNotFoundByAbsoluteNumerException:
self._log(str(tvdb_id) + ": TVDB object absolute number " + str(ep.epno) + " is incomplete, skipping this episode")
else:
if len(episodes):
self._log(u"Lookup successful from anidb. ", logger.DEBUG)
return (tvdb_id, season, episodes)
if ep.anidb_file_name:
self._log(u"Lookup successful, using anidb filename "+str(ep.anidb_file_name), logger.DEBUG)
return self._analyze_name(ep.anidb_file_name)
raise InvalidNameException
开发者ID:stephanehenry27,项目名称:Sickbeard-anime,代码行数:31,代码来源:postProcessor.py
示例10: _addCacheEntry
#.........这里部分代码省略.........
logger.DEBUG)
showResult = helpers.searchDBForShow(parse_result.series_name)
if showResult:
logger.log(
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 not indexer_id:
logger.log(
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 not season:
season = parse_result.season_number if parse_result.season_number != None else 1
if not episodes:
episodes = parse_result.episode_numbers
# if we have an air-by-date show then get the real season/episode numbers
if (parse_result.air_by_date or parse_result.sports) and indexer_id:
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)
epObj = None
if parse_result.air_by_date:
epObj = t[indexer_id].airedOn(parse_result.air_date)[0]
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
except sickbeard.indexer_error, e:
logger.log(u"Unable to contact " + sickbeard.indexerApi(self.indexer).name + ": " + ex(e),
logger.WARNING)
return None
开发者ID:Wizkidje,项目名称:SickBeard-TVRage,代码行数:101,代码来源:tvcache.py
注:本文中的sickbeard.name_cache.addNameToCache函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论