Skip to main content

High-performance asynchronous Twitter/X Space downloader with concurrent download and automatic merging

Project description

Twitter/X Space Downloader

High-performance asynchronous Twitter Space downloader with concurrent download and automatic merging.

Features

  • 🚀 Asynchronous high-speed download, supporting 100+ concurrent connections
  • 💾 Memory streaming processing, no temporary files
  • 📦 Uses Python libraries instead of command-line tools, more stable and reliable
  • 🔄 Automatic retry mechanism, improving download success rate
  • 📊 Real-time progress display and statistics
  • 🧹 Smart cache cleanup, supports user interruption
  • 🎵 Automatically merges audio segments into a complete file
  • 🎶 Smart audio quality selection, default 64kbps voice optimization, optional high quality
  • ⚡ Fast conversion, default low quality mode conversion speed is extremely fast
  • 🏃‍♂️ Ultra-fast mode: fastest option directly saves AAC format, no conversion needed
  • 🔥 Multi-threaded FFmpeg acceleration, fully utilizing CPU performance
  • 🔐 Automatically gets cookies from Chrome, supports authenticated content download
  • 🌐 Complete browser request header simulation, improving download success rate

System Requirements

  • Python 3.7+
  • ffmpeg binary file (for audio merging)
  • Network connection

Installation

Using pip (Recommended)

pip install twitter-space-downloader

After installation, you can use the command anywhere:

# Full command name
twitter-space-downloader "https://twitter.com/i/spaces/1234567890"

# Or use the short alias
tsd "https://twitter.com/i/spaces/1234567890"

Installing from Source

Clone the repository and install:

git clone https://github.com/learnerlj/twitter-space-downloader.git
cd twitter-space-downloader
pip install .

System Requirements

  • Python 3.10+
  • ffmpeg binary file (for audio merging)

Installing ffmpeg

macOS (using Homebrew):

brew install ffmpeg

Ubuntu/Debian:

sudo apt update
sudo apt install ffmpeg

Windows:

  • Download and install FFmpeg
  • Ensure ffmpeg is in the system PATH

Usage

Basic Usage

# Ultra-fast download (AAC format, no conversion, recommended for quick preview)
twitter-space-downloader --quality fastest "https://twitter.com/i/spaces/1234567890"

# Default low quality, quick conversion, suitable for voice content
twitter-space-downloader "https://twitter.com/i/spaces/1234567890"

# Or use the short alias
tsd "https://twitter.com/i/spaces/1234567890"

Advanced Options

# Ultra-fast mode (recommended for long recordings or quick preview)
twitter-space-downloader -q fastest "https://twitter.com/i/spaces/1234567890"

# Adjust audio quality (default low, quick conversion)
twitter-space-downloader --quality medium "https://twitter.com/i/spaces/1234567890"
twitter-space-downloader -q high "https://twitter.com/i/spaces/1234567890"

# Adjust concurrency (default 100)
twitter-space-downloader --max-workers 150 "https://twitter.com/i/spaces/1234567890"

# Keep temporary files (mainly m3u8 playback list)
twitter-space-downloader --keep-temp "https://twitter.com/i/spaces/1234567890"

# Adjust retry count (default 3 times)
twitter-space-downloader --max-retries 5 "https://twitter.com/i/spaces/1234567890"

# Combine options usage
twitter-space-downloader -q high -w 200 -r 5 "https://twitter.com/i/spaces/1234567890"

# View help
twitter-space-downloader --help

Parameter Description

  • --quality, -q: Audio quality selection
    • fastest: AAC format (recommended) - no conversion, fastest speed, good compatibility
    • low: 64kbps (default) - voice optimization, fastest conversion
    • medium: 128kbps - balanced quality and speed
    • high: 192kbps - high quality audio
    • highest: 320kbps - highest quality, slower conversion
  • --max-workers, -w: Concurrent download connection count (recommended 50-200, default 100)
  • --keep-temp: Keep temporary files (only m3u8 playback list file)
  • --max-retries, -r: Maximum retry count for each segment (default 3 times)

Work Principle

  1. 🔍 Program uses yt-dlp library to extract audio stream information from Space
  2. 📥 Concurrent download all audio segments to memory (no temporary files)
  3. 🔄 Smart audio processing:
    • fastest mode: Directly save AAC format, no conversion needed (recommended)
    • other modes: Multi-threaded FFmpeg converts to MP3 format
  4. 🧹 Automatically clean temporary m3u8 playback list files

Performance Features

  • Memory streaming processing: All audio segments are processed directly in memory, avoiding disk I/O
  • Zero temporary files: No temporary audio files are generated, only m3u8 playback list
  • High concurrency: Supports 100+ concurrent connections to download simultaneously
  • Smart retry: Failed segments automatically retry, without affecting other downloads
  • Multi-threaded conversion: FFmpeg uses all CPU cores to accelerate audio conversion
  • Ultra-fast mode: fastest option directly copies AAC, conversion time is close to 0

Interrupt Handling

  • Press Ctrl+C at any time to stop download
  • Program will automatically clean temporary m3u8 files
  • Data in memory will be automatically released

Performance Optimization

  • Fastest speed: Use --quality fastest to get the fastest download experience (AAC format)
  • Good network: Can increase --max-workers to 150-200
  • Unstable network: Can reduce to 50-80
  • Retry adjustment: Adjust --max-retries according to network conditions
  • Format selection:
    • Quick preview or long recording: Choose fastest (AAC)
    • Need MP3 compatibility: Choose low or medium

Troubleshooting

  1. Installation dependency failure: Ensure Python version 3.7+, try using virtual environment
  2. ffmpeg not found: Ensure ffmpeg is installed and in the system PATH
  3. Download failure: Check if Space URL is correct and network connection is stable
  4. Memory insufficient: For very long Space, enough memory may be required

License

MIT License - See LICENSE file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twitter_space_downloader-1.4.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twitter_space_downloader-1.4.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file twitter_space_downloader-1.4.1.tar.gz.

File metadata

  • Download URL: twitter_space_downloader-1.4.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.7 Darwin/24.5.0

File hashes

Hashes for twitter_space_downloader-1.4.1.tar.gz
Algorithm Hash digest
SHA256 6edb80563a6c69e8566e2d25ae626b01b6a3fdccce749217d2abcc278df969a7
MD5 775d6781375818a43f9b212308ec5df4
BLAKE2b-256 670e0b6064400b6f3221564f36661d6c8d72d36ee8ba9fec5aa9813a67a30406

See more details on using hashes here.

File details

Details for the file twitter_space_downloader-1.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for twitter_space_downloader-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c267d8ed2cb350b2288527a317bbade79da8b5cdaac215363f99395db646def7
MD5 42ef3eaf3301b2d43d0dc2c6cbda7d36
BLAKE2b-256 bca562083bccb6084455a382f4ca41b53294c3d66ae1b88d1f7dafdc3ab0c027

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page