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 selectionfastest: AAC format (recommended) - no conversion, fastest speed, good compatibilitylow: 64kbps (default) - voice optimization, fastest conversionmedium: 128kbps - balanced quality and speedhigh: 192kbps - high quality audiohighest: 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
- 🔍 Program uses yt-dlp library to extract audio stream information from Space
- 📥 Concurrent download all audio segments to memory (no temporary files)
- 🔄 Smart audio processing:
- fastest mode: Directly save AAC format, no conversion needed (recommended)
- other modes: Multi-threaded FFmpeg converts to MP3 format
- 🧹 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+Cat 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 fastestto get the fastest download experience (AAC format) - Good network: Can increase
--max-workersto 150-200 - Unstable network: Can reduce to 50-80
- Retry adjustment: Adjust
--max-retriesaccording to network conditions - Format selection:
- Quick preview or long recording: Choose
fastest(AAC) - Need MP3 compatibility: Choose
lowormedium
- Quick preview or long recording: Choose
Troubleshooting
- Installation dependency failure: Ensure Python version 3.7+, try using virtual environment
- ffmpeg not found: Ensure ffmpeg is installed and in the system PATH
- Download failure: Check if Space URL is correct and network connection is stable
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6edb80563a6c69e8566e2d25ae626b01b6a3fdccce749217d2abcc278df969a7
|
|
| MD5 |
775d6781375818a43f9b212308ec5df4
|
|
| BLAKE2b-256 |
670e0b6064400b6f3221564f36661d6c8d72d36ee8ba9fec5aa9813a67a30406
|
File details
Details for the file twitter_space_downloader-1.4.1-py3-none-any.whl.
File metadata
- Download URL: twitter_space_downloader-1.4.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.7 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c267d8ed2cb350b2288527a317bbade79da8b5cdaac215363f99395db646def7
|
|
| MD5 |
42ef3eaf3301b2d43d0dc2c6cbda7d36
|
|
| BLAKE2b-256 |
bca562083bccb6084455a382f4ca41b53294c3d66ae1b88d1f7dafdc3ab0c027
|