本文整理汇总了Python中flexget.utils.titles.movie.MovieParser.data方法的典型用法代码示例。如果您正苦于以下问题:Python MovieParser.data方法的具体用法?Python MovieParser.data怎么用?Python MovieParser.data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexget.utils.titles.movie.MovieParser
的用法示例。
在下文中一共展示了MovieParser.data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_feed_exit
# 需要导入模块: from flexget.utils.titles.movie import MovieParser [as 别名]
# 或者: from flexget.utils.titles.movie.MovieParser import data [as 别名]
def on_feed_exit(self, feed, config):
"""Add downloaded movies to the database"""
log.debug('check for learning')
for entry in feed.accepted:
if 'imdb_id' not in entry:
log.debug('`%s` does not have imdb_id' % entry['title'])
continue
parser = MovieParser()
parser.data = entry['title']
parser.parse()
quality = parser.quality.name
log.debug('quality: %s' % quality)
log.debug('imdb_id: %s' % entry['imdb_id'])
log.debug('proper count: %s' % parser.proper_count)
proper_movie = feed.session.query(ProperMovie).\
filter(ProperMovie.imdb_id == entry['imdb_id']).\
filter(ProperMovie.quality == quality).\
filter(ProperMovie.proper_count == parser.proper_count).first()
if not proper_movie:
pm = ProperMovie()
pm.title = entry['title']
pm.feed = feed.name
pm.imdb_id = entry['imdb_id']
pm.quality = quality
pm.proper_count = parser.proper_count
feed.session.add(pm)
log.debug('added %s' % pm)
else:
log.debug('%s already exists' % proper_movie)
示例2: smart_match
# 需要导入模块: from flexget.utils.titles.movie import MovieParser [as 别名]
# 或者: from flexget.utils.titles.movie.MovieParser import data [as 别名]
def smart_match(self, raw_name):
"""Accepts messy name, cleans it and uses information available to make smartest and best match"""
from flexget.utils.titles.movie import MovieParser
parser = MovieParser()
parser.data = raw_name
parser.parse()
name = parser.name
year = parser.year
if name == '':
log.critical('Failed to parse name from %s' % raw_name)
return None
log.debug('smart_match name=%s year=%s' % (name, str(year)))
return self.best_match(name, year)
示例3: on_feed_filter
# 需要导入模块: from flexget.utils.titles.movie import MovieParser [as 别名]
# 或者: from flexget.utils.titles.movie.MovieParser import data [as 别名]
def on_feed_filter(self, feed, config):
log.debug('check for enforcing')
# parse config
if isinstance(config, bool):
# configured a boolean false, disable plugin
if not config:
return
# configured a boolean true, disable timeframe
timeframe = None
else:
# parse time window
amount, unit = config.split(' ')
log.debug('amount: %s unit: %s' % (repr(amount), repr(unit)))
params = {unit: int(amount)}
try:
timeframe = timedelta(**params)
except TypeError:
raise PluginError('Invalid time format', log)
# throws DependencyError if not present aborting feed
imdb_lookup = get_plugin_by_name('imdb_lookup').instance
for entry in feed.entries:
if 'imdb_id' not in entry:
try:
imdb_lookup.lookup(entry)
except PluginError, pe:
log_once(pe.value)
continue
parser = MovieParser()
parser.data = entry['title']
parser.parse()
quality = parser.quality.name
log.debug('quality: %s' % quality)
log.debug('imdb_id: %s' % entry['imdb_id'])
log.debug('current proper count: %s' % parser.proper_count)
proper_movie = feed.session.query(ProperMovie).\
filter(ProperMovie.imdb_id == entry['imdb_id']).\
filter(ProperMovie.quality == quality).\
order_by(desc(ProperMovie.proper_count)).first()
if not proper_movie:
log.debug('no previous download recorded for %s' % entry['imdb_id'])
continue
highest_proper_count = proper_movie.proper_count
log.debug('highest_proper_count: %i' % highest_proper_count)
accept_proper = False
if parser.proper_count > highest_proper_count:
log.debug('proper detected: %s ' % proper_movie)
if timeframe is None:
accept_proper = True
else:
expires = proper_movie.added + timeframe
log.debug('propers timeframe: %s' % timeframe)
log.debug('added: %s' % proper_movie.added)
log.debug('propers ignore after: %s' % str(expires))
if datetime.now() < expires:
accept_proper = True
else:
log.verbose('Proper `%s` has past it\'s expiration time' % entry['title'])
if accept_proper:
log.info('Accepting proper version previously downloaded movie `%s`' % entry['title'])
# TODO: does this need to be called?
# fire_event('forget', entry['imdb_url'])
fire_event('forget', entry['imdb_id'])
feed.accept(entry, 'proper version of previously downloaded movie')
示例4: on_feed_filter
# 需要导入模块: from flexget.utils.titles.movie import MovieParser [as 别名]
# 或者: from flexget.utils.titles.movie.MovieParser import data [as 别名]
def on_feed_filter(self, feed, config):
log.debug('check for enforcing')
# parse config
if isinstance(config, bool):
# configured a boolean false, disable plugin
if not config:
return
# configured a boolean true, disable timeframe
timeframe = None
else:
# parse time window
log.debug('interval: %s' % config)
try:
timeframe = parse_timedelta(config)
except ValueError:
raise PluginError('Invalid time format', log)
# throws DependencyError if not present aborting feed
imdb_lookup = get_plugin_by_name('imdb_lookup').instance
for entry in feed.entries:
parser = MovieParser()
parser.data = entry['title']
parser.parse()
# if we have imdb_id already evaluated
if entry.get('imdb_id', None, eval_lazy=False) is None:
try:
# TODO: fix imdb_id_lookup, cumbersome that it returns None and or throws exception
# Also it's crappy name!
imdb_id = imdb_lookup.imdb_id_lookup(movie_title=parser.name, raw_title=entry['title'])
if imdb_id is None:
continue
entry['imdb_id'] = imdb_id
except PluginError, pe:
log_once(pe.value)
continue
quality = parser.quality.name
log.debug('quality: %s' % quality)
log.debug('imdb_id: %s' % entry['imdb_id'])
log.debug('current proper count: %s' % parser.proper_count)
proper_movie = feed.session.query(ProperMovie).\
filter(ProperMovie.imdb_id == entry['imdb_id']).\
filter(ProperMovie.quality == quality).\
order_by(desc(ProperMovie.proper_count)).first()
if not proper_movie:
log.debug('no previous download recorded for %s' % entry['imdb_id'])
continue
highest_proper_count = proper_movie.proper_count
log.debug('highest_proper_count: %i' % highest_proper_count)
accept_proper = False
if parser.proper_count > highest_proper_count:
log.debug('proper detected: %s ' % proper_movie)
if timeframe is None:
accept_proper = True
else:
expires = proper_movie.added + timeframe
log.debug('propers timeframe: %s' % timeframe)
log.debug('added: %s' % proper_movie.added)
log.debug('propers ignore after: %s' % str(expires))
if datetime.now() < expires:
accept_proper = True
else:
log.verbose('Proper `%s` has past it\'s expiration time' % entry['title'])
if accept_proper:
log.info('Accepting proper version previously downloaded movie `%s`' % entry['title'])
# TODO: does this need to be called?
# fire_event('forget', entry['imdb_url'])
fire_event('forget', entry['imdb_id'])
feed.accept(entry, 'proper version of previously downloaded movie')
示例5: str
# 需要导入模块: from flexget.utils.titles.movie import MovieParser [as 别名]
# 或者: from flexget.utils.titles.movie.MovieParser import data [as 别名]
entry['series_name'][-4:], ')'])
log.verbose(entry['series_name'])
parser.data = cur_filename
parser.parse
log.debug(parser.id_type)
if parser.id_type == 'ep':
entry['series_id'] = ''.join(['S', str(parser.season).rjust(2, str('0')), 'E',
str(parser.episode).rjust(2, str('0'))])
elif parser.id_type == 'sequence':
entry['series_id'] = parser.episode
elif parser.id_type and parser.id:
entry['series_id'] = parser.id
else:
from flexget.utils.titles.movie import MovieParser
parser = MovieParser()
parser.data = cur_file
parser.parse()
log.info(parser)
testname = parser.name
testyear = parser.year
parser.data = entry['title']
parser.parse()
log.info(parser)
if len(parser.name) > len(testname):
entry['name'] = parser.name
entry['movie_name'] = parser.name
else:
entry['name'] = testname
entry['movie_name'] = testname
entry['year'] = parser.year
entry['movie_year'] = parser.year