Skip to content

plugins.twitch: error: Error: server error when setting custom User-Agent #6574

@felipe19930

Description

@felipe19930

Checklist

Collaboration

Streamlink version

streamlink 7.4.0

Description

If I run streamlink with --http-header=User-Agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 and --twitch-purge-client-integrity to watch a random Twitch stream, streamlink ends up exiting with an error while trying to fetch Twitch's integrity token using Brave:

Video_2025-06-22_21-17-12.mp4

If I don't use --http-header=..., streamlink doesn't try to fetch the integrity token, and streaming just works:

$ streamlink --no-config --loglevel=debug --player=mpv --webbrowser-executable=com.brave.Browser --twitch-purge-client-integrity https://www.twitch.tv/gaules 720p60
[cli][debug] OS:         Linux-6.15.3-arch1-1-x86_64-with-glibc2.41
[cli][debug] Python:     3.13.3
[cli][debug] OpenSSL:    OpenSSL 3.5.0 8 Apr 2025
[cli][debug] Streamlink: 7.4.0
[cli][debug] Dependencies:
[cli][debug]  certifi: 2025.6.15
[cli][debug]  isodate: 0.7.2
[cli][debug]  lxml: 5.4.0
[cli][debug]  pycountry: 24.6.1
[cli][debug]  pycryptodome: 3.23.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.32.4
[cli][debug]  trio: 0.30.0
[cli][debug]  trio-websocket: 0.12.2
[cli][debug]  urllib3: 2.5.0
[cli][debug]  websocket-client: 1.8.0
[cli][debug] Arguments:
[cli][debug]  url=https://www.twitch.tv/gaules
[cli][debug]  stream=['720p60']
[cli][debug]  --no-config=True
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv
[cli][debug]  --webbrowser-executable=com.brave.Browser
[cli][debug]  --twitch-purge-client-integrity=True
[session][debug] Loading plugin: twitch
[cli][info] Found matching plugin twitch for URL https://www.twitch.tv/gaules
[plugins.twitch][debug] Getting live HLS streams for gaules
[plugins.twitch][debug] {'adblock': False, 'geoblock_reason': '', 'hide_ads': False, 'server_ads': True, 'show_ads': True}
[utils.l10n][debug] Language code: en_US
[cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p60, 1080p60 (best)
[cli][info] Opening stream: 720p60 (hls)
[cli][info] Starting player: mpv
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
[plugins.twitch][info] Detected advertisement break of 15 seconds
[stream.hls][debug] First Sequence: 0; Last Sequence: 2
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 0; End Sequence: None
[stream.hls][debug] Adding segment 0 to queue
[stream.hls][debug] Adding segment 1 to queue
[stream.hls][debug] Adding segment 2 to queue
[stream.hls][debug] Writing segment 0 to output
[stream.hls][debug] Segment 0 complete
[stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[cli.output][debug] Opening subprocess: ['/usr/bin/mpv', '--force-media-title=https://www.twitch.tv/gaules', '-']
[stream.hls][debug] Writing segment 1 to output
[stream.hls][debug] Segment 1 complete
[cli][debug] Writing stream to output
[stream.hls][debug] Writing segment 2 to output
[stream.hls][debug] Segment 2 complete
[cli][info] Player closed
[stream.segmented][debug] Closing worker thread
[stream.segmented][debug] Closing writer thread
[cli][info] Stream ended
[cli][info] Closing currently open stream...

Debug log

$ streamlink --no-config --loglevel=debug --player=mpv --webbrowser-executable=com.brave.Browser --twitch-purge-client-integrity '--http-header=User-Agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' https://www.twitch.tv/gaules 720p60
[cli][debug] OS:         Linux-6.15.3-arch1-1-x86_64-with-glibc2.41
[cli][debug] Python:     3.13.3
[cli][debug] OpenSSL:    OpenSSL 3.5.0 8 Apr 2025
[cli][debug] Streamlink: 7.4.0
[cli][debug] Dependencies:
[cli][debug]  certifi: 2025.6.15
[cli][debug]  isodate: 0.7.2
[cli][debug]  lxml: 5.4.0
[cli][debug]  pycountry: 24.6.1
[cli][debug]  pycryptodome: 3.23.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.32.4
[cli][debug]  trio: 0.30.0
[cli][debug]  trio-websocket: 0.12.2
[cli][debug]  urllib3: 2.5.0
[cli][debug]  websocket-client: 1.8.0
[cli][debug] Arguments:
[cli][debug]  url=https://www.twitch.tv/gaules
[cli][debug]  stream=['720p60']
[cli][debug]  --no-config=True
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv
[cli][debug]  --http-header=[('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36')]
[cli][debug]  --webbrowser-executable=com.brave.Browser
[cli][debug]  --twitch-purge-client-integrity=True
[session][debug] Loading plugin: twitch
[cli][info] Found matching plugin twitch for URL https://www.twitch.tv/gaules
[plugins.twitch][debug] Getting live HLS streams for gaules
[plugins.twitch][info] Removing cached client-integrity token...
[plugins.twitch][info] Acquiring new client-integrity token...
[webbrowser.webbrowser][info] Launching web browser: /var/lib/flatpak/exports/bin/com.brave.Browser (headless=False)
[webbrowser.webbrowser][debug] Waiting for web browser process to terminate
error: Error: server error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions