Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

发现一个问题 #88

Open
Justsoos opened this issue Mar 12, 2018 · 2 comments
Open

发现一个问题 #88

Justsoos opened this issue Mar 12, 2018 · 2 comments
Labels
common enhancement New feature or request

Comments

@Justsoos
Copy link
Contributor

Justsoos commented Mar 12, 2018

file_size = url_size(url, headers=tmp_headers)

response = urlopen_with_retry(url, **kwargs)

通过监视log,可见:

Downloading 斯坦福2017季CS231n深度视觉识别课程视频(by Fei-Fei Li, Justin Johnson, Serena Yeung)(英文字幕).flv ...
0.0% ( 0.0/317.7MB) ├──────────────────────────────────────┤[ 1/13] [DEBUG] Starting new HTTP connection (1): cn-hljheb2-cu-v-02.acgvideo.com
[DEBUG] http://cn-hljheb2-cu-v-02.acgvideo.com:80 "GET /vg2/upgcxcode/63/12/21741263/21741263-1-80.flv?expires=1520841600&platform=pc&ssig=p1YxiZnGEZarvOmseDx8MQ&oi=2937426531&nfa=KTK9gLiWVOw6OtAbA2rSRg==&dynamic=1&hfa=2023045801&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI= HTTP/1.1" 200 21406066
[DEBUG] Starting new HTTP connection (2): cn-hljheb2-cu-v-02.acgvideo.com
[DEBUG] http://cn-hljheb2-cu-v-02.acgvideo.com:80 "GET /vg2/upgcxcode/63/12/21741263/21741263-1-80.flv?expires=1520841600&platform=pc&ssig=p1YxiZnGEZarvOmseDx8MQ&oi=2937426531&nfa=KTK9gLiWVOw6OtAbA2rSRg==&dynamic=1&hfa=2023045801&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI= HTTP/1.1" 200 21406066
1.4% ( 4.6/317.7MB) ├█─────────────────────────────────────┤[ 1/13] 2 MB/s

由于这个取 url_size 行为,you-get 或 lulu 都要对带token的流地址二次连接,这对于限制盗播的流媒体网站其实相当敏感。应该合并这两个行为。

@iawia002 iawia002 added enhancement New feature or request common labels Mar 12, 2018
@Justsoos
Copy link
Contributor Author

因为我测过 douyu 的api,很变态,token 二次连接很容易就失效,拒绝连接了。b 站相比几乎没太多措施,huya 宽松很多,一分钟内都可以重用。

上面这2次连接,应该是 you-get 在早期留下的坏习惯,当时流媒体网站对 token 失效没有那么变态的要求。

@Justsoos
Copy link
Contributor Author

Justsoos commented Mar 15, 2018

找到解决方案,stream=True 这是个好东西啊。可以删掉 common.url_size() 这个函数了。一次 session.get(),就可以同时取Content-Length,然后下面 response.iter_content() 复用连接

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
common enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants