Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitch live stream fails with python 3. #5158

Closed
miseran opened this issue Mar 7, 2015 · 1 comment
Closed

Twitch live stream fails with python 3. #5158

miseran opened this issue Mar 7, 2015 · 1 comment

Comments

@miseran
Copy link

@miseran miseran commented Mar 7, 2015

When trying to download a twitch live stream in python 3, downloading the m3u8 information often (but not always) fails due to an HTTP 403 error. From what I can tell, the bug is around line 367 of twitch.py. The expression compat_urllib_parse.urlencode(query).encode('utf-8') gives a bytes object, which is inserted into the format string as b'whatever', giving an invalid URL. For example, such an URL might be

http://usher.twitch.tv/api/channel/hls/riotgames.m3u8?b'token=%7B%22user_id%22%3Anull%2C%22channel%22%3A%22riotgames%22%2C%22expires%22%3A1425767945%2C%22chansub%22%3A%7B%22view_until%22%3A1924905600%2C%22restricted_bitrates%22%3A%5B%5D%7D%2C%22private%22%3A%7B%22allowed_to_view%22%3Atrue%7D%2C%22privileged%22%3Afalse%2C%22source_restricted%22%3Afalse%7D&p=7037332&player=twitchweb&segment_preference=4&allow_source=true&sig=624caab07ed41674af64fdfed06c0687ec11b5d5'

Removing the .encode('utf-8') seems to work, but I'm not sure if it breaks anything else.
I have also attached the output of the program below.

$ python3.4 -m youtube_dl --verbose 'http://www.twitch.tv/riotgames'
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--verbose', 'http://www.twitch.tv/riotgames']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.03.03.1
[debug] Git HEAD: 23ba76b
[debug] Python version 3.4.3 - Darwin-13.4.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 2.5.4, ffprobe 2.5.4, rtmpdump 2.4
[debug] Proxy map: {}
[twitch:stream] riotgames: Downloading stream JSON
[twitch:stream] riotgames: Downloading channel access token
[twitch:stream] riotgames: Downloading m3u8 information
ERROR: Failed to download m3u8 information: HTTP Error 403: ERROR (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/private/tmp/tmp.B5NcE/youtube-dl/youtube_dl/extractor/common.py", line 314, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/private/tmp/tmp.B5NcE/youtube-dl/youtube_dl/YoutubeDL.py", line 1674, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 469, in open
    response = meth(req, response)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 579, in http_response
    'http', request, response, code, msg, hdrs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 507, in error
    return self._call_chain(*args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 441, in _call_chain
    result = func(*args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 587, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
@dstftw dstftw closed this in d34e794 Mar 8, 2015
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Mar 8, 2015

This will be fixed in the next version. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.