fix: unavailable album items

This commit is contained in:
ThetaDev 2022-12-05 23:56:39 +01:00
parent b02cc15b28
commit 9e4787f501
7 changed files with 7607 additions and 6 deletions

View file

@ -580,6 +580,7 @@ async fn music_album(testfiles: &Path) {
("various_artists", "MPREb_8QkDeEIawvX"),
("single", "MPREb_bHfHGoy7vuv"),
("description", "MPREb_PiyfuVl6aYd"),
("unavailable", "MPREb_AzuWg8qAVVl"),
] {
let mut json_path = testfiles.to_path_buf();
json_path.push("music_playlist");

View file

@ -376,6 +376,7 @@ mod tests {
#[case::various_artists("various_artists", "MPREb_8QkDeEIawvX")]
#[case::single("single", "MPREb_bHfHGoy7vuv")]
#[case::description("description", "MPREb_PiyfuVl6aYd")]
#[case::unavailable("unavailable", "MPREb_AzuWg8qAVVl")]
fn map_music_album(#[case] name: &str, #[case] id: &str) {
let json_path = path!("testfiles" / "music_playlist" / format!("album_{}.json", name));
let json_file = File::open(json_path).unwrap();

View file

@ -141,6 +141,8 @@ pub(crate) struct ListMusicItem {
pub flex_column_display_style: FlexColumnDisplayStyle,
#[serde(default)]
pub item_height: ItemHeight,
#[serde(default)]
pub music_item_renderer_display_policy: DisplayPolicy,
/// Album track number
#[serde_as(as = "Option<Text>")]
pub index: Option<String>,
@ -165,6 +167,15 @@ pub(crate) enum ItemHeight {
Default,
}
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
pub(crate) enum DisplayPolicy {
#[serde(rename = "MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT")]
GreyOut,
#[default]
#[serde(other)]
Default,
}
#[serde_as]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
@ -713,7 +724,13 @@ impl MusicListMapper {
MusicPageType::Track { .. } => unreachable!(),
}
}
None => Err("could not determine item type".to_owned()),
None => {
if item.music_item_renderer_display_policy == DisplayPolicy::GreyOut {
Ok(None)
} else {
Err("could not determine item type".to_owned())
}
}
}
}
// Tile

View file

@ -0,0 +1,279 @@
---
source: src/client/music_playlist.rs
expression: map_res.c
---
MusicAlbum(
id: "MPREb_AzuWg8qAVVl",
playlist_id: Some("OLAK5uy_mux5ygfN9sbiR1ma3yh1GHTmqNekZNoAI"),
name: "13 Reasons Why (Season 3)",
cover: [
Thumbnail(
url: "https://lh3.googleusercontent.com/-MM-2mTapj54GFHiEC4XrrjnE1jKjRpbOi3Qiy4mkpf2FgvQlD775nRoblwbN5c6sJxMrzVKAXKu-fw=w60-h60-l90-rj",
width: 60,
height: 60,
),
Thumbnail(
url: "https://lh3.googleusercontent.com/-MM-2mTapj54GFHiEC4XrrjnE1jKjRpbOi3Qiy4mkpf2FgvQlD775nRoblwbN5c6sJxMrzVKAXKu-fw=w120-h120-l90-rj",
width: 120,
height: 120,
),
Thumbnail(
url: "https://lh3.googleusercontent.com/-MM-2mTapj54GFHiEC4XrrjnE1jKjRpbOi3Qiy4mkpf2FgvQlD775nRoblwbN5c6sJxMrzVKAXKu-fw=w226-h226-l90-rj",
width: 226,
height: 226,
),
Thumbnail(
url: "https://lh3.googleusercontent.com/-MM-2mTapj54GFHiEC4XrrjnE1jKjRpbOi3Qiy4mkpf2FgvQlD775nRoblwbN5c6sJxMrzVKAXKu-fw=w544-h544-l90-rj",
width: 544,
height: 544,
),
],
artists: [],
description: None,
album_type: Album,
year: Some(2019),
by_va: true,
tracks: [
TrackItem(
id: "JWeJHN5P-E8",
title: "Teeth",
duration: Some(205),
cover: [],
artists: [
ArtistId(
id: Some("UCCj0RlDqqahEB5BXVtDcPqg"),
name: "5 Seconds of Summer",
),
],
artist_id: Some("UCCj0RlDqqahEB5BXVtDcPqg"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(1),
),
TrackItem(
id: "5jd-AhBwcCQ",
title: "Die A Little",
duration: Some(174),
cover: [],
artists: [
ArtistId(
id: Some("UCMrCoizKiBxqeg5pTpBXn1A"),
name: "YUNGBLUD",
),
],
artist_id: Some("UCMrCoizKiBxqeg5pTpBXn1A"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(2),
),
TrackItem(
id: "_cmORZMgv6I",
title: "fuck, i\'m lonely (feat. Anne-Marie)",
duration: Some(199),
cover: [],
artists: [
ArtistId(
id: Some("UCWjoDY2SXJ5dvcdunWI6mjQ"),
name: "Lauv",
),
],
artist_id: Some("UCWjoDY2SXJ5dvcdunWI6mjQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(3),
),
TrackItem(
id: "M_kVMsFaGYs",
title: "Swim Home",
duration: Some(187),
cover: [],
artists: [
ArtistId(
id: Some("UChzK2t3sjnQkWzGnyKXOSSg"),
name: "Cautious Clay",
),
],
artist_id: Some("UChzK2t3sjnQkWzGnyKXOSSg"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(5),
),
TrackItem(
id: "c8AfY6yhdkM",
title: "Another Summer Night Without You",
duration: Some(159),
cover: [],
artists: [
ArtistId(
id: Some("UCvsgN5NKOzXnAURfaf3TOig"),
name: "Alexander 23",
),
],
artist_id: Some("UCvsgN5NKOzXnAURfaf3TOig"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(6),
),
TrackItem(
id: "DSQEKEegiH0",
title: "Miss U",
duration: Some(186),
cover: [],
artists: [
ArtistId(
id: Some("UCI4YNnmHjXFaaKvfdmpWvJQ"),
name: "Charli XCX",
),
],
artist_id: Some("UCI4YNnmHjXFaaKvfdmpWvJQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(7),
),
TrackItem(
id: "2TTOKQSzuQY",
title: "Favorite Drug",
duration: Some(209),
cover: [],
artists: [
ArtistId(
id: Some("UCDaFVUr2n8T7_X1f5yJ1xlw"),
name: "daydream Masi",
),
],
artist_id: Some("UCDaFVUr2n8T7_X1f5yJ1xlw"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(8),
),
TrackItem(
id: "iRaX0BfME70",
title: "Keeping It In The Dark",
duration: Some(209),
cover: [],
artists: [
ArtistId(
id: Some("UCZcc-WkffIMBVGUr6j9e6aQ"),
name: "Daya",
),
],
artist_id: Some("UCZcc-WkffIMBVGUr6j9e6aQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(9),
),
TrackItem(
id: "Kn3cruxYj0c",
title: "All That (feat. Jeremih)",
duration: Some(174),
cover: [],
artists: [
ArtistId(
id: Some("UCQPPz_A65SWYi2wXX8z76AQ"),
name: "Drama Relax",
),
],
artist_id: Some("UCQPPz_A65SWYi2wXX8z76AQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(11),
),
TrackItem(
id: "-P1FyntN_Uc",
title: "This Baby Dont Cry",
duration: Some(185),
cover: [],
artists: [
ArtistId(
id: Some("UChTOXkDhGJ0JftnfMWjpCCg"),
name: "K.Flay",
),
],
artist_id: Some("UChTOXkDhGJ0JftnfMWjpCCg"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: true,
track_nr: Some(12),
),
TrackItem(
id: "njdlNT1RRo4",
title: "Walk Forever By My Side",
duration: Some(237),
cover: [],
artists: [
ArtistId(
id: Some("UCMUB52aO4CqrUXmLwbfRWYA"),
name: "Twin Shadow",
),
],
artist_id: Some("UCMUB52aO4CqrUXmLwbfRWYA"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(13),
),
TrackItem(
id: "Si-CXM8CHqQ",
title: "Ordinary World (feat. White Sea)",
duration: Some(246),
cover: [],
artists: [
ArtistId(
id: Some("UC4YvDAbE1EYwZpj6gQ-lpLw"),
name: "Eskmo",
),
],
artist_id: Some("UC4YvDAbE1EYwZpj6gQ-lpLw"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(18),
),
],
variants: [],
)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,258 @@
---
source: tests/youtube.rs
expression: album
---
MusicAlbum(
id: "MPREb_AzuWg8qAVVl",
playlist_id: Some("OLAK5uy_mux5ygfN9sbiR1ma3yh1GHTmqNekZNoAI"),
name: "13 Reasons Why (Season 3)",
cover: "[cover]",
artists: [],
description: None,
album_type: Album,
year: Some(2019),
by_va: true,
tracks: [
TrackItem(
id: "R3VIKRtzAdE",
title: "Teeth",
duration: Some(205),
cover: [],
artists: [
ArtistId(
id: Some("UCCj0RlDqqahEB5BXVtDcPqg"),
name: "5 Seconds of Summer",
),
],
artist_id: Some("UCCj0RlDqqahEB5BXVtDcPqg"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(1),
),
TrackItem(
id: "t0v0UOgOt18",
title: "Die A Little",
duration: Some(174),
cover: [],
artists: [
ArtistId(
id: Some("UCMrCoizKiBxqeg5pTpBXn1A"),
name: "YUNGBLUD",
),
],
artist_id: Some("UCMrCoizKiBxqeg5pTpBXn1A"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(2),
),
TrackItem(
id: "HjJYAkUXrxI",
title: "fuck, i\'m lonely (feat. Anne-Marie)",
duration: Some(199),
cover: [],
artists: [
ArtistId(
id: Some("UCWjoDY2SXJ5dvcdunWI6mjQ"),
name: "Lauv",
),
],
artist_id: Some("UCWjoDY2SXJ5dvcdunWI6mjQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(3),
),
TrackItem(
id: "Hg0KUOTL06I",
title: "Swim Home",
duration: Some(187),
cover: [],
artists: [
ArtistId(
id: Some("UChzK2t3sjnQkWzGnyKXOSSg"),
name: "Cautious Clay",
),
],
artist_id: Some("UChzK2t3sjnQkWzGnyKXOSSg"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(5),
),
TrackItem(
id: "c8AfY6yhdkM",
title: "Another Summer Night Without You",
duration: Some(159),
cover: [],
artists: [
ArtistId(
id: Some("UCvsgN5NKOzXnAURfaf3TOig"),
name: "Alexander 23",
),
],
artist_id: Some("UCvsgN5NKOzXnAURfaf3TOig"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(6),
),
TrackItem(
id: "_ZmdHjVvwhc",
title: "Miss U",
duration: Some(186),
cover: [],
artists: [
ArtistId(
id: Some("UCI4YNnmHjXFaaKvfdmpWvJQ"),
name: "Charli XCX",
),
],
artist_id: Some("UCI4YNnmHjXFaaKvfdmpWvJQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(7),
),
TrackItem(
id: "wBe1Zi3q1n8",
title: "Favorite Drug",
duration: Some(209),
cover: [],
artists: [
ArtistId(
id: Some("UCDaFVUr2n8T7_X1f5yJ1xlw"),
name: "daydream Masi",
),
],
artist_id: Some("UCDaFVUr2n8T7_X1f5yJ1xlw"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(8),
),
TrackItem(
id: "l8Pj8s9uPGc",
title: "Keeping It In The Dark",
duration: Some(209),
cover: [],
artists: [
ArtistId(
id: Some("UCZcc-WkffIMBVGUr6j9e6aQ"),
name: "Daya",
),
],
artist_id: Some("UCZcc-WkffIMBVGUr6j9e6aQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(9),
),
TrackItem(
id: "Kn3cruxYj0c",
title: "All That (feat. Jeremih)",
duration: Some(174),
cover: [],
artists: [
ArtistId(
id: Some("UCQPPz_A65SWYi2wXX8z76AQ"),
name: "Drama Relax",
),
],
artist_id: Some("UCQPPz_A65SWYi2wXX8z76AQ"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(11),
),
TrackItem(
id: "Sy1lIOl1YN0",
title: "This Baby Dont Cry",
duration: Some(185),
cover: [],
artists: [
ArtistId(
id: Some("UChTOXkDhGJ0JftnfMWjpCCg"),
name: "K.Flay",
),
],
artist_id: Some("UChTOXkDhGJ0JftnfMWjpCCg"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(12),
),
TrackItem(
id: "njdlNT1RRo4",
title: "Walk Forever By My Side",
duration: Some(237),
cover: [],
artists: [
ArtistId(
id: Some("UCMUB52aO4CqrUXmLwbfRWYA"),
name: "Twin Shadow",
),
],
artist_id: Some("UCMUB52aO4CqrUXmLwbfRWYA"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(13),
),
TrackItem(
id: "Si-CXM8CHqQ",
title: "Ordinary World (feat. White Sea)",
duration: Some(246),
cover: [],
artists: [
ArtistId(
id: Some("UC4YvDAbE1EYwZpj6gQ-lpLw"),
name: "Eskmo",
),
],
artist_id: Some("UC4YvDAbE1EYwZpj6gQ-lpLw"),
album: Some(AlbumId(
id: "MPREb_AzuWg8qAVVl",
name: "13 Reasons Why (Season 3)",
)),
view_count: None,
is_video: false,
track_nr: Some(18),
),
],
variants: [],
)

View file

@ -4,18 +4,20 @@ use std::fmt::Display;
use fancy_regex::Regex;
use once_cell::sync::Lazy;
use rstest::rstest;
use rustypipe::param::Country;
use time::macros::date;
use time::OffsetDateTime;
use rustypipe::client::{ClientType, RustyPipe, RustyPipeQuery};
use rustypipe::error::{Error, ExtractionError};
use rustypipe::model::richtext::ToPlaintext;
use rustypipe::model::{
AlbumType, AudioCodec, AudioFormat, Channel, FromYtItem, MusicEntityType, MusicGenre,
Paginator, UrlTarget, Verification, VideoCodec, VideoFormat, YouTubeItem, YtStream,
richtext::ToPlaintext, AlbumType, AudioCodec, AudioFormat, Channel, FromYtItem,
MusicEntityType, MusicGenre, Paginator, UrlTarget, Verification, VideoCodec, VideoFormat,
YouTubeItem, YtStream,
};
use rustypipe::param::{
search_filter::{self, SearchFilter},
Country,
};
use rustypipe::param::search_filter::{self, SearchFilter};
//#PLAYER
@ -1364,6 +1366,7 @@ async fn music_playlist_not_found() {
#[case::ep("ep", "MPREb_u1I69lSAe5v")]
#[case::audiobook("audiobook", "MPREb_gaoNzsQHedo")]
#[case::show("show", "MPREb_cwzk8EUwypZ")]
#[case::unavailable("unavailable", "MPREb_AzuWg8qAVVl")]
#[tokio::test]
async fn music_album(#[case] name: &str, #[case] id: &str) {
let rp = RustyPipe::builder().strict().build();