本文整理汇总了Python中sickbeard.helpers.remove_extension函数的典型用法代码示例。如果您正苦于以下问题:Python remove_extension函数的具体用法?Python remove_extension怎么用?Python remove_extension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_extension函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _finalize
def _finalize(self, parse_result):
"""
Store parse result if it is complete and final
:param parse_result: Result of parsers
"""
self.release_group = parse_result.release_group
# remember whether it's a proper
if parse_result.extra_info:
self.is_proper = re.search(r'(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info, re.I) != None
# if the result is complete then remember that for later
# if the result is complete then set release name
if parse_result.series_name and ((parse_result.season_number is not None and parse_result.episode_numbers)
or parse_result.air_date) and parse_result.release_group:
if not self.release_name:
self.release_name = helpers.remove_non_release_groups(helpers.remove_extension(ek(os.path.basename, parse_result.original_name)))
else:
logger.log(u"Parse result not sufficient (all following have to be set). will not save release name",
logger.DEBUG)
logger.log(u"Parse result(series_name): " + str(parse_result.series_name), logger.DEBUG)
logger.log(u"Parse result(season_number): " + str(parse_result.season_number), logger.DEBUG)
logger.log(u"Parse result(episode_numbers): " + str(parse_result.episode_numbers), logger.DEBUG)
logger.log(u" or Parse result(air_date): " + str(parse_result.air_date), logger.DEBUG)
logger.log(u"Parse result(release_group): " + str(parse_result.release_group), logger.DEBUG)
开发者ID:nono20004,项目名称:SickRage,代码行数:28,代码来源:postProcessor.py
示例2: parse
def parse(self, name):
name = self._unicodify(name)
cached = name_parser_cache.get(name)
if cached:
return cached
# break it into parts if there are any (dirname, file name, extension)
dir_name, file_name = ek.ek(os.path.split, name)
if self.is_file_name:
base_file_name = helpers.remove_non_release_groups(helpers.remove_extension(file_name))
else:
base_file_name = file_name
# use only the direct parent dir
dir_name = ek.ek(os.path.basename, dir_name)
# set up a result to use
final_result = ParseResult(name)
# try parsing the file name
file_name_result = self._parse_string(base_file_name)
# parse the dirname for extra info if needed
dir_name_result = self._parse_string(dir_name)
# build the ParseResult object
final_result.air_date = self._combine_results(file_name_result, dir_name_result, 'air_date')
if not final_result.air_date:
final_result.season_number = self._combine_results(file_name_result, dir_name_result, 'season_number')
final_result.episode_numbers = self._combine_results(file_name_result, dir_name_result, 'episode_numbers')
final_result.is_proper = self._combine_results(file_name_result, dir_name_result, 'is_proper')
# if the dirname has a release group/show name I believe it over the filename
final_result.series_name = self._combine_results(dir_name_result, file_name_result, 'series_name')
final_result.extra_info = self._combine_results(dir_name_result, file_name_result, 'extra_info')
final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
final_result.which_regex = []
if final_result == file_name_result:
final_result.which_regex = file_name_result.which_regex
elif final_result == dir_name_result:
final_result.which_regex = dir_name_result.which_regex
else:
if file_name_result:
final_result.which_regex += file_name_result.which_regex
if dir_name_result:
final_result.which_regex += dir_name_result.which_regex
# if there's no useful info in it then raise an exception
if final_result.season_number is None and not final_result.episode_numbers and final_result.air_date is None and not final_result.series_name:
raise InvalidNameException("Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace'))
name_parser_cache.add(name, final_result)
# return it
return final_result
开发者ID:PermaNulled,项目名称:SickBeard-XG,代码行数:60,代码来源:parser.py
示例3: _finalize
def _finalize(self, parse_result):
self.release_group = parse_result.release_group
# remember whether it's a proper
self.is_proper = parse_result.is_proper
# if the result is complete then set release name
if (
parse_result.series_name
and ((parse_result.season_number is not None and parse_result.episode_numbers) or parse_result.air_date)
and parse_result.release_group
):
if not self.release_name:
self.release_name = helpers.remove_extension(ek.ek(os.path.basename, parse_result.original_name))
else:
logger.log(
u"Parse result not sufficient (all following have to be set). will not save release name", logger.DEBUG
)
logger.log(u"Parse result(series_name): " + str(parse_result.series_name), logger.DEBUG)
logger.log(u"Parse result(season_number): " + str(parse_result.season_number), logger.DEBUG)
logger.log(u"Parse result(episode_numbers): " + str(parse_result.episode_numbers), logger.DEBUG)
logger.log(u" or Parse result(air_date): " + str(parse_result.air_date), logger.DEBUG)
logger.log(u"Parse result(release_group): " + str(parse_result.release_group), logger.DEBUG)
开发者ID:BrokenRSA,项目名称:Sick-Beard,代码行数:26,代码来源:postProcessor.py
示例4: _get_quality
def _get_quality(self, ep_obj):
"""
Determines the quality of the file that is being post processed by parsing through the data available.
ep_obj: The TVEpisode object related to the file we are post processing
Returns: A quality value found in common.Quality
"""
ep_quality = common.Quality.UNKNOWN
# nzb name is the most reliable if it exists, followed by folder name and lastly file name
filename = self.file_name;
orig_extension = filename.rpartition('.')[-1]
filename = helpers.handle_reversed_names(helpers.remove_extension(filename)) + '.' + orig_extension
name_list = [self.nzb_name, self.folder_name, filename]
# search all possible names for our new quality, in case the file or dir doesn't have it
for cur_name in name_list:
# some stuff might be None at this point still
if not cur_name:
continue
ep_quality = common.Quality.nameQuality(cur_name)
self._log(u"Looking up quality for name " + cur_name + u", got " + common.Quality.qualityStrings[ep_quality], logger.DEBUG)
# if we find a good one then use it
if ep_quality != common.Quality.UNKNOWN:
logger.log(cur_name + u" looks like it has quality " + common.Quality.qualityStrings[ep_quality] + ", using that", logger.DEBUG)
return ep_quality
# Try getting quality from the episode (snatched) status
if ep_obj.status in common.Quality.SNATCHED + common.Quality.SNATCHED_PROPER:
oldStatus, ep_quality = common.Quality.splitCompositeStatus(ep_obj.status) # @UnusedVariable
if ep_quality != common.Quality.UNKNOWN:
self._log(u"The old status had a quality in it, using that: " + common.Quality.qualityStrings[ep_quality], logger.DEBUG)
return ep_quality
# Try guessing quality from the file name
ep_quality = common.Quality.assumeQuality(filename)
self._log(u"Guessing quality for name " + filename + u", got " + common.Quality.qualityStrings[ep_quality], logger.DEBUG)
if ep_quality != common.Quality.UNKNOWN:
logger.log(filename + u" looks like it has quality " + common.Quality.qualityStrings[ep_quality] + ", using that", logger.DEBUG)
return ep_quality
return ep_quality
开发者ID:riksmith,项目名称:Sick-Beard,代码行数:47,代码来源:postProcessor.py
示例5: _analyze_name
def _analyze_name(self, name, file=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, None)
if not name:
return to_return
name = helpers.remove_non_release_groups(helpers.remove_extension(name))
# parse the name to break it into show name, season, and episode
np = NameParser(file, tryIndexers=True, convert=True)
parse_result = np.parse(name)
# show object
show = parse_result.show
if parse_result.is_air_by_date:
season = -1
episodes = [parse_result.air_date]
elif parse_result.is_sports:
season = -1
episodes = [parse_result.sports_air_date]
else:
season = parse_result.season_number
episodes = parse_result.episode_numbers
to_return = (show, season, episodes, parse_result.quality, None)
self._finalize(parse_result)
return to_return
开发者ID:GreenOst,项目名称:SickRage,代码行数:40,代码来源:postProcessor.py
示例6: _finalize
def _finalize(self, parse_result):
self.release_group = parse_result.release_group
# remember whether it's a proper
if parse_result.extra_info:
self.is_proper = None is not re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info, re.I)
# if the result is complete then set release name
if parse_result.series_name and\
((None is not parse_result.season_number and parse_result.episode_numbers) or parse_result.air_date)\
and parse_result.release_group:
if not self.release_name:
self.release_name = helpers.remove_extension(ek.ek(os.path.basename, parse_result.original_name))
else:
logger.log(u'Parse result not sufficient (all following have to be set). will not save release name', logger.DEBUG)
logger.log(u'Parse result(series_name): ' + str(parse_result.series_name), logger.DEBUG)
logger.log(u'Parse result(season_number): ' + str(parse_result.season_number), logger.DEBUG)
logger.log(u'Parse result(episode_numbers): ' + str(parse_result.episode_numbers), logger.DEBUG)
logger.log(u' or Parse result(air_date): ' + str(parse_result.air_date), logger.DEBUG)
logger.log(u'Parse result(release_group): ' + str(parse_result.release_group), logger.DEBUG)
开发者ID:Koernia,项目名称:SickGear,代码行数:23,代码来源:postProcessor.py
示例7: _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
name = helpers.remove_non_release_groups(helpers.remove_extension(name))
# parse the name to break it into show name, season, and episode
np = NameParser(resource, try_indexers=True, try_scene_exceptions=True, convert=True)
parse_result = np.parse(name)
self._log(u'Parsed %s<br />.. into %s' % (name, str(parse_result).decode('utf-8', 'xmlcharrefreplace')), 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:Koernia,项目名称:SickGear,代码行数:37,代码来源:postProcessor.py
示例8: execute
def execute(self):
backupDatabase(16)
logger.log(u"Setting special episodes status to SKIPPED.")
self.connection.action("UPDATE tv_episodes SET status = ? WHERE status = ? AND season = 0", [common.SKIPPED, common.WANTED])
fix_ep_rls_group = []
fix_ep_release_name = []
# re-analyze snatched data
logger.log(u"Analyzing history to correct bad data (this could take a moment, be patient)...")
history_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 2 ORDER BY date ASC")
for cur_result in history_results:
# find the associated download, if there isn't one then ignore it
download_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 4 AND showid = ? AND season = ? AND episode = ? AND quality = ? AND date > ?",
[cur_result["showid"], cur_result["season"], cur_result["episode"], cur_result["quality"], cur_result["date"]])
# only continue if there was a download found (thats newer than the snatched)
if not download_results:
logger.log(u"Found a snatch in the history for " + cur_result["resource"] + " but couldn't find the associated download, skipping it", logger.DEBUG)
continue
# take the snatched nzb, clean it up so we can store it for the corresponding tv_episodes entry
clean_nzb_name = helpers.remove_non_release_groups(helpers.remove_extension(cur_result["resource"]))
# fixed known bad release_group data
if download_results[0]["provider"].upper() in ["-1", "RP", "NZBGEEK"] or "." in download_results[0]["provider"]:
try:
np = NameParser(False)
parse_result = np.parse(clean_nzb_name)
except InvalidNameException:
continue
# leave off check for episode number so we can update season rip data as well?
if parse_result.series_name and parse_result.season_number is not None and parse_result.release_group:
fix_ep_rls_group.append(["UPDATE history SET provider = ? WHERE action = ? AND showid = ? AND season = ? AND episode = ? AND quality = ? AND date = ?", \
[parse_result.release_group, download_results[0]["action"], download_results[0]["showid"], download_results[0]["season"], download_results[0]["episode"], download_results[0]["quality"], download_results[0]["date"]]
])
# find the associated episode on disk
ep_results = self.connection.select("SELECT episode_id, status, release_name FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ? AND location != ''",
[cur_result["showid"], cur_result["season"], cur_result["episode"]])
if not ep_results:
logger.log(u"The episode " + cur_result["resource"] + " was found in history but doesn't exist on disk anymore, skipping", logger.DEBUG)
continue
# skip items that appears to have a 'scene' name already to avoid replacing locally pp/manually moved items
match = re.search(".(xvid|x264|h.?264|mpeg-?2)", ep_results[0]["release_name"], re.I)
if match:
continue
# get the status/quality of the existing ep and make sure it's what we expect
ep_status, ep_quality = common.Quality.splitCompositeStatus(int(ep_results[0]["status"]))
if ep_status != common.DOWNLOADED:
continue
if ep_quality != int(cur_result["quality"]):
continue
# take the extension off the filename, it's not needed
file_name = ek.ek(os.path.basename, download_results[0]["resource"])
if '.' in file_name:
file_name = file_name.rpartition('.')[0]
# make sure this is actually a real release name and not a season pack or something
for cur_name in (clean_nzb_name, file_name):
logger.log(u"Checking if " + cur_name + " is actually a good release name", logger.DEBUG)
try:
np = NameParser(False)
parse_result = np.parse(cur_name)
except InvalidNameException:
continue
if parse_result.series_name and parse_result.season_number is not None and parse_result.episode_numbers and parse_result.release_group:
# if all is well by this point we'll just put the release name into the database
fix_ep_release_name.append(["UPDATE tv_episodes SET release_name = ? WHERE episode_id = ?", [cur_name, ep_results[0]["episode_id"]]])
break
logger.log(u"Corrected " + str(len(fix_ep_release_name)) + " release names (" + str(len(fix_ep_rls_group)) + " release groups) out of the " + str(len(history_results)) + " releases analyzed.")
if len(fix_ep_rls_group) > 0:
self.connection.mass_action(fix_ep_rls_group)
if len(fix_ep_release_name) > 0:
self.connection.mass_action(fix_ep_release_name)
# now cleanup all downloaded release groups in the history
fix_ep_rls_group = []
logger.log(u"Analyzing downloaded history release groups...")
history_results = self.connection.select("SELECT * FROM history WHERE action % 100 = 4 ORDER BY date ASC")
for cur_result in history_results:
clean_provider = helpers.remove_non_release_groups(helpers.remove_extension(cur_result["provider"]))
# take the data on the left of the _, fixes 'LOL_repost'
if clean_provider and "_" in clean_provider:
clean_provider = clean_provider.rsplit('_', 1)[0]
if clean_provider != cur_result["provider"]:
fix_ep_rls_group.append(["UPDATE history SET provider = ? WHERE action = ? AND showid = ? AND season = ? AND episode = ? AND quality = ? AND date = ?", \
[clean_provider, cur_result["action"], cur_result["showid"], cur_result["season"], cur_result["episode"], cur_result["quality"], cur_result["date"]]
])
logger.log(u"Corrected " + str(len(fix_ep_rls_group)) + " release groups.")
if len(fix_ep_rls_group) > 0:
self.connection.mass_action(fix_ep_rls_group)
#.........这里部分代码省略.........
开发者ID:riksmith,项目名称:Sick-Beard,代码行数:101,代码来源:mainDB.py
示例9: parse
def parse(self, name, cache_result=True):
if self.naming_pattern:
cache_result = False
cached = name_parser_cache.get(name)
if cached:
return cached
# break it into parts if there are any (dirname, file name, extension)
dir_name, file_name = ek(os.path.split, name)
if self.file_name:
base_file_name = helpers.remove_extension(file_name)
else:
base_file_name = file_name
# set up a result to use
final_result = ParseResult(name)
# try parsing the file name
file_name_result = self._parse_string(base_file_name)
# use only the direct parent dir
dir_name = ek(os.path.basename, dir_name)
# parse the dirname for extra info if needed
dir_name_result = self._parse_string(dir_name)
# build the ParseResult object
final_result.air_date = self._combine_results(file_name_result, dir_name_result, 'air_date')
# anime absolute numbers
final_result.ab_episode_numbers = self._combine_results(file_name_result, dir_name_result, 'ab_episode_numbers')
# season and episode numbers
final_result.season_number = self._combine_results(file_name_result, dir_name_result, 'season_number')
final_result.episode_numbers = self._combine_results(file_name_result, dir_name_result, 'episode_numbers')
# if the dirname has a release group/show name I believe it over the filename
final_result.series_name = self._combine_results(dir_name_result, file_name_result, 'series_name')
final_result.extra_info = self._combine_results(dir_name_result, file_name_result, 'extra_info')
final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
final_result.version = self._combine_results(dir_name_result, file_name_result, 'version')
final_result.which_regex = []
if final_result == file_name_result:
final_result.which_regex = file_name_result.which_regex
elif final_result == dir_name_result:
final_result.which_regex = dir_name_result.which_regex
else:
if file_name_result:
final_result.which_regex += file_name_result.which_regex
if dir_name_result:
final_result.which_regex += dir_name_result.which_regex
final_result.show = self._combine_results(file_name_result, dir_name_result, 'show')
final_result.quality = self._combine_results(file_name_result, dir_name_result, 'quality')
if not final_result.show:
raise InvalidShowException(
"Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace'))
# if there's no useful info in it then raise an exception
if final_result.season_number is None and not final_result.episode_numbers and final_result.air_date is None and not final_result.ab_episode_numbers and not final_result.series_name:
raise InvalidNameException("Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace'))
if cache_result:
name_parser_cache.add(name, final_result)
logger.log("Parsed " + name + " into " + ss(final_result), logger.DEBUG)
return final_result
开发者ID:zeroX-tj,项目名称:SickRage,代码行数:71,代码来源:parser.py
注:本文中的sickbeard.helpers.remove_extension函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论