$ show Stan-breaks/ytsurf
ytsurf is a single-file Bash script that turns the terminal into a YouTube frontend. It scrapes YouTube search results and channel pages via curl and perl, parses the embedded JSON with jq, and presents results in a fuzzy-finder (fzf, rofi, sentaku, or tv) with thumbnail previews rendered via chafa. Once a video is selected, the script delegates playback to mpv (or iina/syncplay) and downloading to yt-dlp. The tool supports audio-only mode, format selection, subscription management with a personalized feed, watch history, playlists, and queueing. It caches search results and feed data to avoid redundant network calls, uses a config file for persistent settings, and offers multi-selector support. While functionally rich and wellβstructured for a shell script, the codebase is tightly coupled into a single file (βΌ1400 lines), lacks unit tests beyond basic CI sanity checks, and relies on scraping fragile YouTube HTML. The packaging (Nix, Homebrew, AUR) and CI (ShellCheck on Linux/macOS) demonstrate good distribution and quality assurance.
The LLM identified 1 files worth highlighting for reuse:
The functions `create_preview_script_fzf` and `create_preview_script_fzf_channel` dynamically generate a bash script string that is passed to fzf's `--preview` option. They construct a heredoc that formats video/channel metadata and renders a thumbnail via chafa, adapting to the terminal dimensions. This pattern is reusable for any tool that wants rich fzf previews without external dependency on preview scripts; it can be extracted by copying the function and adjusting the JSON extraction logic.