Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XianxinMao
Yt Dlp
提交
6148833f
Y
Yt Dlp
项目概览
XianxinMao
/
Yt Dlp
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
6148833f
编写于
7月 30, 2023
作者:
P
pukkandan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cleanup] Misc
上级
8cb7fc44
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
27 addition
and
25 deletion
+27
-25
test/test_YoutubeDL.py
test/test_YoutubeDL.py
+1
-0
test/test_networking.py
test/test_networking.py
+5
-3
yt_dlp/YoutubeDL.py
yt_dlp/YoutubeDL.py
+6
-8
yt_dlp/extractor/common.py
yt_dlp/extractor/common.py
+1
-1
yt_dlp/extractor/lbry.py
yt_dlp/extractor/lbry.py
+3
-3
yt_dlp/extractor/netverse.py
yt_dlp/extractor/netverse.py
+2
-2
yt_dlp/extractor/ninenow.py
yt_dlp/extractor/ninenow.py
+1
-1
yt_dlp/extractor/vk.py
yt_dlp/extractor/vk.py
+2
-2
yt_dlp/extractor/wimbledon.py
yt_dlp/extractor/wimbledon.py
+1
-1
yt_dlp/networking/common.py
yt_dlp/networking/common.py
+5
-4
未找到文件。
test/test_YoutubeDL.py
浏览文件 @
6148833f
...
...
@@ -831,6 +831,7 @@ def expect_same_infodict(out):
test
(
'%(id&hi {:>10} {}|)s'
,
'hi 1234 1234'
)
test
(
R
'%(id&{0} {}|)s'
,
'NA'
)
test
(
R
'%(id&{0.1}|)s'
,
'NA'
)
test
(
'%(height&{:,d})S'
,
'1,080'
)
# Laziness
def
gen
():
...
...
test/test_networking.py
浏览文件 @
6148833f
...
...
@@ -29,6 +29,7 @@
from
http.cookiejar
import
CookieJar
from
test.helper
import
FakeYDL
,
http_server_port
from
yt_dlp.cookies
import
YoutubeDLCookieJar
from
yt_dlp.dependencies
import
brotli
from
yt_dlp.networking
import
(
HEADRequest
,
...
...
@@ -478,7 +479,7 @@ def test_request_cookie_header(self, handler):
assert
'Cookie: test=test'
not
in
res
# Specified Cookie header should override global cookiejar for that request
cookiejar
=
http
.
cookiejar
.
CookieJar
()
cookiejar
=
YoutubeDL
CookieJar
()
cookiejar
.
set_cookie
(
http
.
cookiejar
.
Cookie
(
version
=
0
,
name
=
'test'
,
value
=
'ytdlp'
,
port
=
None
,
port_specified
=
False
,
domain
=
'127.0.0.1'
,
domain_specified
=
True
,
domain_initial_dot
=
False
,
path
=
'/'
,
...
...
@@ -505,7 +506,7 @@ def test_incompleteread(self, handler):
@
pytest
.
mark
.
parametrize
(
'handler'
,
[
'Urllib'
],
indirect
=
True
)
def
test_cookies
(
self
,
handler
):
cookiejar
=
http
.
cookiejar
.
CookieJar
()
cookiejar
=
YoutubeDL
CookieJar
()
cookiejar
.
set_cookie
(
http
.
cookiejar
.
Cookie
(
0
,
'test'
,
'ytdlp'
,
None
,
False
,
'127.0.0.1'
,
True
,
False
,
'/headers'
,
True
,
False
,
None
,
False
,
None
,
None
,
{}))
...
...
@@ -903,7 +904,8 @@ class HTTPSupportedRH(ValidationRH):
EXTENSION_TESTS
=
[
(
'Urllib'
,
[
({
'cookiejar'
:
'notacookiejar'
},
AssertionError
),
({
'cookiejar'
:
CookieJar
()},
False
),
({
'cookiejar'
:
YoutubeDLCookieJar
()},
False
),
({
'cookiejar'
:
CookieJar
()},
AssertionError
),
({
'timeout'
:
1
},
False
),
({
'timeout'
:
'notatimeout'
},
AssertionError
),
({
'unsupported'
:
'value'
},
UnsupportedRequest
),
...
...
yt_dlp/YoutubeDL.py
浏览文件 @
6148833f
...
...
@@ -256,8 +256,6 @@ class YoutubeDL:
overwrites: Overwrite all video and metadata files if True,
overwrite only non-video files if None
and don't overwrite any file if False
For compatibility with youtube-dl,
"nooverwrites" may also be used instead
playlist_items: Specific indices of playlist to download.
playlistrandom: Download playlist items in random order.
lazy_playlist: Process playlist entries as they are received.
...
...
@@ -553,6 +551,7 @@ class YoutubeDL:
You can reduce network I/O by disabling it if you don't
care about HLS. (only for youtube)
no_color: Same as `color='no_color'`
no_overwrites: Same as `overwrites=False`
"""
_NUMERIC_FIELDS
=
{
...
...
@@ -604,6 +603,7 @@ def __init__(self, params=None, auto_init=True):
self
.
_playlist_level
=
0
self
.
_playlist_urls
=
set
()
self
.
cache
=
Cache
(
self
)
self
.
__header_cookies
=
[]
stdout
=
sys
.
stderr
if
self
.
params
.
get
(
'logtostderr'
)
else
sys
.
stdout
self
.
_out_files
=
Namespace
(
...
...
@@ -632,7 +632,7 @@ def process_color_policy(stream):
policy
=
traverse_obj
(
self
.
params
,
(
'color'
,
(
stream_name
,
None
),
{
str
}),
get_all
=
False
)
if
policy
in
(
'auto'
,
None
):
return
term_allow_color
and
supports_terminal_sequences
(
stream
)
assert
policy
in
(
'always'
,
'never'
,
'no_color'
)
assert
policy
in
(
'always'
,
'never'
,
'no_color'
)
,
policy
return
{
'always'
:
True
,
'never'
:
False
}.
get
(
policy
,
policy
)
self
.
_allow_colors
=
Namespace
(
**
{
...
...
@@ -681,12 +681,10 @@ def process_color_policy(stream):
self
.
params
[
'compat_opts'
]
=
set
(
self
.
params
.
get
(
'compat_opts'
,
()))
self
.
params
[
'http_headers'
]
=
HTTPHeaderDict
(
std_headers
,
self
.
params
.
get
(
'http_headers'
))
self
.
__header_cookies
=
[]
self
.
_load_cookies
(
self
.
params
[
'http_headers'
].
get
(
'Cookie'
))
# compat
self
.
params
[
'http_headers'
].
pop
(
'Cookie'
,
None
)
self
.
_request_director
=
self
.
build_request_director
(
_REQUEST_HANDLERS
.
values
())
self
.
_request_director
=
self
.
build_request_director
(
sorted
(
_REQUEST_HANDLERS
.
values
(),
key
=
lambda
rh
:
rh
.
RH_NAME
.
lower
()))
if
auto_init
and
auto_init
!=
'no_verbose_header'
:
self
.
print_debug_header
()
...
...
@@ -3977,7 +3975,7 @@ def get_encoding(stream):
}))
or
'none'
))
write_debug
(
f
'Proxy map:
{
self
.
proxies
}
'
)
# write_debug(f'Request Handlers: {", ".join(rh.RH_NAME for rh in self._request_director.handlers)}')
# write_debug(f'Request Handlers: {", ".join(rh.RH_NAME for rh in self._request_director.handlers
.values()
)}')
for
plugin_type
,
plugins
in
{
'Extractor'
:
plugin_ies
,
'Post-Processor'
:
plugin_pps
}.
items
():
display_list
=
[
'%s%s'
%
(
klass
.
__name__
,
''
if
klass
.
__name__
==
name
else
f
' as
{
name
}
'
)
...
...
@@ -4080,7 +4078,7 @@ def urlopen(self, req):
def
build_request_director
(
self
,
handlers
):
logger
=
_YDLLogger
(
self
)
headers
=
self
.
params
.
get
(
'http_headers'
)
.
copy
()
headers
=
self
.
params
[
'http_headers'
]
.
copy
()
proxies
=
self
.
proxies
.
copy
()
clean_headers
(
headers
)
clean_proxies
(
proxies
,
headers
)
...
...
yt_dlp/extractor/common.py
浏览文件 @
6148833f
...
...
@@ -729,7 +729,7 @@ def extract(self, url):
except
UnsupportedError
:
raise
except
ExtractorError
as
e
:
e
.
video_id
=
e
.
video_id
or
self
.
get_temp_id
(
url
)
,
e
.
video_id
=
e
.
video_id
or
self
.
get_temp_id
(
url
)
e
.
ie
=
e
.
ie
or
self
.
IE_NAME
,
e
.
traceback
=
e
.
traceback
or
sys
.
exc_info
()[
2
]
raise
...
...
yt_dlp/extractor/lbry.py
浏览文件 @
6148833f
...
...
@@ -248,9 +248,9 @@ def _real_extract(self, url):
# GET request to v3 API returns original video/audio file if available
direct_url
=
re
.
sub
(
r
'/api/v\d+/'
,
'/api/v3/'
,
streaming_url
)
ext
=
urlhandle_detect_ext
(
self
.
_request_webpage
(
direct_url
,
display_id
,
'Checking for original quality'
,
headers
=
headers
)
)
if
ext
!=
'm3u8'
:
urlh
=
self
.
_request_webpage
(
direct_url
,
display_id
,
'Checking for original quality'
,
headers
=
headers
,
fatal
=
False
)
if
urlh
and
urlhandle_detect_ext
(
urlh
)
!=
'm3u8'
:
formats
.
append
({
'url'
:
direct_url
,
'format_id'
:
'original'
,
...
...
yt_dlp/extractor/netverse.py
浏览文件 @
6148833f
...
...
@@ -160,7 +160,7 @@ class NetverseIE(NetverseBaseIE):
'uploader'
:
'Net Prime'
,
'comment_count'
:
int
,
},
'params'
:{
'params'
:
{
'getcomments'
:
True
}
},
{
...
...
@@ -187,7 +187,7 @@ class NetverseIE(NetverseBaseIE):
'season'
:
'Season 1'
,
'comment_count'
:
int
,
},
'params'
:{
'params'
:
{
'getcomments'
:
True
}
}]
...
...
yt_dlp/extractor/ninenow.py
浏览文件 @
6148833f
...
...
@@ -53,7 +53,7 @@ class NineNowIE(InfoExtractor):
'upload_date'
:
'20210421'
,
},
'expected_warnings'
:
[
'Ignoring subtitle tracks'
],
'params'
:{
'params'
:
{
'skip_download'
:
True
,
}
}]
...
...
yt_dlp/extractor/vk.py
浏览文件 @
6148833f
...
...
@@ -765,7 +765,7 @@ def _extract_common_meta(self, stream_info):
class
VKPlayIE
(
VKPlayBaseIE
):
_VALID_URL
=
r
'https?://vkplay\.live/(?P<username>[^/
]+)/record/(?P<id>[a-f0-9\
-]+)'
_VALID_URL
=
r
'https?://vkplay\.live/(?P<username>[^/
#?]+)/record/(?P<id>[a-f0-9
-]+)'
_TESTS
=
[{
'url'
:
'https://vkplay.live/zitsmann/record/f5e6e3b5-dc52-4d14-965d-0680dd2882da'
,
'info_dict'
:
{
...
...
@@ -802,7 +802,7 @@ def _real_extract(self, url):
class
VKPlayLiveIE
(
VKPlayBaseIE
):
_VALID_URL
=
r
'https?://vkplay\.live/(?P<id>[^/]+)/?(?:[#?]|$)'
_VALID_URL
=
r
'https?://vkplay\.live/(?P<id>[^/
#?
]+)/?(?:[#?]|$)'
_TESTS
=
[{
'url'
:
'https://vkplay.live/bayda'
,
'info_dict'
:
{
...
...
yt_dlp/extractor/wimbledon.py
浏览文件 @
6148833f
...
...
@@ -6,7 +6,7 @@
class
WimbledonIE
(
InfoExtractor
):
_VALID_URL
=
r
'https?://(?:www\.)?wimbledon\.com/\w+/video/media/(?P<id>\d+).html'
_VALID_URL
=
r
'https?://(?:www\.)?wimbledon\.com/\w+/video/media/(?P<id>\d+)
\
.html'
_TESTS
=
[{
'url'
:
'https://www.wimbledon.com/en_GB/video/media/6330247525112.html'
,
'info_dict'
:
{
...
...
yt_dlp/networking/common.py
浏览文件 @
6148833f
...
...
@@ -12,7 +12,6 @@
from
collections.abc
import
Iterable
,
Mapping
from
email.message
import
Message
from
http
import
HTTPStatus
from
http.cookiejar
import
CookieJar
from
._helper
import
make_ssl_context
,
wrap_request_errors
from
.exceptions
import
(
...
...
@@ -22,6 +21,7 @@
UnsupportedRequest
,
)
from
..compat.types
import
NoneType
from
..cookies
import
YoutubeDLCookieJar
from
..utils
import
(
bug_reports_message
,
classproperty
,
...
...
@@ -194,7 +194,7 @@ def __init__(
self
,
*
,
logger
,
# TODO(Grub4k): default logger
headers
:
HTTPHeaderDict
=
None
,
cookiejar
:
CookieJar
=
None
,
cookiejar
:
YoutubeDL
CookieJar
=
None
,
timeout
:
float
|
int
|
None
=
None
,
proxies
:
dict
=
None
,
source_address
:
str
=
None
,
...
...
@@ -208,7 +208,7 @@ def __init__(
self
.
_logger
=
logger
self
.
headers
=
headers
or
{}
self
.
cookiejar
=
cookiejar
if
cookiejar
is
not
None
else
CookieJar
()
self
.
cookiejar
=
cookiejar
if
cookiejar
is
not
None
else
YoutubeDL
CookieJar
()
self
.
timeout
=
float
(
timeout
or
20
)
self
.
proxies
=
proxies
or
{}
self
.
source_address
=
source_address
...
...
@@ -275,7 +275,7 @@ def _check_proxies(self, proxies):
def
_check_extensions
(
self
,
extensions
):
"""Check extensions for unsupported extensions. Subclasses should extend this."""
assert
isinstance
(
extensions
.
get
(
'cookiejar'
),
(
CookieJar
,
NoneType
))
assert
isinstance
(
extensions
.
get
(
'cookiejar'
),
(
YoutubeDL
CookieJar
,
NoneType
))
assert
isinstance
(
extensions
.
get
(
'timeout'
),
(
float
,
int
,
NoneType
))
def
_validate
(
self
,
request
):
...
...
@@ -302,6 +302,7 @@ def send(self, request: Request) -> Response:
@
abc
.
abstractmethod
def
_send
(
self
,
request
:
Request
):
"""Handle a request from start to finish. Redefine in subclasses."""
pass
def
close
(
self
):
pass
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录