fix: support podcast episodes in new videos
This commit is contained in:
parent
a5ec111af4
commit
53a8ec680a
5 changed files with 47180 additions and 20 deletions
|
|
@ -112,13 +112,14 @@ mod tests {
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case::default("default")]
|
#[case::default("default")]
|
||||||
|
#[case::default("w_podcasts")]
|
||||||
fn map_music_new_videos(#[case] name: &str) {
|
fn map_music_new_videos(#[case] name: &str) {
|
||||||
let json_path = path!(*TESTFILES / "music_new" / format!("videos_{name}.json"));
|
let json_path = path!(*TESTFILES / "music_new" / format!("videos_{name}.json"));
|
||||||
let json_file = File::open(json_path).unwrap();
|
let json_file = File::open(json_path).unwrap();
|
||||||
|
|
||||||
let new_albums: response::MusicNew =
|
let new_videos: response::MusicNew =
|
||||||
serde_json::from_reader(BufReader::new(json_file)).unwrap();
|
serde_json::from_reader(BufReader::new(json_file)).unwrap();
|
||||||
let map_res: MapResult<Vec<TrackItem>> = new_albums
|
let map_res: MapResult<Vec<TrackItem>> = new_videos
|
||||||
.map_response("", Language::En, None, None)
|
.map_response("", Language::En, None, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::{
|
||||||
text::{Text, TextComponent, TextComponents},
|
text::{Text, TextComponent, TextComponents},
|
||||||
MapResult,
|
MapResult,
|
||||||
},
|
},
|
||||||
util::{self, dictionary},
|
util::{self, dictionary, timeago},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -780,10 +780,17 @@ impl MusicListMapper {
|
||||||
.map(|st| map_album_type(st.first_str(), self.lang))
|
.map(|st| map_album_type(st.first_str(), self.lang))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let (artists, by_va) = map_artists(subtitle_p2);
|
let (mut artists, by_va) = map_artists(subtitle_p2);
|
||||||
|
|
||||||
let artist_id = map_artist_id_fallback(item.menu, artists.first());
|
let artist_id = map_artist_id_fallback(item.menu, artists.first());
|
||||||
|
|
||||||
|
// Album artist links may be invisible on the search page, so
|
||||||
|
// fall back to menu data
|
||||||
|
if let Some(a1) = artists.first_mut() {
|
||||||
|
if a1.id.is_none() {
|
||||||
|
a1.id = artist_id.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let year =
|
let year =
|
||||||
subtitle_p3.and_then(|st| util::parse_numeric(st.first_str()).ok());
|
subtitle_p3.and_then(|st| util::parse_numeric(st.first_str()).ok());
|
||||||
|
|
||||||
|
|
@ -855,23 +862,38 @@ impl MusicListMapper {
|
||||||
match item.navigation_endpoint.music_page() {
|
match item.navigation_endpoint.music_page() {
|
||||||
Some(music_page) => match music_page.typ {
|
Some(music_page) => match music_page.typ {
|
||||||
MusicPageType::Track { vtype } => {
|
MusicPageType::Track { vtype } => {
|
||||||
let (artists, by_va) = map_artists(subtitle_p1);
|
let (artists, by_va, view_count, duration) = if vtype == MusicVideoType::Episode
|
||||||
|
{
|
||||||
self.items.push(MusicItem::Track(TrackItem {
|
let (artists, by_va) = map_artists(subtitle_p2);
|
||||||
id: music_page.id,
|
let duration = subtitle_p1.and_then(|s| {
|
||||||
name: item.title,
|
timeago::parse_video_duration_or_warn(
|
||||||
duration: None,
|
self.lang,
|
||||||
cover: item.thumbnail_renderer.into(),
|
s.first_str(),
|
||||||
artist_id: artists.first().and_then(|a| a.id.clone()),
|
&mut self.warnings,
|
||||||
artists,
|
)
|
||||||
album: None,
|
});
|
||||||
view_count: subtitle_p2.and_then(|c| {
|
(artists, by_va, None, duration)
|
||||||
|
} else {
|
||||||
|
let (artists, by_va) = map_artists(subtitle_p1);
|
||||||
|
let view_count = subtitle_p2.and_then(|c| {
|
||||||
util::parse_large_numstr_or_warn(
|
util::parse_large_numstr_or_warn(
|
||||||
c.first_str(),
|
c.first_str(),
|
||||||
self.lang,
|
self.lang,
|
||||||
&mut self.warnings,
|
&mut self.warnings,
|
||||||
)
|
)
|
||||||
}),
|
});
|
||||||
|
(artists, by_va, view_count, None)
|
||||||
|
};
|
||||||
|
|
||||||
|
self.items.push(MusicItem::Track(TrackItem {
|
||||||
|
id: music_page.id,
|
||||||
|
name: item.title,
|
||||||
|
duration,
|
||||||
|
cover: item.thumbnail_renderer.into(),
|
||||||
|
artist_id: artists.first().and_then(|a| a.id.clone()),
|
||||||
|
artists,
|
||||||
|
album: None,
|
||||||
|
view_count,
|
||||||
is_video: vtype.is_video(),
|
is_video: vtype.is_video(),
|
||||||
track_nr: None,
|
track_nr: None,
|
||||||
by_va,
|
by_va,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
44183
testfiles/music_new/videos_w_podcasts.json
Normal file
44183
testfiles/music_new/videos_w_podcasts.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1389,9 +1389,10 @@ fn music_playlist_cont(#[case] id: &str, rp: RustyPipe) {
|
||||||
assert_gte(track_count, 100, "tracks");
|
assert_gte(track_count, 100, "tracks");
|
||||||
|
|
||||||
assert_eq!(track_count, playlist.tracks.count.unwrap());
|
assert_eq!(track_count, playlist.tracks.count.unwrap());
|
||||||
assert_eq!(
|
assert_gte(
|
||||||
usize::try_from(track_count).unwrap(),
|
usize::try_from(track_count).unwrap(),
|
||||||
playlist.tracks.items.len()
|
playlist.tracks.items.len(),
|
||||||
|
"tracks",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2263,7 +2264,12 @@ fn music_new_videos(rp: RustyPipe) {
|
||||||
validate::video_id(&video.id).unwrap();
|
validate::video_id(&video.id).unwrap();
|
||||||
assert!(!video.name.is_empty());
|
assert!(!video.name.is_empty());
|
||||||
assert!(!video.cover.is_empty(), "got no cover");
|
assert!(!video.cover.is_empty(), "got no cover");
|
||||||
assert_gte(video.view_count.unwrap(), 1000, "views");
|
if let Some(view_count) = video.view_count {
|
||||||
|
assert_gte(view_count, 1000, "views");
|
||||||
|
} else {
|
||||||
|
// Podcast episode: shows duration instead of view count
|
||||||
|
assert!(video.duration.is_some(), "no view count or duration");
|
||||||
|
}
|
||||||
assert!(video.is_video);
|
assert!(video.is_video);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue