Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XianxinMao
Yt Dlp
提交
b5ac45b1
Y
Yt Dlp
项目概览
XianxinMao
/
Yt Dlp
12 个月 前同步成功
通知
27
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
Yt Dlp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b5ac45b1
编写于
7月 07, 2021
作者:
P
pukkandan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix selectors `all`, `mergeall` and add tests
Bug from:
981052c9
上级
38a40c9e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
29 deletion
+22
-29
test/test_YoutubeDL.py
test/test_YoutubeDL.py
+21
-29
yt_dlp/YoutubeDL.py
yt_dlp/YoutubeDL.py
+1
-0
未找到文件。
test/test_YoutubeDL.py
浏览文件 @
b5ac45b1
...
@@ -35,6 +35,9 @@ def process_info(self, info_dict):
...
@@ -35,6 +35,9 @@ def process_info(self, info_dict):
def
to_screen
(
self
,
msg
):
def
to_screen
(
self
,
msg
):
self
.
msgs
.
append
(
msg
)
self
.
msgs
.
append
(
msg
)
def
dl
(
self
,
*
args
,
**
kwargs
):
assert
False
,
'Downloader must not be invoked for test_YoutubeDL'
def
_make_result
(
formats
,
**
kwargs
):
def
_make_result
(
formats
,
**
kwargs
):
res
=
{
res
=
{
...
@@ -117,35 +120,24 @@ def test_format_selection(self):
...
@@ -117,35 +120,24 @@ def test_format_selection(self):
]
]
info_dict
=
_make_result
(
formats
)
info_dict
=
_make_result
(
formats
)
ydl
=
YDL
({
'format'
:
'20/47'
})
def
test
(
inp
,
*
expected
,
multi
=
False
):
ydl
.
process_ie_result
(
info_dict
.
copy
())
ydl
=
YDL
({
downloaded
=
ydl
.
downloaded_info_dicts
[
0
]
'format'
:
inp
,
self
.
assertEqual
(
downloaded
[
'format_id'
],
'47'
)
'allow_multiple_video_streams'
:
multi
,
'allow_multiple_audio_streams'
:
multi
,
ydl
=
YDL
({
'format'
:
'20/71/worst'
})
})
ydl
.
process_ie_result
(
info_dict
.
copy
())
ydl
.
process_ie_result
(
info_dict
.
copy
())
downloaded
=
ydl
.
downloaded_info_dicts
[
0
]
downloaded
=
map
(
lambda
x
:
x
[
'format_id'
],
ydl
.
downloaded_info_dicts
)
self
.
assertEqual
(
downloaded
[
'format_id'
],
'35'
)
self
.
assertEqual
(
list
(
downloaded
),
list
(
expected
))
ydl
=
YDL
()
test
(
'20/47'
,
'47'
)
ydl
.
process_ie_result
(
info_dict
.
copy
())
test
(
'20/71/worst'
,
'35'
)
downloaded
=
ydl
.
downloaded_info_dicts
[
0
]
test
(
None
,
'2'
)
self
.
assertEqual
(
downloaded
[
'format_id'
],
'2'
)
test
(
'webm/mp4'
,
'47'
)
test
(
'3gp/40/mp4'
,
'35'
)
ydl
=
YDL
({
'format'
:
'webm/mp4'
})
test
(
'example-with-dashes'
,
'example-with-dashes'
)
ydl
.
process_ie_result
(
info_dict
.
copy
())
test
(
'all'
,
'35'
,
'example-with-dashes'
,
'45'
,
'47'
,
'2'
)
# Order doesn't actually matter for this
downloaded
=
ydl
.
downloaded_info_dicts
[
0
]
test
(
'mergeall'
,
'2+47+45+example-with-dashes+35'
,
multi
=
True
)
self
.
assertEqual
(
downloaded
[
'format_id'
],
'47'
)
ydl
=
YDL
({
'format'
:
'3gp/40/mp4'
})
ydl
.
process_ie_result
(
info_dict
.
copy
())
downloaded
=
ydl
.
downloaded_info_dicts
[
0
]
self
.
assertEqual
(
downloaded
[
'format_id'
],
'35'
)
ydl
=
YDL
({
'format'
:
'example-with-dashes'
})
ydl
.
process_ie_result
(
info_dict
.
copy
())
downloaded
=
ydl
.
downloaded_info_dicts
[
0
]
self
.
assertEqual
(
downloaded
[
'format_id'
],
'example-with-dashes'
)
def
test_format_selection_audio
(
self
):
def
test_format_selection_audio
(
self
):
formats
=
[
formats
=
[
...
...
yt_dlp/YoutubeDL.py
浏览文件 @
b5ac45b1
...
@@ -1758,6 +1758,7 @@ def _merge(formats_pair):
...
@@ -1758,6 +1758,7 @@ def _merge(formats_pair):
def
_check_formats
(
formats
):
def
_check_formats
(
formats
):
if
not
check_formats
:
if
not
check_formats
:
yield
from
formats
yield
from
formats
return
for
f
in
formats
:
for
f
in
formats
:
self
.
to_screen
(
'[info] Testing format %s'
%
f
[
'format_id'
])
self
.
to_screen
(
'[info] Testing format %s'
%
f
[
'format_id'
])
temp_file
=
tempfile
.
NamedTemporaryFile
(
temp_file
=
tempfile
.
NamedTemporaryFile
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录