Show series name in video player titlebar for episodes

This commit is contained in:
Avery
2023-11-22 11:15:57 -05:00
parent b157be2603
commit 26c6b79bc5
3 changed files with 17 additions and 1 deletions

View File

@@ -3,10 +3,25 @@ use jellyfin_api::types::BaseItemDto;
use crate::tr;
pub trait ItemName {
fn series_and_episode(&self) -> Option<String>;
fn episode_name_with_number(&self) -> Option<String>;
}
impl ItemName for BaseItemDto {
fn series_and_episode(&self) -> Option<String> {
match (&self.series_name, self.episode_name_with_number()) {
(Some(series_name), Some(episode_name)) => Some(
tr!("library-series-and-episode-name", {
"seriesName" => series_name.to_string(),
"episodeName" => episode_name,
})
.to_string(),
),
(_, Some(episode_name)) => Some(episode_name),
_ => None,
}
}
fn episode_name_with_number(&self) -> Option<String> {
let name = match &self.name {
Some(name) => name,

View File

@@ -115,7 +115,7 @@ impl Component for VideoPlayer {
#[watch]
set_title: &model.media.as_ref()
.and_then(|media| media
.episode_name_with_number()
.series_and_episode()
.or(media.name.clone()))
.unwrap_or(tr!("app-name").to_string()),

View File

@@ -14,6 +14,7 @@ library-section-title =
.latest-music = Latest Music
library-episode-name-with-season-and-episode = S{$seasonNumber}:E{$episodeNumber} - {$episodeName}
library-series-and-episode-name = {$seriesName} - {$episodeName}
library-media-tile-unnamed-item = Unnamed Item