本文整理汇总了Python中sickbeard.name_parser.parser.NameParser类的典型用法代码示例。如果您正苦于以下问题:Python NameParser类的具体用法?Python NameParser怎么用?Python NameParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NameParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: validate_name
def validate_name(pattern, multi=None, anime_type=None, file_only=False, abd=False, sports=False):
"""
See if we understand a name
:param pattern: Name to analyse
:param multi: Is this a multi-episode name
:param anime_type: Is this anime
:param file_only: Is this just a file or a dir
:param abd: Is air-by-date enabled
:param sports: Is this sports
:return: True if valid name, False if not
"""
ep = generate_sample_ep(multi, abd, sports, anime_type)
new_name = ep.formatted_filename(pattern, multi, anime_type) + '.ext'
new_path = ep.formatted_dir(pattern, multi)
if not file_only:
new_name = ek(os.path.join, new_path, new_name)
if not new_name:
logger.log(u"Unable to create a name out of " + pattern, logger.DEBUG)
return False
logger.log(u"Trying to parse " + new_name, logger.DEBUG)
parser = NameParser(True, showObj=ep.show, naming_pattern=True)
try:
result = parser.parse(new_name)
except Exception, e:
logger.log(u"Unable to parse " + new_name + ", not valid", logger.DEBUG)
return False
开发者ID:SerialShadow,项目名称:SickRage,代码行数:32,代码来源:naming.py
示例2: _analyze_name
def _analyze_name(self, name, resource=True):
"""
Takes a name and tries to figure out a show, season, and episode from it.
name: A string which we want to analyze to determine show info from (unicode)
Returns a (indexer_id, season, [episodes]) tuple. The first two may be None and episodes may be []
if none were found.
"""
logger.log(u'Analyzing name ' + repr(name))
to_return = (None, None, [], None)
if not name:
return to_return
# parse the name to break it into show name, season, and episode
np = NameParser(resource, try_scene_exceptions=True, convert=True)
parse_result = np.parse(name)
self._log(u'Parsed %s<br />.. from %s' % (str(parse_result).decode('utf-8', 'xmlcharrefreplace'), name), logger.DEBUG)
if parse_result.is_air_by_date:
season = -1
episodes = [parse_result.air_date]
else:
season = parse_result.season_number
episodes = parse_result.episode_numbers
# show object
show = parse_result.show
to_return = (show, season, episodes, parse_result.quality)
self._finalize(parse_result)
return to_return
开发者ID:Apocrathia,项目名称:SickGear,代码行数:35,代码来源:postProcessor.py
示例3: process
def process(self):
self._log(u"Failed download detected: (" + str(self.nzb_name) + ", " + str(self.dir_name) + ")")
releaseName = show_name_helpers.determineReleaseName(self.dir_name, self.nzb_name)
if releaseName is None:
self._log(u"Warning: unable to find a valid release name.", logger.WARNING)
raise exceptions.FailedProcessingFailed()
try:
parser = NameParser(False, showObj=self.show, convert=True)
parsed = parser.parse(releaseName)
except InvalidNameException:
self._log(u"Error: release name is invalid: " + releaseName, logger.DEBUG)
raise exceptions.FailedProcessingFailed()
except InvalidShowException:
self._log(u"Error: unable to parse release name " + releaseName + " into a valid show", logger.DEBUG)
raise exceptions.FailedProcessingFailed()
logger.log(u"name_parser info: ", logger.DEBUG)
logger.log(u" - " + str(parsed.series_name), logger.DEBUG)
logger.log(u" - " + str(parsed.season_number), logger.DEBUG)
logger.log(u" - " + str(parsed.episode_numbers), logger.DEBUG)
logger.log(u" - " + str(parsed.extra_info), logger.DEBUG)
logger.log(u" - " + str(parsed.release_group), logger.DEBUG)
logger.log(u" - " + str(parsed.air_date), logger.DEBUG)
for episode in parsed.episode_numbers:
segment = parsed.show.getEpisode(parsed.season_number, episode)
cur_failed_queue_item = search_queue.FailedQueueItem(parsed.show, [segment])
sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item)
return True
开发者ID:JackDandy,项目名称:SickGear,代码行数:33,代码来源:failedProcessor.py
示例4: validate_name
def validate_name(pattern, multi=None, file_only=False, abd=False):
ep = _generate_sample_ep(multi, abd)
parser = NameParser(True)
new_name = ep.formatted_filename(pattern, multi) + '.ext'
new_path = ep.formatted_dir(pattern, multi)
if not file_only:
new_name = ek.ek(os.path.join, new_path, new_name)
logger.log(u"Trying to parse "+new_name, logger.DEBUG)
try:
result = parser.parse(new_name)
except InvalidNameException:
logger.log(u"Unable to parse "+new_name+", not valid", logger.DEBUG)
return False
logger.log(new_name + " vs " + str(result), logger.DEBUG)
if abd:
if result.air_date != ep.airdate:
return False
else:
if result.season_number != ep.season:
return False
if result.episode_numbers != [x.episode for x in [ep] + ep.relatedEps]:
return False
return True
开发者ID:Adrellias,项目名称:Sick-Beard,代码行数:30,代码来源:naming.py
示例5: test_formating
def test_formating(self):
release = "UFC.172.26th.April.2014.HDTV.x264.720p-Sir.Paul[rartv]"
# parse the name to break it into show name, season, and episode
np = NameParser(file)
parse_result = np.parse(release).convert()
print(parse_result)
开发者ID:BobWatson,项目名称:SickBeard-TVRage,代码行数:7,代码来源:xem_tests.py
示例6: _find_season_quality
def _find_season_quality(self, title, torrent_id, ep_number):
""" Return the modified title of a Season Torrent with the quality found inspecting torrent file list """
mediaExtensions = ['avi', 'mkv', 'wmv', 'divx',
'vob', 'dvr-ms', 'wtv', 'ts'
'ogv', 'rar', 'zip', 'mp4']
quality = Quality.UNKNOWN
fileName = None
fileURL = self.proxy._buildURL(self.url + 'ajax_details_filelist.php?id=' + str(torrent_id))
data = self.getURL(fileURL)
if not data:
return None
filesList = re.findall('<td.+>(.*?)</td>', data)
if not filesList:
logger.log(u"Unable to get the torrent file list for " + title, logger.ERROR)
videoFiles = filter(lambda x: x.rpartition(".")[2].lower() in mediaExtensions, filesList)
#Filtering SingleEpisode/MultiSeason Torrent
if len(videoFiles) < ep_number or len(videoFiles) > float(ep_number * 1.1):
logger.log(
u"Result " + title + " have " + str(ep_number) + " episode and episodes retrived in torrent are " + str(
len(videoFiles)), logger.DEBUG)
logger.log(u"Result " + title + " Seem to be a Single Episode or MultiSeason torrent, skipping result...",
logger.DEBUG)
return None
if Quality.sceneQuality(title) != Quality.UNKNOWN:
return title
for fileName in videoFiles:
quality = Quality.sceneQuality(os.path.basename(fileName))
if quality != Quality.UNKNOWN: break
if fileName is not None and quality == Quality.UNKNOWN:
quality = Quality.assumeQuality(os.path.basename(fileName))
if quality == Quality.UNKNOWN:
logger.log(u"Unable to obtain a Season Quality for " + title, logger.DEBUG)
return None
try:
myParser = NameParser()
parse_result = myParser.parse(fileName)
except InvalidNameException:
return None
logger.log(u"Season quality for " + title + " is " + Quality.qualityStrings[quality], logger.DEBUG)
if parse_result.series_name and parse_result.season_number:
title = parse_result.series_name + ' S%02d' % int(parse_result.season_number) + ' ' + self._reverseQuality(
quality)
return title
开发者ID:sgtwtf,项目名称:SickRage,代码行数:60,代码来源:thepiratebay.py
示例7: _parseItem
def _parseItem(self, item):
ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy()
ltvdb_api_parms['search_all_languages'] = True
(title, url) = self.provider._get_title_and_url(item)
if not title or not url:
logger.log(u"The XML returned from the Ethor RSS feed is incomplete, this result is unusable", logger.ERROR)
return
try:
myParser = NameParser()
parse_result = myParser.parse(title)
except InvalidNameException:
logger.log(u"Unable to parse the filename "+title+" into a valid episode", logger.DEBUG)
return
try:
t = tvdb_api.Tvdb(**ltvdb_api_parms)
showObj = t[parse_result.series_name]
except tvdb_exceptions.tvdb_error:
logger.log(u"TVDB timed out, unable to update episodes from TVDB", logger.ERROR)
return
logger.log(u"Adding item from RSS to cache: " + title, logger.DEBUG)
self._addCacheEntry(name=title, url=url, tvdb_id=showObj['id'])
开发者ID:ClubSoundZ,项目名称:Sick-Beard,代码行数:27,代码来源:ethor.py
示例8: history_snatched_proper_fix
def history_snatched_proper_fix():
my_db = db.DBConnection()
if not my_db.has_flag('history_snatch_proper'):
logger.log('Updating history items with status Snatched Proper in a background process...')
sql_result = my_db.select('SELECT rowid, resource, quality, showid'
' FROM history'
' WHERE action LIKE "%%%02d"' % SNATCHED +
' AND (UPPER(resource) LIKE "%PROPER%"'
' OR UPPER(resource) LIKE "%REPACK%"'
' OR UPPER(resource) LIKE "%REAL%")')
if sql_result:
cl = []
for r in sql_result:
show_obj = None
try:
show_obj = helpers.findCertainShow(sickbeard.showList, int(r['showid']))
except (StandardError, Exception):
pass
np = NameParser(False, showObj=show_obj, testing=True)
try:
pr = np.parse(r['resource'])
except (StandardError, Exception):
continue
if 0 < Quality.get_proper_level(pr.extra_info_no_name(), pr.version, pr.is_anime):
cl.append(['UPDATE history SET action = ? WHERE rowid = ?',
[Quality.compositeStatus(SNATCHED_PROPER, int(r['quality'])),
r['rowid']]])
if cl:
my_db.mass_action(cl)
logger.log('Completed the history table update with status Snatched Proper.')
my_db.add_flag('history_snatch_proper')
开发者ID:JackDandy,项目名称:SickGear,代码行数:31,代码来源:history.py
示例9: findEpisode
def findEpisode(self, episode, manualSearch=False):
self._checkAuth()
logger.log(u"Searching "+self.name+" for " + episode.prettyName())
self.cache.updateCache()
results = self.cache.searchCache(episode, manualSearch)
logger.log(u"Cache results: "+str(results), 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 or not manualSearch:
return results
itemList = []
for cur_search_string in self._get_episode_search_strings(episode):
itemList += self._doSearch(cur_search_string)
for item in itemList:
(title, url) = self._get_title_and_url(item)
# parse the file name
try:
myParser = NameParser()
parse_result = myParser.parse(title)
except InvalidNameException:
logger.log(u"Unable to parse the filename "+title+" into a valid episode", logger.WARNING)
continue
if episode.show.air_by_date:
if parse_result.air_date != episode.airdate:
logger.log("Episode "+title+" didn't air on "+str(episode.airdate)+", skipping it", logger.DEBUG)
continue
elif parse_result.season_number != episode.season or episode.episode not in parse_result.episode_numbers:
logger.log("Episode "+title+" isn't "+str(episode.season)+"x"+str(episode.episode)+", skipping it", logger.DEBUG)
continue
quality = self.getQuality(item)
if not episode.show.wantEpisode(episode.season, episode.episode, quality, manualSearch):
logger.log(u"Ignoring result "+title+" because we don't want an episode that is "+Quality.qualityStrings[quality], logger.DEBUG)
continue
logger.log(u"Found result " + title + " at " + url, logger.DEBUG)
result = self.getResult([episode])
result.url = url
result.name = title
result.quality = quality
result.provider = self
result.content = None
results.append(result)
return results
开发者ID:fldc,项目名称:Sick-Beard,代码行数:59,代码来源:generic.py
示例10: _find_season_quality
def _find_season_quality(self, title, torrent_link, ep_number):
""" Return the modified title of a Season Torrent with the quality found inspecting torrent file list """
quality = Quality.UNKNOWN
file_name = None
data = self.get_url(torrent_link)
if not data:
return None
try:
with BS4Parser(data, features=['html5lib', 'permissive']) as soup:
file_table = soup.find('table', attrs={'class': 'torrentFileList'})
if not file_table:
return None
files = [x.text for x in file_table.find_all('td', attrs={'class': 'torFileName'})]
video_files = filter(lambda i: i.rpartition('.')[2].lower() in mediaExtensions, files)
# Filtering SingleEpisode/MultiSeason Torrent
if len(video_files) < ep_number or len(video_files) > float(ep_number * 1.1):
logger.log(u'Result %s lists %s episodes with %s episodes retrieved in torrent'
% (title, ep_number, len(video_files)), logger.DEBUG)
logger.log(u'Result %s seem to be a single episode or multi-season torrent, skipping result...'
% title, logger.DEBUG)
return None
if Quality.UNKNOWN != Quality.sceneQuality(title):
return title
for file_name in video_files:
quality = Quality.sceneQuality(os.path.basename(file_name))
if Quality.UNKNOWN != quality:
break
if None is not file_name and Quality.UNKNOWN == quality:
quality = Quality.assumeQuality(os.path.basename(file_name))
if Quality.UNKNOWN == quality:
logger.log(u'Unable to obtain a Season Quality for ' + title, logger.DEBUG)
return None
try:
my_parser = NameParser(showObj=self.show)
parse_result = my_parser.parse(file_name)
except (InvalidNameException, InvalidShowException):
return None
logger.log(u'Season quality for %s is %s' % (title, Quality.qualityStrings[quality]), logger.DEBUG)
if parse_result.series_name and parse_result.season_number:
title = parse_result.series_name + ' S%02d %s' % (int(parse_result.season_number),
self._reverse_quality(quality))
return title
except Exception:
logger.log(u'Failed to quality parse ' + self.name + ' Traceback: ' + traceback.format_exc(), logger.ERROR)
开发者ID:Apocrathia,项目名称:SickGear,代码行数:59,代码来源:kat.py
示例11: already_postprocessed
def already_postprocessed(dirName, videofile, force, result):
"""
Check if we already post processed a file
:param dirName: Directory a file resides in
:param videofile: File name
:param force: Force checking when already checking (currently unused)
:param result: True if file is already postprocessed, False if not
:return:
"""
if force:
return False
# Avoid processing the same dir again if we use a process method <> move
myDB = db.DBConnection()
sqlResult = myDB.select("SELECT * FROM tv_episodes WHERE release_name = ?", [dirName])
if sqlResult:
# result.output += logHelper(u"You're trying to post process a dir that's already been processed, skipping", logger.DEBUG)
return True
else:
sqlResult = myDB.select("SELECT * FROM tv_episodes WHERE release_name = ?", [videofile.rpartition(".")[0]])
if sqlResult:
# result.output += logHelper(u"You're trying to post process a video that's already been processed, skipping", logger.DEBUG)
return True
# Needed if we have downloaded the same episode @ different quality
# But we need to make sure we check the history of the episode we're going to PP, and not others
np = NameParser(dirName, tryIndexers=True)
try: # if it fails to find any info (because we're doing an unparsable folder (like the TV root dir) it will throw an exception, which we want to ignore
parse_result = np.parse(dirName)
except Exception: # ignore the exception, because we kind of expected it, but create parse_result anyway so we can perform a check on it.
parse_result = False
search_sql = "SELECT tv_episodes.indexerid, history.resource FROM tv_episodes INNER JOIN history ON history.showid=tv_episodes.showid" # This part is always the same
search_sql += " WHERE history.season=tv_episodes.season and history.episode=tv_episodes.episode"
# If we find a showid, a season number, and one or more episode numbers then we need to use those in the query
if parse_result and (
parse_result.show.indexerid and parse_result.episode_numbers and parse_result.season_number
):
search_sql += (
" and tv_episodes.showid = '"
+ str(parse_result.show.indexerid)
+ "' and tv_episodes.season = '"
+ str(parse_result.season_number)
+ "' and tv_episodes.episode = '"
+ str(parse_result.episode_numbers[0])
+ "'"
)
search_sql += " and tv_episodes.status IN (" + ",".join([str(x) for x in common.Quality.DOWNLOADED]) + ")"
search_sql += " and history.resource LIKE ?"
sqlResult = myDB.select(search_sql, ["%" + videofile])
if sqlResult:
# result.output += logHelper(u"You're trying to post process a video that's already been processed, skipping", logger.DEBUG)
return True
return False
开发者ID:stvkno,项目名称:SickRage,代码行数:58,代码来源:processTV.py
示例12: _find_season_quality
def _find_season_quality(self,title, torrent_link, ep_number):
""" Return the modified title of a Season Torrent with the quality found inspecting torrent file list """
mediaExtensions = ['avi', 'mkv', 'wmv', 'divx',
'vob', 'dvr-ms', 'wtv', 'ts'
'ogv', 'rar', 'zip', 'mp4']
quality = Quality.UNKNOWN
fileName = None
data = self.getURL(torrent_link)
if not data:
return None
try:
soup = BeautifulSoup(data, features=["html5lib", "permissive"])
file_table = soup.find('table', attrs = {'class': 'torrentFileList'})
if not file_table:
return None
files = [x.text for x in file_table.find_all('td', attrs = {'class' : 'torFileName'} )]
videoFiles = filter(lambda x: x.rpartition(".")[2].lower() in mediaExtensions, files)
#Filtering SingleEpisode/MultiSeason Torrent
if len(videoFiles) < ep_number or len(videoFiles) > float(ep_number * 1.1 ):
logger.log(u"Result " + title + " Seem to be a Single Episode or MultiSeason torrent, skipping result...", logger.DEBUG)
return None
for fileName in videoFiles:
quality = Quality.sceneQuality(os.path.basename(fileName))
if quality != Quality.UNKNOWN: break
if fileName!=None and quality == Quality.UNKNOWN:
quality = Quality.assumeQuality(os.path.basename(fileName))
if quality == Quality.UNKNOWN:
logger.log(u"Unable to obtain a Season Quality for " + title, logger.DEBUG)
return None
try:
myParser = NameParser()
parse_result = myParser.parse(fileName)
except InvalidNameException:
return None
logger.log(u"Season quality for "+title+" is "+Quality.qualityStrings[quality], logger.DEBUG)
if parse_result.series_name and parse_result.season_number:
title = parse_result.series_name+' S%02d' % int(parse_result.season_number)+' '+self._reverseQuality(quality)
return title
except Exception, e:
logger.log(u"Failed parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR)
开发者ID:fldc,项目名称:Sick-Beard,代码行数:57,代码来源:kat.py
示例13: test_formating
def test_formating(self):
self.loadFromDB()
release = "d:\\Downloads\\newdownload\\2.Broke.Girls.S03E10.And.the.First.Day.of.School.720p.WEB-DL.DD5.1.H.264-BS.mkv"
# parse the name to break it into show name, season, and episode
np = NameParser(file)
parse_result = np.parse(release).convert()
print(parse_result)
开发者ID:Acio,项目名称:SickBeard-TVRage,代码行数:9,代码来源:xem_tests.py
示例14: _find_season_quality
def _find_season_quality(self, title, torrent_id):
""" Rewrite the title of a Season Torrent with the quality found inspecting torrent file list """
mediaExtensions = ["avi", "mkv", "wmv", "divx", "vob", "dvr-ms", "wtv", "ts" "ogv", "rar", "zip"]
quality = Quality.UNKNOWN
fileName = None
fileURL = self.proxy._buildURL(self.url + "ajax_details_filelist.php?id=" + str(torrent_id))
data = self.getURL(fileURL)
if not data:
return None
filesList = re.findall("<td.+>(.*?)</td>", data)
if not filesList:
logger.log(u"Unable to get the torrent file list for " + title, logger.ERROR)
# for fileName in filter(lambda x: x.rpartition(".")[2].lower() in mediaExtensions, filesList):
# quality = Quality.nameQuality(os.path.basename(fileName))
# if quality != Quality.UNKNOWN: break
for fileName in filesList:
sepFile = fileName.rpartition(".")
if fileName.rpartition(".")[2].lower() in mediaExtensions:
quality = Quality.nameQuality(fileName)
if quality != Quality.UNKNOWN:
break
if fileName != None and quality == Quality.UNKNOWN:
quality = Quality.assumeQuality(os.path.basename(fileName))
if quality == Quality.UNKNOWN:
logger.log(u"No Season quality for " + title, logger.DEBUG)
return None
try:
myParser = NameParser()
parse_result = myParser.parse(fileName)
except InvalidNameException:
return None
logger.log(u"Season quality for " + title + " is " + Quality.qualityStrings[quality], logger.DEBUG)
if parse_result.series_name and parse_result.season_number:
title = (
parse_result.series_name
+ " S%02d" % int(parse_result.season_number)
+ " "
+ self._reverseQuality(quality)
)
return title
开发者ID:majello,项目名称:Sick-Beard-Majello,代码行数:56,代码来源:thepiratebay.py
示例15: _find_season_quality
def _find_season_quality(self, title, torrent_id, ep_number):
""" Return the modified title of a Season Torrent with the quality found inspecting torrent file list """
if not self.url:
return False
quality = Quality.UNKNOWN
file_name = None
data = self.get_url('%sajax_details_filelist.php?id=%s' % (self.url, torrent_id))
if self.should_skip() or not data:
return None
files_list = re.findall('<td.+>(.*?)</td>', data)
if not files_list:
logger.log(u'Unable to get the torrent file list for ' + title, logger.ERROR)
video_files = filter(lambda x: x.rpartition('.')[2].lower() in mediaExtensions, files_list)
# Filtering SingleEpisode/MultiSeason Torrent
if ep_number > len(video_files) or float(ep_number * 1.1) < len(video_files):
logger.log(u'Result %s has episode %s and total episodes retrieved in torrent are %s'
% (title, str(ep_number), str(len(video_files))), logger.DEBUG)
logger.log(u'Result %s seems to be a single episode or multiseason torrent, skipping result...'
% title, logger.DEBUG)
return None
if Quality.UNKNOWN != Quality.sceneQuality(title):
return title
for file_name in video_files:
quality = Quality.sceneQuality(os.path.basename(file_name))
if Quality.UNKNOWN != quality:
break
if None is not file_name and Quality.UNKNOWN == quality:
quality = Quality.assumeQuality(os.path.basename(file_name))
if Quality.UNKNOWN == quality:
logger.log(u'Unable to obtain a Season Quality for ' + title, logger.DEBUG)
return None
try:
my_parser = NameParser(showObj=self.show, indexer_lookup=False)
parse_result = my_parser.parse(file_name)
except (InvalidNameException, InvalidShowException):
return None
logger.log(u'Season quality for %s is %s' % (title, Quality.qualityStrings[quality]), logger.DEBUG)
if parse_result.series_name and parse_result.season_number:
title = '%s S%02d %s' % (parse_result.series_name,
int(parse_result.season_number),
self._reverse_quality(quality))
return title
开发者ID:JackDandy,项目名称:SickGear,代码行数:56,代码来源:thepiratebay.py
示例16: validate_name
def validate_name(pattern, multi=None, anime_type=None, file_only=False, abd=False, sports=False):
"""
See if we understand a name
:param pattern: Name to analyse
:param multi: Is this a multi-episode name
:param anime_type: Is this anime
:param file_only: Is this just a file or a dir
:param abd: Is air-by-date enabled
:param sports: Is this sports
:return: True if valid name, False if not
"""
ep = generate_sample_ep(multi, abd, sports, anime_type)
new_name = ep.formatted_filename(pattern, multi, anime_type) + '.ext'
new_path = ep.formatted_dir(pattern, multi)
if not file_only:
new_name = ek(os.path.join, new_path, new_name)
if not new_name:
logging.debug("Unable to create a name out of " + pattern)
return False
logging.debug("Trying to parse " + new_name)
parser = NameParser(True, showObj=ep.show, naming_pattern=True)
try:
result = parser.parse(new_name)
except Exception:
logging.debug("Unable to parse " + new_name + ", not valid")
return False
logging.debug("The name " + new_name + " parsed into " + str(result))
if abd or sports:
if result.air_date != ep.airdate:
logging.debug("Air date incorrect in parsed episode, pattern isn't valid")
return False
elif anime_type != 3:
if len(result.ab_episode_numbers) and result.ab_episode_numbers != [x.absolute_number for x in
[ep] + ep.relatedEps]:
logging.debug("Absolute numbering incorrect in parsed episode, pattern isn't valid")
return False
else:
if result.season_number != ep.season:
logging.debug("Season number incorrect in parsed episode, pattern isn't valid")
return False
if result.episode_numbers != [x.episode for x in [ep] + ep.relatedEps]:
logging.debug("Episode numbering incorrect in parsed episode, pattern isn't valid")
return False
return True
开发者ID:coderbone,项目名称:SickRage,代码行数:53,代码来源:naming.py
示例17: _get_language
def _get_language(self, title=None, item=None):
if not title:
return 'en'
else:
try:
myParser = NameParser()
parse_result = myParser.parse(title)
except InvalidNameException:
logger.log(u"Unable to parse the filename "+title+" into a valid episode", logger.WARNING)
return 'en'
return parse_result.audio_langs
开发者ID:Franck69,项目名称:Sick-Beard,代码行数:12,代码来源:newznab.py
示例18: _addCacheEntry
def _addCacheEntry(self, name, url, parse_result=None, indexer_id=0):
# check if we passed in a parsed result or should we try and create one
if not parse_result:
# create showObj from indexer_id if available
showObj = None
if indexer_id:
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
try:
myParser = NameParser(showObj=showObj)
parse_result = myParser.parse(name)
except InvalidNameException:
logging.debug("Unable to parse the filename " + name + " into a valid episode")
return None
except InvalidShowException:
logging.debug("Unable to parse the filename " + name + " into a valid show")
return None
if not parse_result or not parse_result.series_name:
return None
# if we made it this far then lets add the parsed result to cache for usager later on
season = parse_result.season_number if parse_result.season_number else 1
episodes = parse_result.episode_numbers
if season and episodes:
# store episodes as a seperated string
episodeText = "|" + "|".join(map(str, episodes)) + "|"
# get the current timestamp
curTimestamp = int(time.mktime(datetime.datetime.today().timetuple()))
# get quality of release
quality = parse_result.quality
name = ss(name)
# get release group
release_group = parse_result.release_group
# get version
version = parse_result.version
logging.debug("Added RSS item: [" + name + "] to cache: [" + self.providerID + "]")
return [
"INSERT OR IGNORE INTO [" + self.providerID + "] (name, season, episodes, indexerid, url, time, quality, release_group, version) VALUES (?,?,?,?,?,?,?,?,?)",
[name, season, episodeText, parse_result.show.indexerid, url, curTimestamp, quality, release_group,
version]]
开发者ID:Sinap,项目名称:SickRage,代码行数:51,代码来源:tvcache.py
示例19: process
def process(self):
self._log(u"Failed download detected: (" + str(self.nzb_name) + ", " + str(self.dir_name) + ")")
releaseName = show_name_helpers.determineReleaseName(self.dir_name, self.nzb_name)
if releaseName is None:
self._log(u"Warning: unable to find a valid release name.", logger.WARNING)
raise exceptions.FailedProcessingFailed()
parser = NameParser(False)
try:
parsed = parser.parse(releaseName, True)
except InvalidNameException:
self._log(u"Error: release name is invalid: " + releaseName, logger.WARNING)
raise exceptions.FailedProcessingFailed()
logger.log(u"name_parser info: ", logger.DEBUG)
logger.log(u" - " + str(parsed.series_name), logger.DEBUG)
logger.log(u" - " + str(parsed.season_number), logger.DEBUG)
logger.log(u" - " + str(parsed.episode_numbers), logger.DEBUG)
logger.log(u" - " + str(parsed.extra_info), logger.DEBUG)
logger.log(u" - " + str(parsed.release_group), logger.DEBUG)
logger.log(u" - " + str(parsed.air_date), logger.DEBUG)
show_id = self._get_show_id(parsed.series_name)
if show_id is None:
self._log(u"Warning: couldn't find show ID", logger.WARNING)
raise exceptions.FailedProcessingFailed()
self._log(u"Found show_id: " + str(show_id), logger.DEBUG)
self._show_obj = helpers.findCertainShow(sickbeard.showList, show_id)
if self._show_obj is None:
self._log(u"Could not create show object. Either the show hasn't been added to SickBeard, or it's still loading (if SB was restarted recently)", logger.WARNING)
raise exceptions.FailedProcessingFailed()
# # Revert before fail, as fail alters the history
# self._log(u"Reverting episodes...")
# self.log += failed_history.revertEpisodes(self._show_obj, parsed.season_number, parsed.episode_numbers)
# self._log(u"Marking release as bad: " + releaseName)
# self.log += failed_history.logFailed(releaseName)
self.log += failed_history.markFailed(self._show_obj, parsed.season_number, parsed.episode_numbers)
# self._log(u"Marking release as Failed: " + releaseName)
# self.log += failed_history.logFailed(releaseName)
cur_failed_queue_item = search_queue.FailedQueueItem(self._show_obj, parsed.season_number)
sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item)
return True
开发者ID:mikevmil,项目名称:Sick-Beard,代码行数:49,代码来源:failedProcessor.py
示例20: parse_wrapper
def parse_wrapper(self, show=None, toParse='', showList=[], tvdbActiveLookUp=False):
"""Returns a parse result or a InvalidNameException
to get the tvdbid the tvdbapi might be used if tvdbActiveLookUp is True
"""
# TODO: refactor ABD into its own mode ... if done remove simple check in parse()
if len(showList) == 0:
showList = sickbeard.showList
try:
myParser = NameParser()
parse_result = myParser.parse(toParse)
except InvalidNameException:
raise InvalidNameException(u"Unable to parse: " + toParse)
else:
show = self.get_show_by_name(parse_result.series_name, showList, toParse, tvdbActiveLookUp)
return (parse_result, show)
开发者ID:089git,项目名称:Sick-Beard,代码行数:15,代码来源:completparser.py
注:本文中的sickbeard.name_parser.parser.NameParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论