本文整理汇总了Python中sickbeard.show_name_helpers.filterBadReleases函数的典型用法代码示例。如果您正苦于以下问题:Python filterBadReleases函数的具体用法?Python filterBadReleases怎么用?Python filterBadReleases使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filterBadReleases函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_release_name
def _get_release_name(self):
"""Try to find a valid-looking release name"""
if self.nzb_name is not None:
self._log(u"Using self.nzb_name for release name.")
return re.sub(r'\.nzb$', '', self.nzb_name, flags=re.IGNORECASE)
# try to get the release name from nzb/nfo
self._log(u"No self.nzb_name given. Trying to guess release name.")
file_types = ["*.nzb", "*.nfo"]
for search in file_types:
search_path = ek.ek(os.path.join, self.dir_name, search)
results = ek.ek(glob, search_path)
if len(results) == 1:
found_file = ek.ek(os.path.basename, results[0])
found_file = re.sub(r'\.nzb$', '', found_file, flags=re.IGNORECASE)
if show_name_helpers.filterBadReleases(found_file, self._show_obj):
self._log(u"Release name (" + found_file + ") found from file (" + results[0] + ")")
return found_file
# If that fails, we try the folder
folder = ek.ek(os.path.basename, self.dir_name)
if show_name_helpers.filterBadReleases(folder, self._show_obj):
# NOTE: Multiple failed downloads will change the folder name.
# (e.g., appending #s)
# Should we handle that?
self._log(u"Folder name (" + folder + ") appears to be a valid release name. Using it.")
return folder
return None
示例2: findSeason
def findSeason(show, season):
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
foundResults = {}
didSearch = False
for curProvider in providers.sortedProviderList():
if not curProvider.isActive():
continue
try:
curResults = curProvider.findSeasonResults(show, season)
# 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
示例3: findSeason
def findSeason(show, season):
myDB = db.DBConnection()
allEps = [int(x["episode"]) for x in myDB.select("SELECT episode FROM tv_episodes WHERE showid = ? AND season = ?", [show.tvdbid, season])]
logger.log(u"Episode list: "+str(allEps), logger.DEBUG)
reallywanted=[]
notwanted=[]
finalResults = []
for curEpNum in allEps:
sqlResults = myDB.select("SELECT status FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?", [show.tvdbid, season, curEpNum])
epStatus = int(sqlResults[0]["status"])
if epStatus ==3:
reallywanted.append(curEpNum)
else:
notwanted.append(curEpNum)
if notwanted != []:
for EpNum in reallywanted:
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, show.tvdbid)
episode = showObj.getEpisode(season, EpNum)
res=findEpisode(episode, manualSearch=True)
snatchEpisode(res)
return
else:
logger.log(u"Searching for stuff we need from "+show.name+" season "+str(season))
foundResults = {}
didSearch = False
for curProvider in providers.sortedProviderList():
if not curProvider.isActive():
continue
try:
curResults = curProvider.findSeasonResults(show, season)
# 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.DEBUG)
logger.log(traceback.format_exc(), logger.DEBUG)
continue
didSearch = True
示例4: _doSearch
def _doSearch(self, search_params, show=None):
results = []
items = {'Season': [], 'Episode': []}
if not self._doLogin():
return
for mode in search_params.keys():
for search_string in search_params[mode]:
searchURL = self.urls['search'] % (search_string, self.categories)
logger.log(u"Search string: " + searchURL, logger.DEBUG)
data = self.getURL(searchURL)
if not data:
return []
html = BeautifulSoup(data)
try:
torrent_table = html.find('table', attrs = {'id' : 'torrenttable'})
if not torrent_table:
logger.log(u"No results found for: " + search_string + "(" + searchURL + ")", logger.DEBUG)
return []
for result in torrent_table.find_all('tr')[1:]:
link = result.find('td', attrs = {'class' : 'name'}).find('a')
url = result.find('td', attrs = {'class' : 'quickdownload'}).find('a')
title = link.string
download_url = self.urls['download'] % url['href']
id = int(link['href'].replace('/torrent/', ''))
seeders = int(result.find('td', attrs = {'class' : 'seeders'}).string)
leechers = int(result.find('td', attrs = {'class' : 'leechers'}).string)
#Filter unseeded torrent
if seeders == 0 or not title \
or not show_name_helpers.filterBadReleases(title):
continue
item = title, download_url, id, seeders, leechers
logger.log(u"Found result: " + title + "(" + searchURL + ")", logger.DEBUG)
items[mode].append(item)
except:
logger.log(u"Failed to parsing " + self.name + " page url: " + searchURL, logger.ERROR)
#For each search mode sort all the items by seeders
items[mode].sort(key=lambda tup: tup[3], reverse=True)
results += items[mode]
return results
示例5: _test_filter_bad_releases
def _test_filter_bad_releases(self, name, expected):
"""
Test filter of bad releases
:param name:
:param expected:
:return:
"""
result = show_name_helpers.filterBadReleases(name)
self.assertEqual(result, expected)
示例6: _doSearch
def _doSearch(self, search_params, show=None):
results = []
items = {'Season': [], 'Episode': []}
for mode in search_params.keys():
for search_string in search_params[mode]:
searchURL = self.proxy._buildURL(self.searchurl %(urllib.quote(search_string)))
logger.log(u"Search string: " + searchURL, logger.DEBUG)
data = self.getURL(searchURL)
if not data:
return []
re_title_url = self.proxy._buildRE(self.re_title_url)
#Extracting torrent information from data returned by searchURL
match = re.compile(re_title_url, re.DOTALL ).finditer(urllib.unquote(data))
for torrent in match:
title = torrent.group('title').replace('_','.')#Do not know why but SickBeard skip release with '_' in name
url = torrent.group('url')
id = int(torrent.group('id'))
seeders = int(torrent.group('seeders'))
leechers = int(torrent.group('leechers'))
#Filter unseeded torrent
if seeders == 0 or not title \
or not show_name_helpers.filterBadReleases(title):
continue
#Accept Torrent only from Good People for every Episode Search
if sickbeard.THEPIRATEBAY_TRUSTED and re.search('(VIP|Trusted|Helper)',torrent.group(0))== None:
logger.log(u"ThePirateBay Provider found result "+torrent.group('title')+" but that doesn't seem like a trusted result so I'm ignoring it",logger.DEBUG)
continue
#Try to find the real Quality for full season torrent analyzing files in torrent
if mode == 'Season' and Quality.nameQuality(title) == Quality.UNKNOWN:
if not self._find_season_quality(title,id): continue
item = title, url, id, seeders, leechers
items[mode].append(item)
#For each search mode sort all the items by seeders
items[mode].sort(key=lambda tup: tup[3], reverse=True)
results += items[mode]
return results
示例7: filterSearchResults
def filterSearchResults(show, season, results):
foundResults = {}
# make a list of all the results for this provider
for curEp in results:
# skip non-tv crap
results[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name) and x.show == show,results[curEp])
if curEp in foundResults:
foundResults[curEp] += results[curEp]
else:
foundResults[curEp] = results[curEp]
return foundResults
示例8: searchProviders
def searchProviders(show, season, episode=None, manualSearch=False):
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
foundResults = {}
didSearch = False
seasonSearch = False
# 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:
seasonEps = show.getAllEpisodes(season)
wantedEps = [x for x in seasonEps if show.getOverview(x.status) in (Overview.WANTED, Overview.QUAL)]
if len(seasonEps) == len(wantedEps):
seasonSearch = True
else:
ep_obj = show.getEpisode(season, episode)
wantedEps = [ep_obj]
for curProvider in providers.sortedProviderList():
if not curProvider.isActive():
continue
try:
curResults = curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch)
# 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
示例9: filterSearchResults
def filterSearchResults(show, results):
foundResults = {}
# make a list of all the results for this provider
for curEp in results.keys():
# skip non-tv crap
results[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name, show),
results[curEp])
if len(results[curEp]):
if curEp in foundResults:
foundResults[curEp] += results[curEp]
else:
foundResults[curEp] = results[curEp]
return foundResults
示例10: findNeededEpisodes
def findNeededEpisodes(self, episode, manualSearch=False, downCurQuality=False):
neededEps = {}
cl = []
myDB = self._getDB()
if not episode:
sqlResults = myDB.select("SELECT * FROM [" + self.providerID + "]")
elif type(episode) != list:
sqlResults = myDB.select(
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
[episode.show.indexerid, episode.season, "%|" + str(episode.episode) + "|%"])
else:
for epObj in episode:
cl.append([
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ? AND quality IN (" + ",".join(
[str(x) for x in epObj.wantedQuality]) + ")",
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"]])
sqlResults = myDB.mass_action(cl, fetchall=True)
sqlResults = list(itertools.chain(*sqlResults))
# for each cache entry
for curResult in sqlResults:
# ignored/required words, and non-tv junk
if not show_name_helpers.filterBadReleases(curResult["name"]):
continue
# get the show object, or if it's not one of our shows then ignore it
showObj = Show.find(sickbeard.showList, int(curResult["indexerid"]))
if not showObj:
continue
# skip if provider is anime only and show is not anime
if self.provider.anime_only and not showObj.is_anime:
logger.log(u"" + str(showObj.name) + " is not an anime, skiping", logger.DEBUG)
continue
# get season and ep data (ignoring multi-eps for now)
curSeason = int(curResult["season"])
if curSeason == -1:
continue
curEp = curResult["episodes"].split("|")[1]
if not curEp:
continue
curEp = int(curEp)
curQuality = int(curResult["quality"])
curReleaseGroup = curResult["release_group"]
curVersion = curResult["version"]
# if the show says we want that episode then add it to the list
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch, downCurQuality):
logger.log(u"Skipping " + curResult["name"], logger.DEBUG)
continue
epObj = showObj.getEpisode(curSeason, curEp)
# build a result object
title = curResult["name"]
url = curResult["url"]
logger.log(u"Found result " + title + " at " + url)
result = self.provider.get_result([epObj])
result.show = showObj
result.url = url
result.name = title
result.quality = curQuality
result.release_group = curReleaseGroup
result.version = curVersion
result.content = None
# add it to the list
if epObj not in neededEps:
neededEps[epObj] = [result]
else:
neededEps[epObj].append(result)
# datetime stamp this search so cache gets cleared
self.setLastSearch()
return neededEps
示例11: ex
break
except Exception, e:
logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG)
break
finally:
threading.currentThread().name = origThreadName
didSearch = True
if len(searchResults):
# make a list of all the results for this provider
for curEp in searchResults:
# skip non-tv crap
searchResults[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name, parse=False) and x.show == show, searchResults[curEp])
if curEp in foundResults:
foundResults[curProvider.name][curEp] += searchResults[curEp]
else:
foundResults[curProvider.name][curEp] = searchResults[curEp]
break
elif not curProvider.search_fallback or searchCount == 2:
break
if search_mode == 'sponly':
logger.log(u"FALLBACK EPISODE SEARCH INITIATED ...")
search_mode = 'eponly'
else:
logger.log(u"FALLBACK SEASON PACK SEARCH INITIATED ...")
示例12: ex
try:
curFoundResults = curProvider.findEpisode(episode, manualSearch=manualSearch)
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
# skip non-tv crap
curFoundResults = filter(
lambda x: show_name_helpers.filterBadReleases(x.name)
and show_name_helpers.isGoodResult(x.name, episode.show),
curFoundResults,
)
# loop all results and see if any of them are good enough that we can stop searching
done_searching = False
for cur_result in curFoundResults:
done_searching = isFinalResult(cur_result)
logger.log(
u"Should we stop searching after finding " + cur_result.name + ": " + str(done_searching), logger.DEBUG
)
if done_searching:
break
foundResults += curFoundResults
示例13: findNeededEpisodes
def findNeededEpisodes(self, episode = None, manualSearch=False):
neededEps = {}
if episode:
neededEps[episode] = []
myDB = self._getDB()
if not episode:
sqlResults = myDB.select("SELECT * FROM "+self.providerID)
else:
sqlResults = myDB.select("SELECT * FROM "+self.providerID+" WHERE tvdbid = ? AND season = ? AND episodes LIKE ?", [episode.show.tvdbid, episode.season, "|"+str(episode.episode)+"|"])
# for each cache entry
for curResult in sqlResults:
# skip non-tv crap (but allow them for Newzbin cause we assume it's filtered well)
if self.providerID != 'newzbin' and not show_name_helpers.filterBadReleases(curResult["name"]):
continue
# get the show object, or if it's not one of our shows then ignore it
showObj = helpers.findCertainShow(sickbeard.showList, int(curResult["tvdbid"]))
if not showObj:
continue
# get season and ep data (ignoring multi-eps for now)
curSeason = int(curResult["season"])
if curSeason == -1:
continue
curEp = curResult["episodes"].split("|")[1]
if not curEp:
continue
curEp = int(curEp)
curQuality = int(curResult["quality"])
# if the show says we want that episode then add it to the list
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch):
logger.log(u"Skipping "+curResult["name"]+" because we don't want an episode that's "+Quality.qualityStrings[curQuality], logger.DEBUG)
else:
if episode:
epObj = episode
else:
epObj = showObj.getEpisode(curSeason, curEp)
# build a result object
title = curResult["name"]
url = curResult["url"]
logger.log(u"Found result " + title + " at " + url)
result = self.provider.getResult([epObj])
result.url = url
result.name = title
result.quality = curQuality
# add it to the list
if epObj not in neededEps:
neededEps[epObj] = [result]
else:
neededEps[epObj].append(result)
return neededEps
示例14: filter
epObjs.append(show.getEpisode(season, curEpNum))
bestSeasonNZB.episodes = epObjs
return [bestSeasonNZB]
elif not anyWanted:
logger.log(u"No eps from this season are wanted at this quality, ignoring the result of "+bestSeasonNZB.name, logger.DEBUG)
else:
if bestSeasonNZB.provider.providerType == GenericProvider.NZB:
logger.log(u"Breaking apart the NZB and adding the individual ones to our results", logger.DEBUG)
# if not, break it apart and add them as the lowest priority results
individualResults = nzbSplitter.splitResult(bestSeasonNZB)
individualResults = filter(lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name, show, season=season), individualResults)
for curResult in individualResults:
if len(curResult.episodes) == 1:
epNum = curResult.episodes[0].episode
elif len(curResult.episodes) > 1:
epNum = MULTI_EP_RESULT
if epNum in foundResults:
foundResults[epNum].append(curResult)
else:
foundResults[epNum] = [curResult]
# If this is a torrent all we can do is leech the entire torrent, user will have to select which eps not do download in his torrent client
else:
示例15: searchProviders
def searchProviders(show, season, episodes, manualSearch=False):
foundResults = {}
finalResults = []
# check if we want to search for season packs instead of just season/episode
seasonSearch = False
if not manualSearch:
seasonEps = show.getAllEpisodes(season)
if len(seasonEps) == len(episodes):
seasonSearch = True
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
if not len(providers):
logger.log(
u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.",
logger.ERROR,
)
return
origThreadName = threading.currentThread().name
for providerNum, provider in enumerate(providers):
if provider.anime_only and not show.is_anime:
logger.log(u"" + str(show.name) + " is not an anime skiping ...")
continue
threading.currentThread().name = origThreadName + " :: [" + provider.name + "]"
foundResults.setdefault(provider.name, {})
searchCount = 0
search_mode = "eponly"
if seasonSearch and provider.search_mode == "sponly":
search_mode = provider.search_mode
while True:
searchCount += 1
if search_mode == "sponly":
logger.log(u"Searching for " + show.name + " Season " + str(season) + " pack")
else:
logger.log(u"Searching for episodes we need from " + show.name + " Season " + str(season))
try:
searchResults = provider.findSearchResults(show, season, episodes, search_mode, manualSearch)
except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
break
except Exception, e:
logger.log(u"Error while searching " + provider.name + ", skipping: " + ex(e), logger.ERROR)
break
if len(searchResults):
# make a list of all the results for this provider
for curEp in searchResults:
# skip non-tv crap
searchResults[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name)
and show_name_helpers.isGoodResult(x.name, show, season=season),
searchResults[curEp],
)
if curEp in foundResults:
foundResults[provider.name][curEp] += searchResults[curEp]
else:
foundResults[provider.name][curEp] = searchResults[curEp]
break
elif not provider.search_fallback or searchCount == 2:
break
if search_mode == "sponly":
logger.log(u"FALLBACK EPISODE SEARCH INITIATED ...")
search_mode = "eponly"
else:
logger.log(u"FALLBACK SEASON PACK SEARCH INITIATED ...")
search_mode = "sponly"