本文整理汇总了Python中Manager.Manager.clean方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.clean方法的具体用法?Python Manager.clean怎么用?Python Manager.clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Manager.Manager
的用法示例。
在下文中一共展示了Manager.clean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Manager import Manager [as 别名]
# 或者: from Manager.Manager import clean [as 别名]
def main():
# Parsing Options & Args
parser = OptionParser(description = '%prog Download subtitles from titulky.com',
usage = '%prog [OPTION]... [URL]...',
epilog = 'Support: Otto Sabart (www.seberm.com / [email protected])',
version = '%prog ' + VERSION)
options = OptionGroup(parser, 'Program Options', 'Options specific to titulky_com_downloader.')
options.add_option('-l', '--link', dest='link', action='store_true',
help='Print download link(s) on stdout (default behaviour)')
options.add_option('-e', '--page-encoding', dest='pageEncoding', action='store', metavar='<encoding>', default=PAGE_ENCODING,
help='Sets webpage encoding - default [cp1250]')
options.add_option('-n', '--with-info', dest='withInfo', action='store_true',
help='Print download links with movie name and number of secs to link activation')
options.add_option('-p', '--dir', dest='dir', action='store',
help='Change program directory')
options.add_option('--login', dest='login', action='store_true',
help='Login to netusers.cz (titulky.com)')
options.add_option('--log', dest='logLevel', action='store', default=DEFAULT_LOGGING_LEVEL,
help='Set logging level (debug, info, warning, error, critical)')
options.add_option('-i', '--vip', dest='vip', action='store_true',
help='Set up a VIP user download (we don\'t want to wait for download)')
# @todo Remove warning message in following option
options.add_option('-d', '--download', dest='download', action='store_true',
help='Download subtitles to current folder (sometimes does not work - use option -l in combination with wget - just take a look to README)')
# @todo it will be possible to add prefix to downloaded files
#options.add_option('--prefix', dest='prefix', action='store_true',
# help='Set prefix to downloaded files')
# @todo will be possible to download with direct link
#options.add_option('--direct-link', dest='directLink', action='store_true',
# help='Direct link to iframe')
parser.add_option_group(options)
(opt, args) = parser.parse_args()
# Do some logging stuff
try:
logging.basicConfig(format=DEFAULT_LOGGING_FORMAT, level=opt.logLevel.upper())
debug('Setting logging mode to: %s' % opt.logLevel.upper())
except ValueError:
logging.basicConfig(format=DEFAULT_LOGGING_FORMAT, level=DEFAULT_LOGGING_LEVEL)
warning('It is not possible to set logging level to %s' % opt.logLevel.upper())
warning('Using default setting logging level: %s' % DEFAULT_LOGGING_LEVEL)
if opt.dir:
debug('Changing default program directory to %s' % opt.dir)
os.chdir(opt.dir)
if not args[0:]:
error('You have to provide an URL address!')
sys.exit(1)
debug('Page encoding: %s' % opt.pageEncoding)
from Manager import Manager
manager = Manager(encoding=opt.pageEncoding)
if opt.login:
login = input('[netusers.cz] Login: ')
password = getpass('[netusers.cz] Password: ')
manager.logIn(login=login, password=password)
if opt.vip:
manager.userVIP()
for arg in args:
manager.getSubtitleSourceLinks(urlparse(arg))
if opt.download:
manager.downloadFiles()
if opt.withInfo:
manager.showWithInfo()
if opt.withInfo or not opt.download:
manager.printLinks()
manager.clean()