Skip to content

[BUG] Twitch chat downloading fails #283

@uwu-crj

Description

@uwu-crj

Basic information

  • Program version: 0.2.8
  • Python version: 3.12.3
  • Operating system: Ubuntu

Describe the bug

As of a few hours ago (definitely fewer than 24), chat_downloader ceased operating entirely on Twitch, for either live streams or VODs.

Command/Code used

If running from the command line, provide the following:

  1. The command used (including the verbose tag, -v):
$ chat_downloader -v https://www.twitch.tv/dashducks 
  1. Output from the above command:
[DEBUG] Python version: 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0]
[DEBUG] Program version: 0.2.8
[DEBUG] Initialisation parameters: {'headers': None, 'cookies': None, 'proxy': None}
[DEBUG] Created TwitchChatDownloader session.
[INFO] Site: twitch.tv
[DEBUG] Program parameters: {'url': 'https://www.twitch.tv/dashducks', 'start_time': None, 'end_time': None, 'max_attempts': 15, 'retry_timeout': None, 'interruptible_retry': True, 'timeout': None, 'inactivity_timeout': None, 'max_messages': None, 'message_groups': ['messages'], 'message_types': None, 'output': None, 'overwrite': True, 'sort_keys': True, 'indent': 4, 'format': 'twitch', 'format_file': None, 'chat_type': 'live', 'ignore': None, 'message_receive_timeout': 0.1, 'buffer_size': 4096}
[DEBUG] Starting new HTTPS connection (1): gql.twitch.tv:443
[DEBUG] https://gql.twitch.tv:443 "POST /gql HTTP/1.1" 200 165
[DEBUG] Session closed.
Traceback (most recent call last):
  File "/home/crj/venv-testing/bin/chat_downloader", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/crj/venv-testing/lib/python3.12/site-packages/chat_downloader/cli.py", line 194, in main
    run(**args.__dict__)
  File "/home/crj/venv-testing/lib/python3.12/site-packages/chat_downloader/chat_downloader.py", line 351, in run
    chat = downloader.get_chat(**chat_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/crj/venv-testing/lib/python3.12/site-packages/chat_downloader/chat_downloader.py", line 224, in get_chat
    chat = get_chat(match, params)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/crj/venv-testing/lib/python3.12/site-packages/chat_downloader/sites/twitch.py", line 1646, in _get_chat_by_stream_id
    return self.get_chat_by_stream_id(match.group('id'), params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/crj/venv-testing/lib/python3.12/site-packages/chat_downloader/sites/twitch.py", line 1659, in get_chat_by_stream_id
    stream_info = self._download_gql(query)[0]['data']['user']
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'

Otherwise, if using the python module, provide the following:

I'm not including an example because the problem is reproducible via the command line, but I initially observed it via the Python API (with the same exception at the same point in the code).

Expected behavior

I expected the program to retrieve chat messages.

Screenshots

n/a

Additional context/information

I believe this is because Twitch has replaced all of their GQL persistedQuery hashes; yt-dlp and streamlink are also affected.

This means that _OPERATION_HASHES at twitch.py:842 needs updating. I would fix it myself, but I can't see how to determine the replacements.

Activity

babupipi

babupipi commented on Nov 11, 2025

@babupipi

twitch.py

Line 856
# 'ComscoreStreamingQuery': 'e1edae8122517d013405f237ffcc124515dc6ded82480a88daef69c83b53ac01',

Do this
'ComscoreStreamingQuery': 'e1edae8122517d013405f237ffcc124515dc6ded82480a88daef69c83b53ac01',

and

Line 1652

    query = [{
        'operationName': 'StreamMetadata',
        'variables': {'channelLogin': stream_id.lower()}
    }]

Do this

    query = [{
        'operationName': 'StreamMetadata',
        'variables': {'channelLogin': stream_id.lower()}
    },{
        'operationName': 'ComscoreStreamingQuery',
        'variables': {
            'channel': stream_id.lower(),
            'clipSlug': '',
            'isClip': False,
            'isLive': True,
            'isVodOrCollection': False,
            'vodID': '',
    }}]
gadi-playstream-gg

gadi-playstream-gg commented on Nov 11, 2025

@gadi-playstream-gg

having the same issue.

uwu-crj

uwu-crj commented on Nov 11, 2025

@uwu-crj
Author

Line 1652
[…]
Do this
[…]

Thanks — that seems to fix acquisition from a live stream, but the problem remains for a VOD.

Acting on raw intuition based on the change you suggested for get_chat_by_stream_id I tried amending get_chat_by_vod_id to say:

        query = [{
            'operationName': 'VideoMetadata',
            'variables': {
                'channelLogin': '',
                'videoID': vod_id
            }
        },{
            'operationName': 'ComscoreStreamingQuery',
            'variables': {
                'channel': '',
                'clipSlug': '',
                'isClip': False,
                'isLive': False,
                'isVodOrCollection': False,
                'vodID': vod_id,
            }
        }]

…but that didn't work ­­— when I instrumented it to print the GQL response, it read:

[
    {
        "errors": [
            {
                "message": "PersistedQueryNotFound"
            }
        ],
        "extensions": {
            "durationMilliseconds": 2,
            "operationName": "VideoMetadata",
            "requestID": "01K9S9E7XR72CQVP8SRYBJ647D"
        }
    },
    {
        "data": {},
        "extensions": {
            "durationMilliseconds": 2,
            "operationName": "ComscoreStreamingQuery",
            "requestID": "01K9S9E7XR72CQVP8SRYBJ647D"
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @babupipi@gadi-playstream-gg@uwu-crj

        Issue actions

          [BUG] Twitch chat downloading fails · Issue #283 · xenova/chat-downloader