finished client refactor, client2 -> client
This commit is contained in:
parent
05f609e247
commit
8548bc81e9
39 changed files with 1484 additions and 11468 deletions
|
|
@ -4,6 +4,7 @@ use serde_with::VecSkipError;
|
|||
|
||||
use super::TimeOverlay;
|
||||
use super::{ContentRenderer, ContentsRenderer, Thumbnails, VideoListItem};
|
||||
use crate::serializer::text::Text;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
@ -63,11 +64,11 @@ pub struct GridRenderer {
|
|||
pub struct ChannelVideo {
|
||||
pub video_id: String,
|
||||
pub thumbnail: Thumbnails,
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub title: String,
|
||||
#[serde_as(as = "Option<crate::serializer::text::Text>")]
|
||||
#[serde_as(as = "Option<Text>")]
|
||||
pub published_time_text: Option<String>,
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub view_count_text: String,
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub thumbnail_overlays: Vec<TimeOverlay>,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub mod video;
|
|||
pub use channel::Channel;
|
||||
pub use player::Player;
|
||||
pub use playlist::Playlist;
|
||||
pub use playlist::PlaylistCont;
|
||||
pub use playlist_music::PlaylistMusic;
|
||||
pub use video::Video;
|
||||
pub use video::VideoComments;
|
||||
|
|
@ -15,7 +16,7 @@ pub use video::VideoRecommendations;
|
|||
use serde::Deserialize;
|
||||
use serde_with::{serde_as, DefaultOnError, VecSkipError};
|
||||
|
||||
use crate::serializer::text::TextLink;
|
||||
use crate::serializer::text::{Text, TextLink, TextLinks};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
@ -93,10 +94,10 @@ pub struct VideoOwner {
|
|||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct VideoOwnerRenderer {
|
||||
#[serde_as(as = "crate::serializer::text::TextLink")]
|
||||
#[serde_as(as = "TextLink")]
|
||||
pub title: TextLink,
|
||||
pub thumbnail: Thumbnails,
|
||||
#[serde_as(as = "Option<crate::serializer::text::Text>")]
|
||||
#[serde_as(as = "Option<Text>")]
|
||||
pub subscriber_count_text: Option<String>,
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
|
|
@ -132,7 +133,7 @@ pub struct TimeOverlay {
|
|||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TimeOverlayRenderer {
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub text: String,
|
||||
#[serde(default)]
|
||||
#[serde_as(deserialize_as = "DefaultOnError")]
|
||||
|
|
@ -198,7 +199,7 @@ pub struct MusicColumn {
|
|||
#[serde_as]
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct MusicColumnRenderer {
|
||||
#[serde_as(as = "crate::serializer::text::TextLinks")]
|
||||
#[serde_as(as = "TextLinks")]
|
||||
pub text: Vec<TextLink>,
|
||||
}
|
||||
|
||||
|
|
@ -213,3 +214,23 @@ pub struct MusicContinuation {
|
|||
pub struct MusicContinuationData {
|
||||
pub continuation: String,
|
||||
}
|
||||
|
||||
impl From<Thumbnail> for crate::model::Thumbnail {
|
||||
fn from(tn: Thumbnail) -> Self {
|
||||
crate::model::Thumbnail {
|
||||
url: tn.url,
|
||||
width: tn.width,
|
||||
height: tn.height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Thumbnails> for Vec<crate::model::Thumbnail> {
|
||||
fn from(ts: Thumbnails) -> Self {
|
||||
let mut thumbnails = vec![];
|
||||
for t in ts.thumbnails {
|
||||
thumbnails.push(t.into());
|
||||
}
|
||||
thumbnails
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ use std::ops::Range;
|
|||
use chrono::NaiveDate;
|
||||
use serde::Deserialize;
|
||||
use serde_with::serde_as;
|
||||
use serde_with::{json::JsonString, DefaultOnError, VecSkipError};
|
||||
use serde_with::{json::JsonString, DefaultOnError};
|
||||
|
||||
use super::Thumbnails;
|
||||
use crate::serializer::{text::Text, MapResult, VecLogError};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
@ -45,11 +46,11 @@ pub struct StreamingData {
|
|||
#[serde_as(as = "JsonString")]
|
||||
pub expires_in_seconds: u32,
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub formats: Vec<Format>,
|
||||
#[serde_as(as = "VecLogError<_>")]
|
||||
pub formats: MapResult<Vec<Format>>,
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub adaptive_formats: Vec<Format>,
|
||||
#[serde_as(as = "VecLogError<_>")]
|
||||
pub adaptive_formats: MapResult<Vec<Format>>,
|
||||
/// Only on livestreams
|
||||
pub dash_manifest_url: Option<String>,
|
||||
/// Only on livestreams
|
||||
|
|
@ -73,20 +74,20 @@ pub struct Format {
|
|||
pub width: Option<u32>,
|
||||
pub height: Option<u32>,
|
||||
|
||||
#[serde_as(as = "Option<crate::serializer::range::Range>")]
|
||||
#[serde_as(as = "Option<crate::serializer::Range>")]
|
||||
pub index_range: Option<Range<u32>>,
|
||||
#[serde_as(as = "Option<crate::serializer::range::Range>")]
|
||||
#[serde_as(as = "Option<crate::serializer::Range>")]
|
||||
pub init_range: Option<Range<u32>>,
|
||||
|
||||
#[serde_as(as = "JsonString")]
|
||||
pub content_length: u64,
|
||||
#[serde_as(as = "Option<JsonString>")]
|
||||
pub content_length: Option<u64>,
|
||||
|
||||
#[serde(default)]
|
||||
#[serde_as(deserialize_as = "DefaultOnError")]
|
||||
pub quality: Option<Quality>,
|
||||
pub fps: Option<u8>,
|
||||
pub quality_label: Option<String>,
|
||||
pub average_bitrate: u32,
|
||||
pub average_bitrate: Option<u32>,
|
||||
pub color_info: Option<ColorInfo>,
|
||||
|
||||
// Audio only
|
||||
|
|
@ -104,7 +105,9 @@ pub struct Format {
|
|||
|
||||
impl Format {
|
||||
pub fn is_audio(&self) -> bool {
|
||||
self.audio_quality.is_some() && self.audio_sample_rate.is_some()
|
||||
self.content_length.is_some()
|
||||
&& self.audio_quality.is_some()
|
||||
&& self.audio_sample_rate.is_some()
|
||||
}
|
||||
|
||||
pub fn is_video(&self) -> bool {
|
||||
|
|
@ -188,7 +191,7 @@ pub struct PlayerCaptionsTracklistRenderer {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CaptionTrack {
|
||||
pub base_url: String,
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub name: String,
|
||||
pub language_code: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ use serde::Deserialize;
|
|||
use serde_with::serde_as;
|
||||
use serde_with::{json::JsonString, DefaultOnError, VecSkipError};
|
||||
|
||||
use crate::serializer::text::TextLink;
|
||||
use crate::serializer::text::{Text, TextLink};
|
||||
use crate::serializer::{MapResult, VecLogError};
|
||||
|
||||
use super::{ContentRenderer, ContentsRenderer, Thumbnails, ThumbnailsWrap, VideoListItem};
|
||||
|
||||
|
|
@ -56,8 +57,8 @@ pub struct PlaylistVideoListRenderer {
|
|||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PlaylistVideoList {
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub contents: Vec<VideoListItem<PlaylistVideo>>,
|
||||
#[serde_as(as = "VecLogError<_>")]
|
||||
pub contents: MapResult<Vec<VideoListItem<PlaylistVideo>>>,
|
||||
}
|
||||
|
||||
#[serde_as]
|
||||
|
|
@ -66,10 +67,10 @@ pub struct PlaylistVideoList {
|
|||
pub struct PlaylistVideo {
|
||||
pub video_id: String,
|
||||
pub thumbnail: Thumbnails,
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub title: String,
|
||||
#[serde(rename = "shortBylineText")]
|
||||
#[serde_as(as = "crate::serializer::text::TextLink")]
|
||||
#[serde_as(as = "TextLink")]
|
||||
pub channel: TextLink,
|
||||
#[serde_as(as = "JsonString")]
|
||||
pub length_seconds: u32,
|
||||
|
|
@ -86,14 +87,14 @@ pub struct Header {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct HeaderRenderer {
|
||||
pub playlist_id: String,
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub title: String,
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "DefaultOnError<Option<crate::serializer::text::Text>>")]
|
||||
#[serde_as(as = "DefaultOnError<Option<Text>>")]
|
||||
pub description_text: Option<String>,
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub num_videos_text: String,
|
||||
#[serde_as(as = "Option<crate::serializer::text::TextLink>")]
|
||||
#[serde_as(as = "Option<TextLink>")]
|
||||
pub owner_text: Option<TextLink>,
|
||||
|
||||
// Alternative layout
|
||||
|
|
@ -118,7 +119,7 @@ pub struct Byline {
|
|||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BylineRenderer {
|
||||
#[serde_as(as = "crate::serializer::text::Text")]
|
||||
#[serde_as(as = "Text")]
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +151,7 @@ pub struct SidebarPrimaryInfoRenderer {
|
|||
// - `"495", " videos"`
|
||||
// - `"3,310,996 views"`
|
||||
// - `"Last updated on ", "Aug 7, 2022"`
|
||||
#[serde_as(as = "Vec<crate::serializer::text::Text>")]
|
||||
#[serde_as(as = "Vec<Text>")]
|
||||
pub stats: Vec<String>,
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +173,7 @@ pub struct OnResponseReceivedAction {
|
|||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppendAction {
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub continuation_items: Vec<VideoListItem<PlaylistVideo>>,
|
||||
#[serde_as(as = "VecLogError<_>")]
|
||||
pub continuation_items: MapResult<Vec<VideoListItem<PlaylistVideo>>>,
|
||||
pub target_id: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(clippy::enum_variant_names)]
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde_with::serde_as;
|
||||
use serde_with::{DefaultOnError, VecSkipError};
|
||||
|
|
|
|||
Reference in a new issue