fix: lyrics not found error, no channel shorts cont

This commit is contained in:
ThetaDev 2022-11-22 12:37:07 +01:00
parent d465ec203a
commit 1abdd6f3e2
15 changed files with 134 additions and 14 deletions

View file

@ -142,7 +142,7 @@ impl MapResponse<Channel<Paginator<VideoItem>>> for response::Channel {
header: self.header,
metadata: self.metadata,
microformat: self.microformat,
visitor_data: self.response_context.visitor_data,
visitor_data: self.response_context.visitor_data.clone(),
has_shorts: content.has_shorts,
has_live: content.has_live,
},
@ -157,7 +157,13 @@ impl MapResponse<Channel<Paginator<VideoItem>>> for response::Channel {
mapper.map_response(items);
MapResult {
c: Paginator::new(None, mapper.items, mapper.ctoken),
c: Paginator::new_ext(
None,
mapper.items,
mapper.ctoken,
self.response_context.visitor_data,
crate::param::ContinuationEndpoint::Browse,
),
warnings: mapper.warnings,
}
}

View file

@ -166,7 +166,9 @@ impl MapResponse<TrackDetails> for response::MusicDetails {
}
}
let content = content.ok_or(ExtractionError::InvalidData(Cow::Borrowed("no content")))?;
let content = content.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
"track not found",
)))?;
let track_item = content
.contents
.c
@ -215,7 +217,9 @@ impl MapResponse<Paginator<TrackItem>> for response::MusicDetails {
let content = tabs
.into_iter()
.find_map(|t| t.tab_renderer.content)
.ok_or(ExtractionError::InvalidData(Cow::Borrowed("no content")))?
.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
"radio unavailable",
)))?
.music_queue_renderer
.content
.playlist_panel_renderer;
@ -261,10 +265,15 @@ impl MapResponse<Lyrics> for response::MusicLyrics {
let lyrics = self
.contents
.section_list_renderer
.contents
.into_iter()
.find_map(|item| item.music_description_shelf_renderer)
.ok_or(ExtractionError::InvalidData(Cow::Borrowed("no content")))?;
.and_then(|sl| {
sl.contents
.into_iter()
.find_map(|item| item.music_description_shelf_renderer)
})
.ok_or(match self.contents.message_renderer {
Some(msg) => ExtractionError::ContentUnavailable(Cow::Owned(msg.text)),
None => ExtractionError::InvalidData(Cow::Borrowed("no content")),
})?;
Ok(MapResult {
c: Lyrics {

View file

@ -154,7 +154,7 @@ impl MapResponse<VideoPlayer> for response::Player {
// reason: "This video requires payment to watch."
"payment" => return Err(ExtractionError::VideoUnavailable("DRM", reason)),
// reason: "The uploader has not made this video available in your country."
"country" => return Err(ExtractionError::VideoGeoblock),
"country" => return Err(ExtractionError::VideoGeoblocked),
// reason (Android): "This video can only be played on newer versions of Android or other supported devices."
// reason (TV client): "Playback on other websites has been disabled by the video owner."
"Android" | "websites" => {

View file

@ -1,8 +1,11 @@
use serde::Deserialize;
use serde_with::serde_as;
use serde_with::DefaultOnError;
use crate::serializer::text::Text;
use super::AlertRenderer;
use super::ContentsRenderer;
use super::{
music_item::{ItemSection, PlaylistPanelRenderer},
ContentRenderer, SectionList,
@ -46,9 +49,12 @@ pub(crate) struct Tab {
}
/// Watch next tab
#[serde_as]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct TabRenderer {
#[serde(default)]
#[serde_as(as = "DefaultOnError")]
pub content: Option<TabContent>,
pub endpoint: Option<TabEndpoint>,
}
@ -101,12 +107,19 @@ pub(crate) struct PlaylistPanel {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct MusicLyrics {
pub contents: SectionList<LyricsContents>,
pub contents: LyricsContents,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct LyricsContents {
pub message_renderer: Option<AlertRenderer>,
pub section_list_renderer: Option<ContentsRenderer<LyricsSection>>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct LyricsSection {
pub music_description_shelf_renderer: Option<LyricsRenderer>,
}

View file

@ -1369,6 +1369,7 @@ Channel(
),
],
ctoken: Some("4qmFsgLlARIYVUNoOGdIZHR6TzJ0WGQ1OTNfYmpFcldnGsgBOGdhU0FScVBBVktNQVFxSEFRcGZRME00VVVGU2IyWnZaMWxqUTJob1ZsRXlaelJhTUdoclpFaHdVRTF1VWxsYVJGVTFUVEU1YVdGclZubFdNbU5SUVZOSlVrTm5PSGhQYWtVeVRtcFpOVTlFWnpCTmFsRjVUbFJyY1VSUmIweFRXRXBUVFROU1ZWZ3diSGhYYldNU0pEWXpOakl6WkdRd0xUQXdNREF0TW1GaFlpMWlZalF6TFRVNE1qUXlPV00yTmpFell4Z0I%3D"),
visitor_data: Some("Cgt3cDF3NkYwWWlENCiI8_CaBg%3D%3D"),
endpoint: browse,
),
)

View file

@ -1351,6 +1351,7 @@ Channel(
),
],
ctoken: Some("4qmFsgKhARIYVUNoOGdIZHR6TzJ0WGQ1OTNfYmpFcldnGoQBOGdaZ0dsNTZYQXBZQ2pCRlozTkpiRXRwYURZdFNGZG9ZbVZuUVZObmVVMUJSVFJJYTBsTVExQlFVbXR3YjBkRlMwUnBkVmRhU1VGV1FVRVNKRFl6TkRnd056Wm1MVEF3TURBdE1tRXhaUzA0TnpRNUxXUTBaalUwTjJZNE16a3pZeGdC"),
visitor_data: Some("CgtQdE9zVVR3NVBDbyjz0ZKaBg%3D%3D"),
endpoint: browse,
),
)

View file

@ -1380,6 +1380,7 @@ Channel(
),
],
ctoken: Some("4qmFsgKhARIYVUMyRGpGRTdYZjExVVJacVdCaWdjVk9RGoQBOGdaZ0dsNTZYQXBZQ2pCRlozTkpOV054YjJ4eWNYSnBjeTA0UVZObmVVMUJSVFJJYTBsTVEwbEhjV3cxYjBkRlVHcHlYM2hTU1VGV1FVRVNKRFl6TkRZMVlqZzFMVEF3TURBdE1qTXlOaTA1WTJSbUxUTmpNamcyWkRReU1tWTNOaGdC"),
visitor_data: Some("Cgs4ZFVmMzVlU1dxbyiBqpeaBg%3D%3D"),
endpoint: browse,
),
)

View file

@ -1380,6 +1380,7 @@ Channel(
),
],
ctoken: Some("4qmFsgKrARIYVUMyRGpGRTdYZjExVVJacVdCaWdjVk9RGmBFZ1oyYVdSbGIzTVlBeUFBTUFFNEFlb0RNRVZuYjBsMVMzWlpPVXREWWw5TVRraExSRWwzUVZSblpWRm5kMGx3ZFVOMGJWRlpVVjlOUjA1d2QwcEpRVlpCUVElM0QlM0SaAixicm93c2UtZmVlZFVDMkRqRkU3WGYxMVVSWnFXQmlnY1ZPUXZpZGVvczEwMg%3D%3D"),
visitor_data: Some("CgszNU5rbDVZS2hMcyim4K2ZBg%3D%3D"),
endpoint: browse,
),
)

View file

@ -995,6 +995,7 @@ Channel(
),
],
ctoken: None,
visitor_data: Some("CgtkYXJITElwYmd4OCj85a2ZBg%3D%3D"),
endpoint: browse,
),
)

View file

@ -991,6 +991,7 @@ Channel(
),
],
ctoken: Some("4qmFsgKrARIYVUNoOGdIZHR6TzJ0WGQ1OTNfYmpFcldnGmBFZ1oyYVdSbGIzTVlBeUFBTUFFNEFlb0RNRVZuYzBrM2NsTnVkazF4U1hWemRqQkJVMmQ1VFVGRk5FaHJTVXhEVUhac2NscHJSMFZKWVhWd016RkpRVlpCUVElM0QlM0SaAixicm93c2UtZmVlZFVDaDhnSGR0ek8ydFhkNTkzX2JqRXJXZ3ZpZGVvczEwMg%3D%3D"),
visitor_data: Some("CgtneXVRbGtSMWtlYyj75a2ZBg%3D%3D"),
endpoint: browse,
),
)

View file

@ -1368,6 +1368,7 @@ Channel(
),
],
ctoken: Some("4qmFsgKnARIYVUNjdmZIYS1HSFNPSEZBalUwLUllNTdBGlxFZ1oyYVdSbGIzTVlBeUFBTUFFNEFlb0RNa1ZuYzBsdFlYbFhlRkJZYnpWMlltcEJVMmQ1VFVGRk5FaHJTVTFEVFdGVWVrcHJSMFZPUzJzMmNqQkNVMEZHVVVGQpoCLGJyb3dzZS1mZWVkVUNjdmZIYS1HSFNPSEZBalUwLUllNTdBdmlkZW9zMTAy"),
visitor_data: Some("Cgs4Ri1tLW1KNWozNCjGk8yZBg%3D%3D"),
endpoint: browse,
),
)