ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.18k stars 10.02k forks source link

[Python3][Tumblr] Infinite redirect when using proxy feature #9654

Open kidol opened 8 years ago

kidol commented 8 years ago

version 2016.05.30.2

youtube-dl -j "http://sythnmsvntn.tumblr.com/post/145116566731/little-kid-dancing-to-seventeens-pretty-u-this-is

WITHOUT proxy:

Request 1:

GET /post/145116566731/

(why is youtube-dl removing part of the url here?)

Response:

HTTP/1.1 301 Moved Permanently Location: http://sythnmsvntn.tumblr.com/post/145116566731/little-kid-dancing-to-seventeens-pretty-u-this-is#_=_

Request 2:

GET /post/145116566731/little-kid-dancing-to-seventeens-pretty-u-this-is HTTP/1.1

OK, page is now sent and youtube-dl handles it correctly.

WITH proxy:

Same as before, but request 2 looks like this:

GET http://sythnmsvntn.tumblr.com/post/145116566731/little-kid-dancing-to-seventeens-pretty-u-this-is#_=_

Notice the not removed #_=_ at the end. This causes tumblr to respond with yet another 301 redirect (as in first response) resulting in infinite loop:

ERROR: Unable to download webpage: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.

yan12125 commented 8 years ago

Works fine for me either with proxy or without proxy. Please post the output of:

youtube-dl -vF "http://sythnmsvntn.tumblr.com/post/145116566731/little-kid-dancing-to-seventeens-pretty-u-this-is" --print-traffic --proxy your_proxy_ip:port

Note that --print-traffic is broken on Python 3 (#9365), so please use Python 2.

kidol commented 8 years ago

Hmm, with Python 2 it works correctly. Before I used the youtube-dl.exe which comes with Python 3.

So obviously something changed in Python url libs? If that's the case then youtube-dl should probably normalize the url manually.

yan12125 commented 8 years ago

So obviously something changed in Python url libs?

Maybe. I can't reproduce it yet on Python 3 with a proxy. Need to investigate further.

kidol commented 8 years ago

I can't reproduce it yet on Python 3 with a proxy

Strange. Here is version info:

[debug] Python version 3.4.4 - Windows-7-6.1.7601-SP1

kidol commented 8 years ago

Related python bug I found (even though it says 2.7): http://bugs.python.org/issue18119