本文整理汇总了Python中youtube_dl.YoutubeDL.params['restrictfilenames']方法的典型用法代码示例。如果您正苦于以下问题:Python YoutubeDL.params['restrictfilenames']方法的具体用法?Python YoutubeDL.params['restrictfilenames']怎么用?Python YoutubeDL.params['restrictfilenames']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类youtube_dl.YoutubeDL
的用法示例。
在下文中一共展示了YoutubeDL.params['restrictfilenames']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_url
# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import params['restrictfilenames'] [as 别名]
def process_url(self, source, global_opts):
"""Main method for processing urls
This method basically hands over the configuration to YoutubeDL and repeats
the step until every source in the configuration was read
"""
ydl = YoutubeDL()
ydl.add_default_info_extractors()
sourceUrl = source['url']
sourceDescription = source.get("description", "")
self._logsource(
"Processing source: '" + sourceDescription +
"' Url: '" + sourceUrl + "'", source)
# Merge local parameters with global ones
ydl.params = copy.copy(global_opts)
ydl.params.update(source)
prefix = ""
ydl.params['match_filter'] = (
None if 'match_filter' not in ydl.params or ydl.params['match_filter'] is None
else match_filter_func(ydl.params['match_filter']))
# Settings by commute tube over the standard settings, respect if the config sets them differently
if 'format' not in ydl.params and 'format_limit' not in ydl.params:
ydl.params['format'] = "bestvideo+bestaudio/best" if 'format' not in self.config else self.config["format"]
if 'nooverwrites' not in ydl.params:
ydl.params['nooverwrites'] = True
if 'ignoreerrors' not in ydl.params:
ydl.params['ignoreerrors'] = True
if 'download_archive' not in ydl.params:
ydl.params['download_archive'] = self.download_archive
if 'prefix' in ydl.params:
prefix = ydl.params['prefix']
ydl.params['restrictfilenames'] = True
ydl.params['logger'] = self.ydlLog
outtmpl = self.pathToDownloadFolder + "/" + prefix + \
'%(uploader)s-%(title)s.%(ext)s'
if 'outtmpl' not in ydl.params:
ydl.params['outtmpl'] = outtmpl
elif not (ydl.params['outtmpl'].startswith(self.pathToDownloadFolder)):
self._logsource("Prefixing custom set outtmpl with '" + self.pathToDownloadFolder + "/" + prefix + "'", source)
ydl.params['outtmpl'] = self.pathToDownloadFolder + "/" + prefix + \
ydl.params['outtmpl']
if self.debug:
self._logsource(
"All downloads will be simulated since this is debug mode", source)
ydl.params['simulate'] = True
ydl.download([source['url']])
示例2: processUrl
# 需要导入模块: from youtube_dl import YoutubeDL [as 别名]
# 或者: from youtube_dl.YoutubeDL import params['restrictfilenames'] [as 别名]
def processUrl(self, source):
ydl = YoutubeDL()
ydl.add_default_info_extractors()
sourceUrl = source['url'].decode()
sourceDescription = ""
if 'description' in source:
sourceDescription = source['description'].decode()
self.log.info(
"Processing source: '" + sourceDescription
+ "' Url: '" + sourceUrl + "'")
ydl.params = source
prefix = ""
if 'format' not in ydl.params and 'format_limit' not in ydl.params:
ydl.params['format'] = "bestvideo+bestaudio"
if 'nooverwrites' not in ydl.params:
ydl.params['nooverwrites'] = True
if 'ignoreerrors' not in ydl.params:
ydl.params['ignoreerrors'] = True
if 'download_archive' not in ydl.params:
ydl.params['download_archive'] = "already_downloaded.txt"
if 'prefix' in ydl.params:
prefix = ydl.params['prefix']
ydl.params['restrictfilenames'] = True
ydl.params['logger'] = self.ydlLog
outtmpl = self.pathToDownloadFolder + "/" + prefix + \
u'%(uploader)s-%(title)s-%(id)s.%(ext)s'
if 'outtmpl' not in ydl.params:
ydl.params['outtmpl'] = outtmpl
if self.debug is True:
self.log.debug(
"All downloads will be simulated since this is debug mode")
ydl.params['simulate'] = True
ydl.download([source['url']])