Created
December 6, 2025 22:51
-
-
Save extratone/0b19e65caa03302ffe84d8642d30194a to your computer and use it in GitHub Desktop.
Accepts the Twitch username of a live channel as input, resolves the highest quality .m3u8 URL available for it via `streamlink`, open said URL as streaming media with VLC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Check if a username was provided | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <twitch_username>" | |
| exit 1 | |
| fi | |
| USERNAME=$1 | |
| echo "Checking for live stream for user: $USERNAME..." | |
| # Retrieve the highest quality .m3u8 URL using streamlink | |
| # --stream-url prints the URL instead of playing it directly | |
| # 2>&1 redirects stderr to stdout so we can hide 'error' messages if offline | |
| STREAM_URL=$(streamlink --stream-url "twitch.tv/$USERNAME" best 2>/dev/null) | |
| # Check if we got a valid URL back (Streamlink returns nothing or an error msg if offline) | |
| if [[ "$STREAM_URL" == http* ]]; then | |
| echo "Stream found! Opening in VLC..." | |
| echo "URL: $STREAM_URL" | |
| # Open the retrieved URL in VLC | |
| # --meta-title sets the window title to the Twitch username | |
| vlc "$STREAM_URL" --meta-title "Twitch: $USERNAME" 2>/dev/null & | |
| else | |
| echo "Error: Channel is likely offline or does not exist." | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Paired with @Chatterino, this widdle script has the potential to enable reliable, pleasant, even efficient Twitch consumption. Incredible.