yt-dlp: [twitch] ERROR: 'NoneType' object is not subscriptable

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

United States

Provide a description that is worded well enough to be understood

What I did:

Tried to download a Twitch stream like this:

yt-dlp 'https://twitch.tv/gamesdonequick'

What I expected to happen: It starts downloading

What happened instead:

ERROR: 'NoneType' object is not subscriptable
  • I was successfully using yt-dlp with Twitch earlier today.
  • The issue is not limited to my IP address AFAICT

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['-vU', 'https://twitch.tv/gamesdonequick']
[debug] Encodings: locale utf-8, fs utf-8, pref utf-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d]
[debug] Lazy loading extractors is disabled
[debug] Python 3.11.3 (CPython x86_64 64bit) - Linux-6.2.13-arch1-1-x86_64-with-glibc2.37 (OpenSSL 3.0.9 30 May 2023, glibc 2.37)
[debug] exe versions: ffmpeg 6.0 (setts), ffprobe 6.0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.18.0, brotlicffi-1.0.9.2, certifi-2023.05.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-11.0.3
[debug] Proxy map: {}
[debug] Loaded 1842 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.03.04, Current version: stable@2023.03.04
yt-dlp is up to date (stable@2023.03.04)
[twitch:stream] Extracting URL: https://twitch.tv/gamesdonequick
[twitch:stream] gamesdonequick: Downloading stream GraphQL
[twitch:stream] gamesdonequick: Downloading stream access token GraphQL
ERROR: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/yt_dlp/YoutubeDL.py", line 1552, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/yt_dlp/YoutubeDL.py", line 1628, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 698, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/yt_dlp/extractor/twitch.py", line 1025, in _real_extract
    token = access_token['value']
            ~~~~~~~~~~~~^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 19
  • Comments: 20 (2 by maintainers)

Commits related to this issue

Most upvoted comments

streamlink/streamlink#5370 (comment) m4eba/twitch-dump@2006b88

Seems that replacing the ID here

https://github.com/yt-dlp/yt-dlp/blob/c35448b7b14113b35c4415dbfbf488c4731f006f/yt_dlp/extractor/twitch.py#L44

with ue6666qo983tsx6so1t0vnawi233wa, works

Any idea how those of us using the pip version of yt_dlp might be able to do this fix? I have an automation script for twitch that seems to be broken now because of this API change. I would add my console output, but I don’t want to flood the thread.

Related: #7058

It seems that Twitch is now requiring the “integrity” challenge for livestream GraphQL requests as well. The JSON response that yt-dlp gets:

{
  "errors": [
    {
      "message": "failed integrity check",
      "path": [
        "streamPlaybackAccessToken"
      ]
    }
  ],
  "data": {
    "streamPlaybackAccessToken": null
  },
  "extensions": {
    "challenge": {
      "type": "integrity"
    },
    "durationMilliseconds": 2,
    "requestID": "..."
  }
}

See linked issue for more info

Possibly related: Twitch is now also blocking Firefox from watching livestreams if privacy.resistFingerprinting is enabled. Seems both site changes occurred around the same time. (Previously, Twitch was already blocking Firefox RFP from login, and the bugzilla report about that contains some troubling info about what we are up against)

@trit34 as noted in the streamlink issue, it was probably one of the first tests before going permanent. Twitch probably wants to save on BOT bandwidth since no advertiser will trust their metrics anyway (the only metrics advertisers can trust is the correlation of the actual sales with an advertisement campaign).

Found another _CLIENT_ID that works (tested the same way as above): kd1unb4b3q4t58fwlpcbzcbnm76a8fp

Courtesy of the good folks at https://github.com/crackededed/Xtra

streamlink/streamlink#5370 (comment) m4eba/twitch-dump@2006b88 Seems that replacing the ID here https://github.com/yt-dlp/yt-dlp/blob/c35448b7b14113b35c4415dbfbf488c4731f006f/yt_dlp/extractor/twitch.py#L44

with ue6666qo983tsx6so1t0vnawi233wa, works

Any idea how those of us using the pip version of yt_dlp might be able to do this fix? I have an automation script for twitch that seems to be broken now because of this API change. I would add my console output, but I don’t want to flood the thread.

Okay, I found a fix for us pip users. It’s really simple. Run py -m pip show yt_dlp and you should get and output that looks kinda like this:

Name: yt-dlp
Version: 2023.3.4
Summary: A youtube-dl fork with additional features and patches
Home-page: https://github.com/yt-dlp/yt-dlp
Author:
Author-email:
License:
Location: C:\Users\[YOUR USER NAME]\AppData\Local\Programs\Python\Python311\Lib\site-packages
Requires: brotli, certifi, mutagen, pycryptodomex, websockets
Required-by:

Go to that location and modify line 44 in yt-dlp/yt_dlp/extractor/twitch.py as @Gregaras said, changing _CLIENT_ID in the TwitchBaseIE() function to 'ue6666qo983tsx6so1t0vnawi233wa'. Works for me now, though who can say for how long.

Was about to post this, can confirm it is working for the time being. Got the file path i needed by running yt-dlp --verbose "https://twitch.tv/streamer_name", the output will have a stacktrace with the twitch.py filepath at the end.

streamlink/streamlink#5370 (comment) m4eba/twitch-dump@2006b88 Seems that replacing the ID here https://github.com/yt-dlp/yt-dlp/blob/c35448b7b14113b35c4415dbfbf488c4731f006f/yt_dlp/extractor/twitch.py#L44

with ue6666qo983tsx6so1t0vnawi233wa, works

Any idea how those of us using the pip version of yt_dlp might be able to do this fix? I have an automation script for twitch that seems to be broken now because of this API change. I would add my console output, but I don’t want to flood the thread.

Okay, I found a fix for us pip users. It’s really simple. Run py -m pip show yt_dlp and you should get and output that looks kinda like this:

Name: yt-dlp
Version: 2023.3.4
Summary: A youtube-dl fork with additional features and patches
Home-page: https://github.com/yt-dlp/yt-dlp
Author:
Author-email:
License:
Location: C:\Users\[YOUR USER NAME]\AppData\Local\Programs\Python\Python311\Lib\site-packages
Requires: brotli, certifi, mutagen, pycryptodomex, websockets
Required-by:

Go to that location and modify line 44 in yt-dlp/yt_dlp/extractor/twitch.py as @Gregaras said, changing _CLIENT_ID in the TwitchBaseIE() function to 'ue6666qo983tsx6so1t0vnawi233wa'. Works for me now, though who can say for how long.

So --add-header "Client-ID:ue6666qo983tsx6so1t0vnawi233wa" does not work right now?

No, it does not work currently.