/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2024 metamuffin */ use crate::{AssetRole, SourceTrack, SourceTrackKind}; impl SourceTrackKind { pub fn letter(&self) -> char { match self { SourceTrackKind::Video { .. } => 'v', SourceTrackKind::Audio { .. } => 'a', SourceTrackKind::Subtitles => 's', } } } impl AssetRole { pub fn as_str(&self) -> &'static str { match self { AssetRole::Poster => "poster", AssetRole::Backdrop => "backdrop", } } } impl std::fmt::Display for SourceTrack { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let kspec = match &self.kind { SourceTrackKind::Video { width, height, fps, .. } => { format!("Video: {width}x{height} {}fps ", fps.unwrap_or(0.)) } SourceTrackKind::Audio { channels, sample_rate, bit_depth, } => format!( "Audio: {channels}ch {sample_rate}Hz {}bits ", bit_depth.unwrap_or(0) ), SourceTrackKind::Subtitles => "Subtitles: ".to_string(), }; f.write_fmt(format_args!( "{} {:?} {} ({})", kspec, self.name, self.language, self.codec )) } }