$ show nathom/streamrip
streamrip is a CLI application that downloads music tracks, albums, playlists, and artist discographies from Qobuz, Tidal, Deezer, and SoundCloud. It operates as an async pipeline: user input (URLs, IDs, or search queries) is parsed into pending items, resolved into metadata-rich media objects, and then concurrently downloaded with rate limiting. The system handles audio conversion (via ffmpeg), metadata tagging (via mutagen), artwork embedding, and maintains a SQLite database to avoid re-downloading known tracks. The codebase is modular with separate client classes for each streaming service, media abstraction layers, and a config system based on TOML. It uses rich for console output and progress bars.
The LLM identified 5 files worth highlighting for reuse:
Provides an abstract base class `Converter` and concrete implementations (FLAC, LAME, ALAC, Vorbis, OPUS, AAC) that wrap ffmpeg. Each codec class defines its own ffmpeg arguments and container extension. The module handles sampling rate and bit depth constraints for lossless codecs, and offers dynamic quality argument generation for lossy codecs. This is a self-contained, reusable pattern for integrating ffmpeg conversion in any Python project.
Implements a lightweight, generic SQLite wrapper (`DatabaseBase`) with an interface (`DatabaseInterface`) and concrete implementations (`Downloads`, `Failed`). It supports create, contains, add, remove, and all operations. Includes a `Dummy` implementation for disabling databases. The `Database` dataclass composes these into a unit. The code is clean, well-typed, and easily extractable for any project needing a simple persistent key-value or row store.
Provides `clean_filename` and `clean_filepath` functions that leverage the `pathvalidate` library to sanitize file/directory names and paths. Includes a `truncate_str` function to limit byte length, and optional character restrictions via an allowed-characters set. This is a self-contained utility module ideal for any application that needs to create safe filesystem names from user or metadata strings.
Offers reusable functions for creating SSL contexts with optional verification and certifi integration. `create_ssl_context` and `get_aiohttp_connector_kwargs` abstract away SSL configuration for aiohttp sessions. Also includes a `print_ssl_error_help` function for user-friendly error messages. This small module is self-contained and can be reused in any async Python project requiring flexible SSL control.
Manages a global progress bar display using `rich`. The `ProgressManager` class creates and updates multiple progress bars, supports title banners, and provides a `Handle` context manager for callbacks. The module offers simple functions (`get_progress_callback`, `add_title`, `remove_title`, `clear_progress`) that wrap the manager. This is a reusable component for any CLI tool needing rich, live progress feedback.