Closed zhangn1985 closed 7 years ago
acfun从7月初就改版了 mp4/flv必须带cookies: ac__avi 访问才能正常播放/下载
不用cookies
curl http://player.acfun.cn/route_mp4\?uid\=ACFUN\×tamp\=1504198693\&fid\=0504400204000059A5561000010002EB0000000000-0000-0000-019D-C0DD00000000.mp4\&ns\=video.acfun.cn\&ran\=1010069662930e64d7f81ca59e4035f9c9346d545c9erpcx12125p45p178p2575d7482dbb754\&vid\=59a554910cf23b9f08c46db3\&customer_id\=5859fdaee4b0eaf5dd325b91\&sign\=ct59a840250cf28d96cb8ecebc -L > out.mp4
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 111 100 111 0 0 1373 0 --:--:-- --:--:-- --:--:-- 1387
100 1073k 100 1073k 0 0 167k 0 0:00:06 0:00:06 --:--:-- 213k
问题在fake_headers上面
和上次api的限制一样,Mozilla这个词被禁掉了
这样改一下能下载
diff --git a/ykdl/util/download.py b/ykdl/util/download.py
index 1e38928..3d6fa7c 100644
--- a/ykdl/util/download.py
+++ b/ykdl/util/download.py
@@ -42,7 +42,9 @@ def save_url(url, name, ext, status, part = None, reporthook = simple_hook):
read = 0
blocknum = 0
open_mode = 'wb'
- req = Request(url, headers = fake_headers)
+ headers = fake_headers.copy()
+ headers['User-Agent'] = 'ozilla/5.0'
+ req = Request(url, headers = headers)
response = urlopen(req, None)
if "content-length" in response.headers:
size = int(response.headers["Content-Length"])
url_save
需要动点手术允许custom headers
ykdl http://acfun.cn/v/ac3947859site: AcFun 优酷合作视频 title: acfun_1504007361552 artist: None streams:
download-with: ykdl --format=HD [URL]
Playing: http://player.acfun.cn/route_mp4?uid=ACFUN×tamp=1504181802&fid=0500400204000059A5561100010002EB0000000000-0000-0000-019D-C0DE00000000.mp4&ns=video.acfun.cn&ran=101006949402a732efe7428e53dcf6fd7f7142e0fba9rpcx12183p193p154p955091f5a895927&vid=59a554910cf23b9f08c46db3&customer_id=5859fdaee4b0eaf5dd325b91&sign=ct59a7fe2a0cf23b9f08ff3870 [ffmpeg] http: HTTP error 403 Forbidden