diff --git a/src/client/mod.rs b/src/client/mod.rs index e762253..d5f9f3e 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -269,7 +269,7 @@ impl CacheEntry { impl From for CacheEntry { fn from(f: T) -> Self { Self::Some { - last_update: util::now_sec(), + last_update: OffsetDateTime::now_utc(), data: f, } } diff --git a/src/client/pagination.rs b/src/client/pagination.rs index 818d3af..94b5396 100644 --- a/src/client/pagination.rs +++ b/src/client/pagination.rs @@ -53,20 +53,14 @@ impl> MapResponse> for response::Continuati lang: crate::param::Language, _deobf: Option<&crate::deobfuscate::Deobfuscator>, ) -> Result>, ExtractionError> { - let items = self - .on_response_received_actions - .and_then(|mut actions| { - actions - .try_swap_remove(0) - .map(|action| action.append_continuation_items_action.continuation_items) - }) - .or_else(|| { - self.continuation_contents - .map(|contents| contents.rich_grid_continuation.contents) - }) + let mut actions = self.on_response_received_actions; + let items = actions + .try_swap_remove(0) .ok_or(ExtractionError::InvalidData(Cow::Borrowed( - "no continuation items", - )))?; + "no item section renderer", + )))? + .append_continuation_items_action + .continuation_items; let mut mapper = response::YouTubeListMapper::::new(lang); mapper.map_response(items); diff --git a/src/client/response/mod.rs b/src/client/response/mod.rs index b0452d7..644b998 100644 --- a/src/client/response/mod.rs +++ b/src/client/response/mod.rs @@ -140,12 +140,6 @@ pub(crate) struct AlertRenderer { pub text: String, } -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct ResponseContext { - pub visitor_data: Option, -} - // CONTINUATION #[serde_as] @@ -159,12 +153,8 @@ pub(crate) struct Continuation { alias = "onResponseReceivedCommands", alias = "onResponseReceivedEndpoints" )] - #[serde_as(as = "Option>")] - pub on_response_received_actions: Option>, - /// Used for channel video rich grid renderer - /// - /// A/B test seen on 19.10.2022 - pub continuation_contents: Option, + #[serde_as(as = "VecSkipError<_>")] + pub on_response_received_actions: Vec, } #[derive(Debug, Deserialize)] @@ -183,16 +173,8 @@ pub(crate) struct ContinuationAction { #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub(crate) struct RichGridContinuationContents { - pub rich_grid_continuation: RichGridContinuation, -} - -#[serde_as] -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct RichGridContinuation { - #[serde_as(as = "VecLogError<_>")] - pub contents: MapResult>, +pub(crate) struct ResponseContext { + pub visitor_data: Option, } // YouTube Music diff --git a/src/client/response/video_details.rs b/src/client/response/video_details.rs index 77871e2..19a0cce 100644 --- a/src/client/response/video_details.rs +++ b/src/client/response/video_details.rs @@ -66,8 +66,8 @@ pub(crate) struct VideoResultsWrap { #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct VideoResults { - #[serde_as(as = "Option>")] - pub contents: Option>>, + #[serde_as(as = "VecLogError<_>")] + pub contents: MapResult>, } /// Video metadata item diff --git a/src/client/video_details.rs b/src/client/video_details.rs index 714875e..132af0f 100644 --- a/src/client/video_details.rs +++ b/src/client/video_details.rs @@ -102,10 +102,7 @@ impl MapResponse for response::VideoDetails { .two_column_watch_next_results .results .results - .contents - .ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed( - "Video not found", - )))?; + .contents; warnings.append(&mut primary_results.warnings); let mut primary_info = None; diff --git a/src/report.rs b/src/report.rs index 3497cee..979d13b 100644 --- a/src/report.rs +++ b/src/report.rs @@ -11,8 +11,8 @@ use serde::{Deserialize, Serialize}; use time::macros::format_description; use time::OffsetDateTime; +use crate::deobfuscate::DeobfData; use crate::error::Error; -use crate::{deobfuscate::DeobfData, util}; const FILENAME_FORMAT: &[time::format_description::FormatItem] = format_description!("[year]-[month]-[day]_[hour]-[minute]-[second]"); @@ -81,7 +81,7 @@ impl Default for Info { Self { package: "rustypipe".to_owned(), version: "0.1.0".to_owned(), - date: util::now_sec(), + date: OffsetDateTime::now_utc(), } } } diff --git a/src/timeago.rs b/src/timeago.rs index 53b0090..8ae4bec 100644 --- a/src/timeago.rs +++ b/src/timeago.rs @@ -84,7 +84,7 @@ impl Mul for TimeAgo { impl From for OffsetDateTime { fn from(ta: TimeAgo) -> Self { - let ts = util::now_sec(); + let ts = OffsetDateTime::now_utc(); match ta.unit { TimeUnit::Second => ts - Duration::seconds(ta.n as i64), TimeUnit::Minute => ts - Duration::minutes(ta.n as i64), diff --git a/src/util/date.rs b/src/util/date.rs index 742a9c6..a161565 100644 --- a/src/util/date.rs +++ b/src/util/date.rs @@ -1,4 +1,4 @@ -use time::{Date, Month, OffsetDateTime}; +use time::{Date, Month}; pub const fn month_from_n(n: u8) -> Option { match n { @@ -42,14 +42,3 @@ pub fn shift_months(date: Date, months: i32) -> Date { pub fn shift_years(date: Date, years: i32) -> Date { shift_months(date, years * 12) } - -/// Get the current datetime without milli/micro/nanoseconds -pub fn now_sec() -> OffsetDateTime { - OffsetDateTime::now_utc() - .replace_millisecond(0) - .unwrap() - .replace_microsecond(0) - .unwrap() - .replace_nanosecond(0) - .unwrap() -} diff --git a/src/util/mod.rs b/src/util/mod.rs index 02a746f..9c6ab8f 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -3,7 +3,7 @@ mod protobuf; pub mod dictionary; -pub use date::{month_from_n, now_sec, shift_months, shift_years}; +pub use date::{month_from_n, shift_months, shift_years}; pub use protobuf::ProtoBuilder; use std::{