- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 python 制作一个脚本,从一个页面下载一些视频,还有一些 Youtube 视频,所以我使用 youtube-dl 来下载它们。
问题是终端的所有信息都太脏了,我想隐藏它们。隐藏一切,保存路径,当前状态,只保留进度信息。如果我将安静模式设置为True,则不会显示进度信息。
我的代码:
def ytbDown(path, name, url):
ydl_opts = {
'outtmpl': path + name,
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
'quiet': False,
'warnings': 'no-warnings'}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
如果我使用该配置运行脚本,终端将以这种方式出现:
如果我将安静模式设置为 True,则不会出现任何内容,但我不想这样。我想仅保留进度状态(下载百分比、下载速度等)
有办法吗?感谢所有帮助,我正在使用 Python 3 和 Windows 7
最佳答案
from __future__ import unicode_literals
import youtube_dl
def my_hook(d):
if d['status'] == 'downloading':
print ("downloading "+ str(round(float(d['downloaded_bytes'])/float(d['total_bytes'])*100,1))+"%")
if d['status'] == 'finished':
filename=d['filename']
print(filename)
ydl_opts = {
'format': 'bestvideo[width<=1080]+bestaudio/best',
'quiet': True,
'no_warnings': True,
'progress_hooks': [my_hook]
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(sys.argv[1:])
可以用 ["www.youtube.com/....."]
替换 sys.argv[1:],包括方括号
引用关于嵌入的 youtube-dl 文档
https://github.com/ytdl-org/youtube-dl/blob/master/README.md#embedding-youtube-dl
关于python - 如何使用 youtube-dl 只显示进度信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63025605/
所以我有一个类似这样的 dl 列表: .title { display: inline-block; padding-bottom: 20px; } dd { -moz-margin-st
我想使用代理并运行它youtube-dl --proxy socks5://127.0.0.1:1080 这是下面的错误 Usage: youtube-dl [OPTIONS] URL [URL...
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve thi
[Windows 10] 我有一个包含 128 个项目的视频播放列表 URL,我已经从同一个播放列表 URL 下载了 25 个视频。现在我想从 26 索引开始下载剩余的视频,但我无法使用 --paly
我正在使用 youtube-dl 从 youtube 下载播放列表。我使用自动编号功能对视频进行编号,这可以通过格式化输出文件的名称来实现,如下 -o "%(autonumber)s-%(title)
我正在显示 的列表tags 我页面中的标签。我想要 当标签的内容足够长以超出 的高度时不换行. 什么 css 可以防止这种情况发生? 最佳答案 我会使用 margin-left在 上等于 的宽
此命令下载视频并将自动生成的 youtube 字幕嵌入到文件中 youtube-dl.exe -ci -f "bestvideo[ext=mp4]"+"bestaudio[ext=m4a]" --wr
我在fedora 116上使用gcc/g++,我的想法是: c program -> load c++ dynamic library A -> load c++ dynamic library B
嗯,我可以在终端中使用它直接获取视频格式 - $ youtube-dl -F "some youtube url" 输出: [youtube] Setting language [youtube] P
我的 youtube-dl 库 ( https://rg3.github.io/youtube-dl/ ) 有问题。我使用 youtube-dl 不是通过这个库直接下载视频,而是我首先使用这样的命令生
关闭。这个问题需要details or clarity .它目前不接受答案。 想要改进这个问题吗? 通过 editing this post 添加详细信息并澄清问题. 关闭 8 年前。 Improve
我是 Android Studio 的新手,每次我尝试将项目与 gradle 同步时都会收到此错误。例如,我提供了对三个文件的引用。 1)项目级build.gradle文件 plugins {
更新 Gradle 后出现以下问题。我找不到任何解决方案。所以请帮我解决以下问题。提前致谢... (问题 ----- 无法获取“https://dl.google.com/dl/android/mav
我最近开始使用 react native,但是根据伊朗人的制裁,gradle 不能构建我的第一个项目,所以我使用了 VPN 和 shecan service但我收到以下错误: 我阅读了 React n
在Firebase身份验证(助手)中使用将Firebase身份验证添加到您的应用程序时出错。 该错误在“同步”标签中显示为: Could not GET 'https://dl.google.com/
我无法在 Android Studio 中构建项目,并且收到以下错误。 Gradle 同步失败。 无法获取“https://dl.google.com/dl/android/maven2/com/an
我正在尝试将 youtube 视频保存为我的下载文件夹中的 MP3。但是,这最终会将文件保存在与 youtube-dl 相同的目录中。 youtube-dl --extract-audio --aud
我正在使用 youtube-dl用于从 YouTube 下载视频。但是在我的办公室,互联网会每隔 20Mb 断开一次。的下载。 [错误:连接被远程服务器强行关闭]。 我必须再次输入 URL 才能继续下
好的,我知道要在您使用的python程序中从Youtube-DL获取Mp3文件 from __future__ import unicode_literals import youtube_dl yd
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic
我是一名优秀的程序员,十分优秀!