From ce98b95008c8727839b40464563508e6b2e9bdf6 Mon Sep 17 00:00:00 2001 From: eNV25 Date: Fri, 16 Feb 2024 08:33:12 +0000 Subject: [PATCH] Respect options passed by ff2mpv extension (#12) * Respect options passed by ff2mpv extension The upstream ff2mpv extension started passing `options`. Respect those by passing them after our `config.player_args`. * Restore the order of imports --------- Co-authored-by: Ryze <50497128+ryze312@users.noreply.github.com> --- src/browser.rs | 1 + src/command.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/browser.rs b/src/browser.rs index c69dfc6..160e511 100644 --- a/src/browser.rs +++ b/src/browser.rs @@ -8,6 +8,7 @@ use crate::error::FF2MpvError; #[derive(Deserialize)] pub struct FF2MpvMessage { pub url: String, + pub options: Vec, } pub fn send_reply() -> Result<(), io::Error> { diff --git a/src/command.rs b/src/command.rs index 048b099..656a7c4 100644 --- a/src/command.rs +++ b/src/command.rs @@ -12,10 +12,9 @@ pub enum Command { ShowManifest, ShowManifestChromium, ValidateConfig, - FF2Mpv + FF2Mpv, } - impl Command { pub fn execute(&self) -> Result<(), FF2MpvError> { match self { @@ -23,7 +22,7 @@ impl Command { Command::ShowManifest => Self::show_manifest(false), Command::ShowManifestChromium => Self::show_manifest(true), Command::ValidateConfig => Self::validate_config(), - Command::FF2Mpv => Self::ff2mpv() + Command::FF2Mpv => Self::ff2mpv(), } } @@ -43,7 +42,10 @@ impl Command { fn show_manifest(chromium: bool) -> Result<(), FF2MpvError> { let executable_path = env::current_exe()?; let allowed_keyvalue = if chromium { - ("allowed_origins", "chrome-extension://ephjcajbkgplkjmelpglennepbpmdpjg") + ( + "allowed_origins", + "chrome-extension://ephjcajbkgplkjmelpglennepbpmdpjg", + ) } else { ("allowed_extensions", "ff2mpv@yossarian.net") }; @@ -72,7 +74,8 @@ impl Command { fn ff2mpv() -> Result<(), FF2MpvError> { let config = Config::build(); let ff2mpv_message = browser::get_mpv_message()?; - Command::launch_mpv(config.player_command, config.player_args, &ff2mpv_message.url)?; + let args = [config.player_args, ff2mpv_message.options].concat(); + Command::launch_mpv(config.player_command, args, &ff2mpv_message.url)?; browser::send_reply()?; Ok(())