feat: add functions to fetch a user's history and subscriptions
This commit is contained in:
parent
ab19034ab1
commit
14e399594f
42 changed files with 176967 additions and 70 deletions
8
src/client/response/history.rs
Normal file
8
src/client/response/history.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use super::{video_item::YouTubeListRendererWrap, Tab, TwoColumnBrowseResults};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct History {
|
||||
pub contents: TwoColumnBrowseResults<Tab<YouTubeListRendererWrap>>,
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
pub(crate) mod channel;
|
||||
pub(crate) mod history;
|
||||
pub(crate) mod music_artist;
|
||||
pub(crate) mod music_charts;
|
||||
pub(crate) mod music_details;
|
||||
pub(crate) mod music_genres;
|
||||
pub(crate) mod music_history;
|
||||
pub(crate) mod music_item;
|
||||
pub(crate) mod music_new;
|
||||
pub(crate) mod music_playlist;
|
||||
|
|
@ -17,6 +19,7 @@ pub(crate) mod video_item;
|
|||
|
||||
pub(crate) use channel::Channel;
|
||||
pub(crate) use channel::ChannelAbout;
|
||||
pub(crate) use history::History;
|
||||
pub(crate) use music_artist::MusicArtist;
|
||||
pub(crate) use music_artist::MusicArtistAlbums;
|
||||
pub(crate) use music_charts::MusicCharts;
|
||||
|
|
@ -25,6 +28,7 @@ pub(crate) use music_details::MusicLyrics;
|
|||
pub(crate) use music_details::MusicRelated;
|
||||
pub(crate) use music_genres::MusicGenre;
|
||||
pub(crate) use music_genres::MusicGenres;
|
||||
pub(crate) use music_history::MusicHistory;
|
||||
pub(crate) use music_item::MusicContinuation;
|
||||
pub(crate) use music_new::MusicNew;
|
||||
pub(crate) use music_playlist::MusicPlaylist;
|
||||
|
|
@ -668,3 +672,6 @@ pub(crate) struct ThumbnailOverlayBadgeViewModel {
|
|||
pub(crate) struct ThumbnailBadges {
|
||||
pub thumbnail_badge_view_model: TextBox,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct Empty {}
|
||||
|
|
|
|||
8
src/client/response/music_history.rs
Normal file
8
src/client/response/music_history.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use super::music_playlist::Contents;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct MusicHistory {
|
||||
pub contents: Contents,
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ pub(crate) struct QueueMusicItem {
|
|||
#[derive(Default, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct MusicThumbnailRenderer {
|
||||
#[serde(alias = "croppedSquareThumbnailRenderer")]
|
||||
#[serde(default, alias = "croppedSquareThumbnailRenderer")]
|
||||
pub music_thumbnail_renderer: ThumbnailsWrap,
|
||||
}
|
||||
|
||||
|
|
@ -767,8 +767,16 @@ impl MusicListMapper {
|
|||
}
|
||||
// Artist / Album / Playlist
|
||||
Some((page_type, id)) => {
|
||||
// Ignore "Shuffle all" button and builtin "Liked music" and "Saved episodes" playlists
|
||||
if page_type == MusicPageType::None
|
||||
|| (page_type == (MusicPageType::Playlist { is_podcast: false })
|
||||
&& matches!(id.as_str(), "MLCT" | "LM" | "SE"))
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mut subtitle_parts = c2
|
||||
.ok_or_else(|| "could not get subtitle".to_owned())?
|
||||
.ok_or_else(|| format!("{id}: could not get subtitle"))?
|
||||
.renderer
|
||||
.text
|
||||
.split(util::DOT_SEPARATOR)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use serde::Deserialize;
|
|||
use serde_with::serde_as;
|
||||
use serde_with::{DefaultOnError, DisplayFromStr};
|
||||
|
||||
use super::{ResponseContext, Thumbnails};
|
||||
use super::{Empty, ResponseContext, Thumbnails};
|
||||
use crate::serializer::{text::Text, MapResult};
|
||||
|
||||
#[serde_as]
|
||||
|
|
@ -57,9 +57,6 @@ pub(crate) enum PlayabilityStatus {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct Empty {}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct ErrorScreen {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use crate::{
|
|||
util,
|
||||
};
|
||||
|
||||
use super::Empty;
|
||||
|
||||
/// navigation/resolve_url response model
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
@ -35,6 +37,9 @@ pub(crate) enum NavigationEndpoint {
|
|||
WatchPlaylist {
|
||||
watch_playlist_endpoint: WatchPlaylistEndpoint,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[allow(unused)]
|
||||
CreatePlaylist { create_playlist_endpoint: Empty },
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
@ -338,6 +343,10 @@ impl NavigationEndpoint {
|
|||
id: watch_playlist_endpoint.playlist_id,
|
||||
typ: MusicPageType::Playlist { is_podcast: false },
|
||||
}),
|
||||
NavigationEndpoint::CreatePlaylist { .. } => Some(MusicPage {
|
||||
id: String::new(),
|
||||
typ: MusicPageType::None,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -381,6 +390,7 @@ impl NavigationEndpoint {
|
|||
NavigationEndpoint::WatchPlaylist {
|
||||
watch_playlist_endpoint,
|
||||
} => Some(watch_playlist_endpoint.playlist_id),
|
||||
NavigationEndpoint::CreatePlaylist { .. } => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue