$ show mps-youtube/yewtube
yewtube is a terminal-based YouTube player and downloader, forked from mps-youtube. It provides a full-featured CLI for searching, streaming, downloading, and managing YouTube content without requiring a YouTube API key. The application uses yt-dlp and youtube-search-python as backends for video extraction and search. It supports multiple media players (mpv, mplayer, VLC), MPRIS integration for desktop media control, Last.fm scrobbling, playlist management (local and YouTube), and various download/transcoding options. The architecture is a monolithic Python application with a command-loop pattern, global state management via a dedicated module, and a plugin-like player abstraction. While the codebase shows its age with some tightly coupled modules and global variables, it contains well-designed components such as a config system with validation, an abstract player interface, and a command registration decorator. The project is actively maintained with recent commits and releases.
The LLM identified 3 files worth highlighting for reuse:
Implements a configuration system with typed ConfigItem objects, validation functions, and JSON persistence. Each config item supports type checking, range validation, custom check functions, and temporary overrides. The singleton _Config class provides attribute-style access and automatic saving. This module is self-contained and could be extracted as a reusable configuration library for any CLI application.
Defines BasePlayer and CmdPlayer abstract classes that provide a clean interface for implementing different media players. Handles playback flow (play, next, previous, stop), stream selection, progress display, MPRIS metadata updates, and error handling. The CmdPlayer subclass manages subprocess-based players with argument generation and status parsing. This abstraction allows easy addition of new players (see players/mpv.py, players/mplayer.py, players/vlc.py) and demonstrates good separation of concerns.
Provides a @command decorator that registers functions as CLI commands with associated regex patterns and tab-completion hints. Commands are stored as namedtuples in a global list and matched against user input in the main loop. This pattern enables clean separation of command logic and easy extensibility. The decorator also integrates with a CommandCompleter for readline tab completion. This module is a lightweight command routing framework that could be reused in other CLI applications.