mirror of
https://github.com/Dasemu/x-space-downloader.git
synced 2026-10-12 00:18:35 +00:00
Both were merged in from the original history and still described the old three-module, MP3-only tool. Bring them in line with the actual video-mode/x_api/models architecture. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2.0 KiB
2.0 KiB
X Space Downloader
CLI tool that downloads X/Twitter Space recordings and renders them as an MP4 replay (participant view + audio) by default, or as plain MP3 audio.
Commands
pip install -e . # Install (editable)
x-space-dl <URL> # Run the CLI (video mode by default)
x-space-dl --mode audio <URL> # Audio-only MP3 mode
python -m src.main <URL> # Alternative invocation
pytest # Run all tests
pytest -m "not integration" # Unit tests only
pytest -m integration # Integration tests only
pytest tests/test_validator.py::test_valid_x_url # Single test
Architecture
src/main.py-- Click CLI entry point. Validates URL via validator, then delegates todownload_space(audio) ordownload_space_video(video, default). Registered asx-space-dlconsole script.src/validator.py--validate_space_url()returns(is_valid, space_id, error_message). Accepts bothx.comandtwitter.comdomains.src/downloader.py--download_space()wraps yt-dlp for audio extraction.download_space_video()fetches Space metadata/timeline viaXApiClient, downloads audio, then renders the MP4 viavideo.render_space_video().src/x_api.py--XApiClientcalls X's web GraphQL (AudioSpaceById) and Periscope replay chat endpoints to fetch title, host, participants, and a speaker timeline. Requires theX_BEARER_TOKENenvironment variable.src/video.py-- Renders the MP4 participant-view frames (Pillow) and pipes them through ffmpeg alongside the audio track.src/models.py-- Shared dataclasses:Participant,SpaceMetadata,SpeakerInterval.
Dependencies
Runtime: yt-dlp, click, requests, Pillow. System: ffmpeg. Dev: pytest, pytest-mock.
Tests mock yt_dlp.YoutubeDL and network calls -- no real network access in unit tests. Integration tests use @pytest.mark.integration.