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: KeyError: 'token' with VOD downloading #560

Open
MikeLund opened this issue Feb 13, 2017 · 3 comments
Open

Twitch: KeyError: 'token' with VOD downloading #560

MikeLund opened this issue Feb 13, 2017 · 3 comments

Comments

@MikeLund
Copy link

~$ svtplay-dl https://www.twitch.tv/playhearthstone/videos/all --verbose
DEBUG [1486977118.84] /usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/utils/__init__.py/request: HTTP getting 'https://www.twitch.tv/playhearthstone/videos/all'
DEBUG [1486977118.95] /usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/utils/__init__.py/request: HTTP getting 'https://api.twitch.tv//api/channels/playhearthstone/access_token'
ERROR [1486977119.74] /usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py/get_one_media: version: 1.9.2
Traceback (most recent call last):
  File "/usr/local/bin/svtplay-dl", line 7, in <module>
    svtplay_dl.main()
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py", line 461, in main
    get_media(urls[0], options)
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py", line 192, in get_media
    get_one_media(stream, copy.copy(options))
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py", line 239, in get_one_media
    for i in streams:
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/service/twitch.py", line 68, in get
    for i in data:
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/service/twitch.py", line 153, in _get_channel
    hls_url = self._get_hls_url(channel)
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/service/twitch.py", line 140, in _get_hls_url
    query = "token=%s&sig=%s&allow_source=true&allow_spectre=true" % (quote_plus(access['token']), access['sig'])
KeyError: 'token'

Get the same thing if trying to download a specific VOD:

~$ svtplay-dl https://www.twitch.tv/videos/99292393 --verbose
DEBUG [1486977178.94] /usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/utils/__init__.py/request: HTTP getting 'https://www.twitch.tv/videos/99292393'
DEBUG [1486977179.36] /usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/utils/__init__.py/request: HTTP getting 'https://api.twitch.tv//api/channels/videos/access_token'
ERROR [1486977180.15] /usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py/get_one_media: version: 1.9.2
Traceback (most recent call last):
  File "/usr/local/bin/svtplay-dl", line 7, in <module>
    svtplay_dl.main()
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py", line 461, in main
    get_media(urls[0], options)
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py", line 192, in get_media
    get_one_media(stream, copy.copy(options))
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/__init__.py", line 239, in get_one_media
    for i in streams:
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/service/twitch.py", line 68, in get
    for i in data:
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/service/twitch.py", line 153, in _get_channel
    hls_url = self._get_hls_url(channel)
  File "/usr/local/Cellar/svtplay-dl/1.9.2/libexec/lib/python2.7/site-packages/svtplay_dl/service/twitch.py", line 140, in _get_hls_url
    query = "token=%s&sig=%s&allow_source=true&allow_spectre=true" % (quote_plus(access['token']), access['sig'])
KeyError: 'token'

Am I doing it wrong, or is this a bug? Thanks!

@qnorsten
Copy link
Collaborator

qnorsten commented Mar 1, 2017

I think Twitch has changed their API. I think you need to use oath2 to get a token now.
I am not sure how to do that in svtplay-dl, perhaps @spaam has some idea?

Edit: I think svtplay-dl need to get a client ID and pass it as a header in all api calls as stated here :
https://blog.twitch.tv/client-id-required-for-kraken-api-calls-afbb8e95f843#.m078q2ys2

Edit2: Turns out they also changed the format of some of the links, but that was an easy fix.

@qnorsten
Copy link
Collaborator

qnorsten commented Mar 9, 2017

I have a fix for this it is mostly a matter of parsing the correct header with a CLIENT-ID. What do you think @spaam should each user get their own ID and pass it with something such as --twitch-client id ? Or should svtplay use a hard coded one similar to how youtube-dl does it?

@drejjmit
Copy link

Status on this fix? Will you generate a client-id for svtplay-dl or will we be able to use our own client-id?

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

No branches or pull requests

3 participants