From 8f66997c4829fd2d9f040ab1f17fb39c3f38d0e2 Mon Sep 17 00:00:00 2001 From: alexpasmantier Date: Tue, 14 Jan 2025 18:14:46 +0100 Subject: [PATCH] fix(cable): cable channels now take precedence over builtins for the cli / shell integration --- crates/television/cli.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/television/cli.rs b/crates/television/cli.rs index eac206e..9f218b9 100644 --- a/crates/television/cli.rs +++ b/crates/television/cli.rs @@ -178,17 +178,19 @@ pub enum ParsedCliChannel { fn parse_channel(channel: &str) -> Result { let cable_channels = cable::load_cable_channels().unwrap_or_default(); - CliTvChannel::try_from(channel) - .map(ParsedCliChannel::Builtin) - .or_else(|_| { - cable_channels - .iter() - .find(|(k, _)| k.to_lowercase() == channel) - .map_or_else( - || Err(eyre!("Unknown channel: {}", channel)), - |(_, v)| Ok(ParsedCliChannel::Cable(v.clone())), - ) - }) + // try to parse the channel as a cable channel + cable_channels + .iter() + .find(|(k, _)| k.to_lowercase() == channel) + .map_or_else( + || { + // try to parse the channel as a builtin channel + CliTvChannel::try_from(channel) + .map(ParsedCliChannel::Builtin) + .map_err(|_| eyre!("Unknown channel: {}", channel)) + }, + |(_, v)| Ok(ParsedCliChannel::Cable(v.clone())), + ) } pub fn list_cable_channels() -> Vec {