diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-19 00:03:53 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-19 00:03:53 +0200 |
commit | 112dcf3009a09e87a619ce5729351c23b65e8d0d (patch) | |
tree | 0ce9ea638b817c8b381d52364b0401fe4cc8b985 | |
parent | a123a1997f3ab527ab83b44ca18bec94883f46d0 (diff) | |
download | jellything-112dcf3009a09e87a619ce5729351c23b65e8d0d.tar jellything-112dcf3009a09e87a619ce5729351c23b65e8d0d.tar.bz2 jellything-112dcf3009a09e87a619ce5729351c23b65e8d0d.tar.zst |
manual clippy fixes
-rw-r--r-- | common/src/stream.rs | 2 | ||||
-rw-r--r-- | import/src/acoustid.rs | 1 | ||||
-rw-r--r-- | remuxer/src/fragment.rs | 6 | ||||
-rw-r--r-- | remuxer/src/lib.rs | 6 | ||||
-rw-r--r-- | remuxer/src/seek_index.rs | 11 | ||||
-rw-r--r-- | remuxer/src/trim_writer.rs | 5 | ||||
-rw-r--r-- | server/src/routes/compat/jellyfin/mod.rs | 6 | ||||
-rw-r--r-- | server/src/routes/ui/admin/log.rs | 5 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 4 | ||||
-rw-r--r-- | server/src/routes/ui/player.rs | 2 | ||||
-rw-r--r-- | stream/src/stream_info.rs | 5 | ||||
-rw-r--r-- | transcoder/src/fragment.rs | 2 |
12 files changed, 23 insertions, 32 deletions
diff --git a/common/src/stream.rs b/common/src/stream.rs index ca1ec29..79cb380 100644 --- a/common/src/stream.rs +++ b/common/src/stream.rs @@ -147,7 +147,7 @@ impl StreamSpec { StreamSpec::Info { segment: Some(segment), } => format!("?info&segment={segment}"), - StreamSpec::Info { segment: None } => format!("?info"), + StreamSpec::Info { segment: None } => "?info".to_string(), StreamSpec::FragmentIndex { segment, track } => { format!("?fragmentindex&segment={segment}&track={track}") } diff --git a/import/src/acoustid.rs b/import/src/acoustid.rs index 7406976..b5a466a 100644 --- a/import/src/acoustid.rs +++ b/import/src/acoustid.rs @@ -16,6 +16,7 @@ pub(crate) struct Fingerprint { fingerprint: String, } +#[allow(unused)] pub(crate) async fn acoustid_fingerprint(path: &Path) -> Result<Arc<Fingerprint>> { async_cache_memory("fpcalc", path, || async move { let child = Command::new("fpcalc") diff --git a/remuxer/src/fragment.rs b/remuxer/src/fragment.rs index 0da1ed5..a567657 100644 --- a/remuxer/src/fragment.rs +++ b/remuxer/src/fragment.rs @@ -37,7 +37,7 @@ pub fn fragment_index(path: &Path, track: u64) -> Result<Vec<Range<f64>>> { .track_type == 17; - let index = get_seek_index(&path)?; + let index = get_seek_index(path)?; let index = index .get(&track) .ok_or(anyhow!("seek index track missing"))?; @@ -106,8 +106,8 @@ pub fn write_fragment_into( let mapped = 1; info!("\t- {track} {path:?} ({} => {mapped})", track); // info!("\t {}", info); - let file = File::open(&path).context("opening source file")?; - let index = get_seek_index(&path)?; + let file = File::open(path).context("opening source file")?; + let index = get_seek_index(path)?; let index = index .get(&track) .ok_or(anyhow!("track missing 2"))? diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs index 931d5e6..1824365 100644 --- a/remuxer/src/lib.rs +++ b/remuxer/src/lib.rs @@ -6,13 +6,13 @@ #![feature(random, exit_status_error)] pub mod extract; pub mod fragment; -pub mod metadata; pub mod matroska_to_mpeg4; +pub mod matroska_to_webm; +pub mod metadata; pub mod remux; pub mod seek_index; pub mod segment_extractor; pub mod trim_writer; -pub mod matroska_to_webm; use ebml_struct::matroska::TrackEntry; pub use fragment::write_fragment_into; @@ -85,7 +85,7 @@ pub fn ebml_track_entry(number: u64, track: &TrackEntry) -> MatroskaTag { MatroskaTag::Channels(audio.channels), ]; if let Some(bit_depth) = audio.bit_depth { - props.push(MatroskaTag::BitDepth(bit_depth.try_into().unwrap())); + props.push(MatroskaTag::BitDepth(bit_depth)); } els.push(MatroskaTag::Audio(Master::Collected(props))); } diff --git a/remuxer/src/seek_index.rs b/remuxer/src/seek_index.rs index 1e1ce02..33c1189 100644 --- a/remuxer/src/seek_index.rs +++ b/remuxer/src/seek_index.rs @@ -15,7 +15,7 @@ use jellymatroska::{ use log::{debug, info, trace, warn}; use std::{collections::BTreeMap, fs::File, io::BufReader, path::Path, sync::Arc}; -#[derive(Debug, Clone, Decode, Encode)] +#[derive(Debug, Clone, Default, Decode, Encode)] pub struct SeekIndex { pub blocks: Vec<BlockIndex>, pub keyframes: Vec<usize>, @@ -29,15 +29,6 @@ pub struct BlockIndex { pub size: usize, } -impl Default for SeekIndex { - fn default() -> Self { - Self { - blocks: Vec::new(), - keyframes: Vec::new(), - } - } -} - pub fn get_seek_index(path: &Path) -> anyhow::Result<Arc<BTreeMap<u64, Arc<SeekIndex>>>> { cache_memory("seekindex-v1", path, move || { info!("generating seek index for {path:?}"); diff --git a/remuxer/src/trim_writer.rs b/remuxer/src/trim_writer.rs index ad400c1..2c1b7ed 100644 --- a/remuxer/src/trim_writer.rs +++ b/remuxer/src/trim_writer.rs @@ -34,10 +34,7 @@ impl<W: Write> Write for TrimWriter<W> { let end = end.clamp(0, buf.len() as isize) as usize; if self.position >= self.range.end { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - anyhow!("range ended"), - )); + return Err(std::io::Error::other(anyhow!("range ended"))); } let tbuf = &buf[start..end]; diff --git a/server/src/routes/compat/jellyfin/mod.rs b/server/src/routes/compat/jellyfin/mod.rs index 7393c5f..e37d7d1 100644 --- a/server/src/routes/compat/jellyfin/mod.rs +++ b/server/src/routes/compat/jellyfin/mod.rs @@ -736,7 +736,8 @@ fn item_object(node: &Node, userdata: &NodeUserData) -> JellyfinItem { parent_id: "todo-parent".to_owned(), // TODO r#type: match node.kind { NodeKind::Movie | NodeKind::Video | NodeKind::ShortFormVideo => JellyfinItemType::Movie, - NodeKind::Collection | _ => JellyfinItemType::CollectionFolder, + NodeKind::Collection => JellyfinItemType::CollectionFolder, + _ => JellyfinItemType::CollectionFolder, }, people: node .people @@ -772,7 +773,8 @@ fn item_object(node: &Node, userdata: &NodeUserData) -> JellyfinItem { "aspect-thumb" => 16. / 9., "aspect-land" => 2f64.sqrt(), "aspect-port" => 1. / 2f64.sqrt(), - "aspect-square" | _ => 1., + "aspect-square" => 1., + _ => 1., }, collection_type: "unknown".to_owned(), image_tags: BTreeMap::from_iter([("Primary".to_string(), "poster".to_string())]), diff --git a/server/src/routes/ui/admin/log.rs b/server/src/routes/ui/admin/log.rs index f962138..fc85b37 100644 --- a/server/src/routes/ui/admin/log.rs +++ b/server/src/routes/ui/admin/log.rs @@ -33,13 +33,15 @@ pub fn enable_logging() { log::set_max_level(log::LevelFilter::Debug); } +type LogBuffer = VecDeque<Arc<LogLine>>; + pub struct Log { inner: env_logger::Logger, stream: ( broadcast::Sender<Arc<LogLine>>, broadcast::Sender<Arc<LogLine>>, ), - log: RwLock<(VecDeque<Arc<LogLine>>, VecDeque<Arc<LogLine>>)>, + log: RwLock<(LogBuffer, LogBuffer)>, } pub struct LogLine { @@ -69,7 +71,6 @@ pub fn r_admin_log<'a>(_session: AdminSession, warnonly: bool) -> MyResult<DynLa }} } }, - ..Default::default() }) } diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 76ecd82..57e8562 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -41,7 +41,7 @@ use std::{cmp::Reverse, collections::BTreeMap, fmt::Write, sync::Arc}; /// This function is a stub and only useful for use in the uri! macro. #[get("/n/<id>")] pub fn r_library_node(id: NodeID) { - id.0[0]; + let _ = id; } #[get("/n/<id>?<parents>&<children>&<filter..>")] @@ -129,7 +129,7 @@ pub fn get_similar_media( ranking .into_iter() .take(32) - .map(|(pid, _)| db.get_node_with_userdata(pid, &session)) + .map(|(pid, _)| db.get_node_with_userdata(pid, session)) .collect::<anyhow::Result<Vec<_>>>() } diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs index ff404fa..5222573 100644 --- a/server/src/routes/ui/player.rs +++ b/server/src/routes/ui/player.rs @@ -143,7 +143,7 @@ pub fn player_conf<'a>(item: Arc<Node>, playing: bool) -> anyhow::Result<DynRend match &track.kind { SourceTrackKind::Audio { .. } => audio_tracks.push((tid, track)), SourceTrackKind::Video { .. } => video_tracks.push((tid, track)), - SourceTrackKind::Subtitles { .. } => sub_tracks.push((tid, track)), + SourceTrackKind::Subtitles => sub_tracks.push((tid, track)), } } diff --git a/stream/src/stream_info.rs b/stream/src/stream_info.rs index 790d342..38270b7 100644 --- a/stream/src/stream_info.rs +++ b/stream/src/stream_info.rs @@ -25,11 +25,11 @@ use tokio::{ }; async fn async_matroska_metadata(path: PathBuf) -> Result<Arc<MatroskaMetadata>> { - Ok(spawn_blocking(move || matroska_metadata(&path)).await??) + spawn_blocking(move || matroska_metadata(&path)).await? } async fn async_get_track_sizes(path: PathBuf) -> Result<BTreeMap<u64, usize>> { - Ok(spawn_blocking(move || get_track_sizes(&path)).await??) + spawn_blocking(move || get_track_sizes(&path)).await? } pub(crate) struct InternalStreamInfo { @@ -104,7 +104,6 @@ fn stream_formats(t: &TrackEntry, remux_bitrate: f64) -> Vec<StreamFormatInfo> { channels: t.audio.as_ref().map(|a| a.channels as usize), width: t.video.as_ref().map(|v| v.pixel_width), height: t.video.as_ref().map(|v| v.pixel_height), - ..Default::default() }); match t.track_type { diff --git a/transcoder/src/fragment.rs b/transcoder/src/fragment.rs index 3e07ad7..e64e690 100644 --- a/transcoder/src/fragment.rs +++ b/transcoder/src/fragment.rs @@ -39,7 +39,7 @@ pub async fn transcode( let filter = match kind { TrackKind::Video => format!("-vf scale={}:-1", format.width.unwrap()), - TrackKind::Audio => format!(""), + TrackKind::Audio => String::new(), TrackKind::Subtitle => String::new(), }; let typechar = match kind { |