Skip to content

Instantly share code, notes, and snippets.

@rodrigopolo
Last active May 25, 2026 01:07
Show Gist options
  • Select an option

  • Save rodrigopolo/40029718a85963399784ae35b06adcaf to your computer and use it in GitHub Desktop.

Select an option

Save rodrigopolo/40029718a85963399784ae35b06adcaf to your computer and use it in GitHub Desktop.
Twitter/X Space Downloader

Twitter/X Space Downloader

Available here: https://gist.github.com/rodrigopolo/40029718a85963399784ae35b06adcaf

Dependencies:

  • yt-dpl
  • wget
  • aria2c
  • ffmpeg

Set the file permissions with chmod +x downloader.sh and run the script, with the URL of the Twitter/X Space as the first argument:

./downloader.sh https://twitter.com/i/spaces/1djxXNyNogvGZ
#!/usr/bin/env bash
#
# Twitter/X Space Downloader Bash Script
# Copyright (c) 2024 Rodrigo Polo - rodrigopolo.com - The MIT License (MIT)
#
# Check if a stream URL is provided
if [ -z "$1" ]; then
echo "Usage: $0 <stream_url>"
exit 1
fi
# Modifying the internal field separator
IFS=$'\t\n'
SPACEURL="$1"
STREAM=$(yt-dlp --cookies-from-browser opera -g $SPACEURL)
FILE_NAME=$(yt-dlp --cookies-from-browser opera --get-filename -o "%(upload_date)s - %(uploader_id)s.%(title)s.%(id)s.%(ext)s" $SPACEURL)
# Get the stream path
STREAMPATH=$(echo "$STREAM" | grep -Eo "(^.*[\/])")
# Download the stream
if ! wget "$STREAM" -O stream.m3u8; then
echo "Failed to download the stream."
exit 1
fi
# Prefix the URLs for the chunks
cat stream.m3u8 | sed -E "s|(^[^.#]+.aac$)|$STREAMPATH\1|g" > modified.m3u8
# Download the chunks
aria2c -x 10 --console-log-level warn -i modified.m3u8
# Join the chunks
ffmpeg -i stream.m3u8 -vn -acodec copy -movflags +faststart "$FILE_NAME"
# Clean-up temporary files
eval "$(cat stream.m3u8| grep -Eo "(^[^.#]+.aac$)" | sed 's/^/rm /')"
rm stream.m3u8 modified.m3u8
@redblocklabshq

Copy link
Copy Markdown

Thanks! I’m looking for a way to transcribe the Twitter spaces next and then summarize the Twitter spaces using a local LLM like Ollama. Do you have any suggestions?

@rodrigopolo

Copy link
Copy Markdown
Author

Thanks! I’m looking for a way to transcribe the Twitter spaces next and then summarize the Twitter spaces using a local LLM like Ollama. Do you have any suggestions?

  1. Whisper: https://github.com/rodrigopolo/cheatsheets/blob/master/whisper.md
  2. Adobe Photoshop
  3. DaVinci Resolve
  4. Subtitle Edit (PC Only) that uses Whisper or Vosk/Kaldi https://www.nikse.dk/subtitleedit

@redblocklabshq

redblocklabshq commented Dec 23, 2024

Copy link
Copy Markdown

Thank you for the suggestions! Appreciate you.

The cheatsheets are really helpful.

@coffnix

coffnix commented Apr 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment