feat: default to IINA for piped playback
This commit is contained in:
+6
-6
@@ -1,13 +1,13 @@
|
|||||||
//! A Ratatui YouTube browser backed by yt-dlp and FFmpeg, with no API key.
|
//! A Ratatui YouTube browser backed by yt-dlp and FFmpeg, with no API key.
|
||||||
//!
|
//!
|
||||||
//! Run `cargo run -- --player mpv --player-arg=--volume=50 "rust programming"`.
|
//! Run `cargo run -- "rust programming"`; macOS defaults to IINA, other platforms to mpv.
|
||||||
//! Without a CLI query, start in insert mode; otherwise search and start in normal mode.
|
//! Without a CLI query, start in insert mode; otherwise search and start in normal mode.
|
||||||
//! Insert: Enter submits a changed query and returns to normal; Esc returns without searching.
|
//! Insert: Enter submits a changed query and returns to normal; Esc returns without searching.
|
||||||
//! Normal: j/k selects, Enter streams, and i returns to insert mode to edit the query.
|
//! Normal: j/k selects, Enter streams, and i returns to insert mode to edit the query.
|
||||||
//! Normal-mode d opens the full description; Up/Down scrolls lines and PgUp/PgDn scrolls pages.
|
//! Normal-mode d opens the full description; Up/Down scrolls lines and PgUp/PgDn scrolls pages.
|
||||||
//! The centered popup uses up to 70% width and 60% height, capped at 96 by 20 cells.
|
//! The centered popup uses up to 70% width and 60% height, capped at 96 by 20 cells.
|
||||||
//! Esc closes the popup; j/k loads the selected video's description and i returns to editing.
|
//! Esc closes the popup; j/k loads the selected video's description and i returns to editing.
|
||||||
//! The player must read media from standard input when passed `-`.
|
//! IINA receives `--stdin`; other players must read standard input when passed `-`.
|
||||||
//! Audio and video are streamed through a pipe, never saved to a video file.
|
//! Audio and video are streamed through a pipe, never saved to a video file.
|
||||||
//! See `--help` for controls; replacing playback or quitting cancels its processes.
|
//! See `--help` for controls; replacing playback or quitting cancels its processes.
|
||||||
|
|
||||||
@@ -30,14 +30,14 @@ use youtube::{Job, Playback, Video};
|
|||||||
#[command(
|
#[command(
|
||||||
version,
|
version,
|
||||||
about = "Search YouTube and stream videos to your chosen player",
|
about = "Search YouTube and stream videos to your chosen player",
|
||||||
after_help = "Requires yt-dlp, FFmpeg, and a player on PATH.\nThe player receives audio/video on standard input, with '-' as its last argument.\nWithout a CLI query, start in INSERT; a CLI query is searched automatically in NORMAL.\nINSERT: type to edit; Enter submits if changed and returns to NORMAL; Esc returns without submitting.\nNORMAL: j/k or arrows select; Enter streams; i edits the query; d toggles description; q quits.\nOpening the description fetches full video metadata, preserving paragraphs and caching it for these results.\nThe centered description window uses up to 70% width and 60% height, capped at 96 by 20 cells.\nWhile it is open, Up/Down scroll lines and PgUp/PgDn scroll pages; j/k still selects videos.\nEsc closes the description; i closes it to edit the query. Scrolling stays within the text.\nCtrl-U clears in INSERT; Ctrl-C quits in either mode.\nSelecting another video replaces playback. Quitting stops playback.\nExample: tubular --player mpv --player-arg=--volume=50 \"rust programming\""
|
after_help = "Requires yt-dlp, FFmpeg, and a player on PATH.\nDefaults to IINA on macOS and mpv elsewhere; --player overrides the default.\nIINA receives '--stdin'; other players receive '-' to read audio/video from standard input.\nWithout a CLI query, start in INSERT; a CLI query is searched automatically in NORMAL.\nINSERT: type to edit; Enter submits if changed and returns to NORMAL; Esc returns without submitting.\nNORMAL: j/k or arrows select; Enter streams; i edits the query; d toggles description; q quits.\nOpening the description fetches full video metadata, preserving paragraphs and caching it for these results.\nThe centered description window uses up to 70% width and 60% height, capped at 96 by 20 cells.\nWhile it is open, Up/Down scroll lines and PgUp/PgDn scroll pages; j/k still selects videos.\nEsc closes the description; i closes it to edit the query. Scrolling stays within the text.\nCtrl-U clears in INSERT; Ctrl-C quits in either mode.\nSelecting another video replaces playback. Quitting stops playback.\nExample: tubular --player mpv --player-arg=--volume=50 \"rust programming\""
|
||||||
)]
|
)]
|
||||||
struct Options {
|
struct Options {
|
||||||
/// Player executable (must support '-' for media on standard input).
|
/// Player executable (IINA or a player supporting '-' for standard input).
|
||||||
#[arg(long, default_value = "mpv")]
|
#[arg(long, default_value = if cfg!(target_os = "macos") { "iina" } else { "mpv" })]
|
||||||
player: OsString,
|
player: OsString,
|
||||||
|
|
||||||
/// Argument passed to the player before '-'; repeat for multiple arguments.
|
/// Argument passed to the player before its standard-input flag; repeat as needed.
|
||||||
#[arg(long, allow_hyphen_values = true)]
|
#[arg(long, allow_hyphen_values = true)]
|
||||||
player_arg: Vec<OsString>,
|
player_arg: Vec<OsString>,
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -230,7 +230,10 @@ impl Playback {
|
|||||||
let stream = extractor.stdout.take().expect("stdout is piped");
|
let stream = extractor.stdout.take().expect("stdout is piped");
|
||||||
let player = match isolated_command(player)
|
let player = match isolated_command(player)
|
||||||
.args(args)
|
.args(args)
|
||||||
.arg("-")
|
.arg(match std::path::Path::new(player).file_name() {
|
||||||
|
Some(name) if name == "iina" || name == "iina-cli" => "--stdin",
|
||||||
|
_ => "-",
|
||||||
|
})
|
||||||
.stdin(Stdio::from(stream))
|
.stdin(Stdio::from(stream))
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
|
|||||||
Reference in New Issue
Block a user