最近要从百毒网盘下大量 HDTV 录制ts 原档,还有 wmv 的视频。但是很多视频我只需要其中的一个片段,为了一个片段下载整个视频显然很浪费带宽资源。
于是自然想到了 http 请求下载文件的部分内容。Google 了一段时间后,发现可以通过修改 header 请求实现下载文件的一部分。
为了测试可行性,我随便写了一个 range header:
Range: bytes=100003400-200003400
我的 Mac 上常用的下载器是 iGetter,貌似不能修改 header,试了 yaaw+aria2也可耻的失败了,只有转战 win 了。
win 下我用了 orbit,可以自定义添加 header。我添加上了这个 range header,但是还是会出错。主要体现是下载的文件体积和完整的体积一样大,而且下载的文件无法边看边下。
以下是 orbit 下载时候的 log:
2014-10-27 22:14:52 正在连接 8.37.233.14:80
2014-10-27 22:14:52 已连接.
2014-10-27 22:14:52 GET /ws.cdn.baidupcs.com/file/0c1d67b1e23ef0229065b2b3ef184d4d?xcode=e9c35b59cba4965d680907b98e99a6e5a9b43ea8c9dc45f9837047dfb5e85c39&fid=805313373-250528-330880784357099&time=1414418679&sign=FDTAXER-DCb740ccc5511e5e8fedcff06b081203-%2FfSaJqr7CG%2FaM1ak%2FnBWg%2FfvVKk%3D&to=hc&fm=Nin%2cB%2cU%2cny&sta_dx=2705&sta_cs=2&sta_ft=wmv&sta_ct=3&newver=1&newfm=1&flow_ver=3&expires=8h&rt=pr&r=813166128&mlogid=3235259757&vuk=805313373&vbdid=2237365620&wshc_tag=0&wsts_tag=544e5356&wsid_tag=321ffc0e&wsiphost=ipdbm HTTP/1.1
2014-10-27 22:14:52 Host: 8.37.233.14
2014-10-27 22:14:52 Referer: http://pan.baidu.com/disk/home
2014-10-27 22:14:52 User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
2014-10-27 22:14:52 Accept: /
2014-10-27 22:14:52 Pragma: no-cache
2014-10-27 22:14:52 Cache-Control: no-cache
2014-10-27 22:14:52 Connection: close
2014-10-27 22:14:53 HTTP/1.0 200 OK
2014-10-27 22:14:53 Expires: Sun, 25 Jan 2015 14:06:01 GMT
2014-10-27 22:14:53 Date: Mon, 27 Oct 2014 14:06:01 GMT
2014-10-27 22:14:53 Access-Control-Allow-Origin: *
2014-10-27 22:14:53 Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS, HEAD
2014-10-27 22:14:53 x-pcs-request-id: MTAuOTguMjAuMzM6ODA4MDoyMjY0OTY1MDQ3OjI3L09jdC8yMDE0IDIxOjIxOjQzIA==
2014-10-27 22:14:53 Accept-Ranges: bytes
2014-10-27 22:14:53 Last-Modified: Sat, 18 Oct 2014 01:28:46 GMT
2014-10-27 22:14:53 x-bs-version: F089B1A53EC161BE9FC8462B06B612E8
2014-10-27 22:14:53 ETag: 0d1e0f57b8215dd2cf49cb99d5118d45
2014-10-27 22:14:53 Content-Type: video/x-ms-wmv
2014-10-27 22:14:53 x-bs-request-id: MTAuOTguMjAuMzM6ODA4MDoyMjY0OTY1MDQ3OjI3L09jdC8yMDE0IDIxOjIxOjQ0IA==
2014-10-27 22:14:53 Content-Disposition: attachment;filename=“[NoDRM]-nmb48n14101701mhb.wmv”
2014-10-27 22:14:53 x-bs-object-type: superfile
2014-10-27 22:14:53 x-bs-client-ip: MTgwLjk3LjE3OC4xOTg=
2014-10-27 22:14:53 Cache-Control: max-age=7776000
2014-10-27 22:14:53 Server: BaiduBS
2014-10-27 22:14:53 Content-Length: 2836402168
2014-10-27 22:14:53 Age: 533
2014-10-27 22:14:53 Via: 1.0 yangzhou198:8080 (Cdn Cache Server V2.0), 1.0 hx14:8888 (Cdn Cache Server V2.0)
2014-10-27 22:14:53 Connection: close
请问这问题有什么办法解决嘛?先行谢过了。
1
sycsycsyc378 OP 额,log 复制错了。应该是
>2014-10-27 22:46:27 正在连接 lx.cdn.baidupcs.com:80 >2014-10-27 22:46:28 已连接. >2014-10-27 22:46:28 GET /file/0c1d67b1e23ef0229065b2b3ef184d4d?xcode=9051757817a92f8ad3449f7e464abacfa9b43ea8c9dc45f9837047dfb5e85c39&fid=805313373-250528-330880784357099&time=1414421173&sign=FDTAXER-DCb740ccc5511e5e8fedcff06b081203-7IWjqA%2Fis9z4ZiIfKKRCoHDU6qc%3D&to=hc&fm=Nin%2cB%2cU%2cny&sta_dx=2705&sta_cs=2&sta_ft=wmv&sta_ct=3&newver=1&newfm=1&flow_ver=3&expires=8h&rt=pr&r=970741873&mlogid=1020275842&vuk=805313373&vbdid=2237365620 HTTP/1.1 >2014-10-27 22:46:28 Host: lx.cdn.baidupcs.com >2014-10-27 22:46:28 Referer: http://pan.baidu.com/disk/home >2014-10-27 22:46:28 User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C) >2014-10-27 22:46:28 Range: bytes=100003400-200002400 >2014-10-27 22:46:30 HTTP/1.0 206 Partial Content >2014-10-27 22:46:30 Server: JSP3/2.0.0-b >2014-10-27 22:46:30 Date: Sat, 18 Oct >2014 03:39:19 GMT >2014-10-27 22:46:30 Content-Type: video/x-ms-wmv >2014-10-27 22:46:30 ETag: 0d1e0f57b8215dd2cf49cb99d5118d45 >2014-10-27 22:46:30 Last-Modified: Sat, 18 Oct >2014 01:28:46 GMT >2014-10-27 22:46:30 Expires: Mon, 17 Nov >2014 03:39:19 GMT >2014-10-27 22:46:30 Access-Control-Allow-Origin: * >2014-10-27 22:46:30 Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS,HEAD >2014-10-27 22:46:30 x-pcs-request-id: MTAuOTguNDAuMjQ6ODA4MDoxNjI5MTc3NTc1OjE4L09jdC8yMDE0IDExOjM5OjE5IA== >2014-10-27 22:46:30 Accept-Ranges: bytes >2014-10-27 22:46:30 x-bs-version: F089B1A53EC161BE9FC8462B06B612E8 >2014-10-27 22:46:30 x-bs-request-id: MTAuOTguNDAuMjQ6ODA4MDoxNjI5MTc3NTc1OjE4L09jdC8yMDE0IDExOjM5OjE5IA== >2014-10-27 22:46:30 Content-Disposition: attachment;filename="[NoDRM]-nmb48n14101701mhb.wmv" >2014-10-27 22:46:30 x-bs-object-type: superfile >2014-10-27 22:46:30 x-bs-client-ip: MjcuMjIxLjQwLjg1 >2014-10-27 22:46:30 Powered-By-ChinaCache: MISS from CNC-HQ-e-3W5.7 >2014-10-27 22:46:30 Cache-Control: max-age=2592000 >2014-10-27 22:46:30 Switch: FSCS >2014-10-27 22:46:30 Age: 817632 >2014-10-27 22:46:30 Powered-By-ChinaCache: HIT from CNC-ST-3-3W5.11 >2014-10-27 22:46:30 Content-Range: bytes 100003400-200002400/2836402168 >2014-10-27 22:46:30 Content-Length: 99999001 >2014-10-27 22:46:30 Switch:FSCS >2014-10-27 22:46:30 开始接收数据 >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:30 新建连接 lx.cdn.baidupcs.com >2014-10-27 22:46:37 用户停止下载 怎么不给编辑了我x! |
2
iCharlesC 2014-10-28 00:45:41 +08:00
|
3
hgc81538 2014-10-28 02:58:41 +08:00 via iPhone
|
4
RelativeLayout 2014-10-28 08:00:09 +08:00 via iPhone
|
5
choury 2014-10-28 08:37:03 +08:00
关键是视频文件你下中间一部分下了真的可以播放吗?而且还正好是你想要的那个片段?
|
7
sycsycsyc378 OP @hgc81538 试了curl,返回206没错了。下载下来的文件体积也是 range 里的那么大。问题就是播放不了 - -!
奇怪的是用下载器时候能边下边看。这样只下一部分就不行了,真是怪啊。 |