diff --git a/src/client/player.rs b/src/client/player.rs index 854157e..03e03ab 100644 --- a/src/client/player.rs +++ b/src/client/player.rs @@ -3,7 +3,6 @@ use std::{ collections::{BTreeMap, HashMap}, }; -use chrono::{Local, NaiveDateTime, NaiveTime, TimeZone}; use fancy_regex::Regex; use once_cell::sync::Lazy; use serde::Serialize; @@ -157,21 +156,6 @@ impl MapResponse for response::Player { self.video_details, Err(ExtractionError::InvalidData("no video details".into())) ); - let microformat = self.microformat.map(|m| m.player_microformat_renderer); - let (publish_date, category, tags, is_family_safe) = - microformat.map_or((None, None, None, None), |m| { - ( - Local - .from_local_datetime(&NaiveDateTime::new( - m.publish_date, - NaiveTime::from_hms(0, 0, 0), - )) - .single(), - Some(m.category), - m.tags, - Some(m.is_family_safe), - ) - }); if video_details.video_id != id { return Err(ExtractionError::WrongResult(format!( @@ -190,15 +174,10 @@ impl MapResponse for response::Player { id: video_details.channel_id, name: video_details.author, }, - publish_date, view_count: video_details.view_count, - keywords: match video_details.keywords { - Some(keywords) => keywords, - None => tags.unwrap_or_default(), - }, - category, + keywords: video_details.keywords, + is_live, is_live_content: video_details.is_live_content, - is_family_safe, }; let mut formats = streaming_data.formats.c; @@ -671,17 +650,6 @@ mod tests { assert_eq!(player_data.details.keywords[0], "spektrem"); assert_eq!(player_data.details.is_live_content, false); - if client_type == ClientType::Desktop || client_type == ClientType::DesktopMusic { - assert!(player_data - .details - .publish_date - .unwrap() - .to_string() - .starts_with("2013-05-05 00:00:00")); - assert_eq!(player_data.details.category.unwrap(), "Music"); - assert_eq!(player_data.details.is_family_safe.unwrap(), true); - } - if client_type == ClientType::Ios { let video = player_data .video_only_streams diff --git a/src/client/response/player.rs b/src/client/response/player.rs index ee8fce6..b363e3a 100644 --- a/src/client/response/player.rs +++ b/src/client/response/player.rs @@ -1,6 +1,5 @@ use std::ops::Range; -use chrono::NaiveDate; use serde::Deserialize; use serde_with::serde_as; use serde_with::{json::JsonString, DefaultOnError}; @@ -15,7 +14,6 @@ pub struct Player { pub streaming_data: Option, pub captions: Option, pub video_details: Option, - pub microformat: Option, } #[derive(Debug, Deserialize)] @@ -204,7 +202,8 @@ pub struct VideoDetails { pub title: String, #[serde_as(as = "JsonString")] pub length_seconds: u32, - pub keywords: Option>, + #[serde(default)] + pub keywords: Vec, pub channel_id: String, pub short_description: Option, #[serde(default)] @@ -214,22 +213,3 @@ pub struct VideoDetails { pub author: String, pub is_live_content: bool, } - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Microformat { - #[serde(alias = "microformatDataRenderer")] - pub player_microformat_renderer: PlayerMicroformatRenderer, -} - -#[serde_as] -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct PlayerMicroformatRenderer { - #[serde(alias = "familySafe")] - pub is_family_safe: bool, - pub category: String, - pub publish_date: NaiveDate, - // Only on YT Music - pub tags: Option>, -} diff --git a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_android.snap b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_android.snap index d8d2791..19447f2 100644 --- a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_android.snap +++ b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_android.snap @@ -34,7 +34,6 @@ VideoPlayer( id: "UCbxxEi-ImPlbLx5F-fHetEg", name: "RomanSenykMusic - Royalty Free Music", ), - publish_date: "~", view_count: 426567, keywords: [ "no copyright music", @@ -59,9 +58,8 @@ VideoPlayer( "motivational music", "montage music", ], - category: None, + is_live: false, is_live_content: false, - is_family_safe: None, ), video_streams: [ VideoStream( diff --git a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktop.snap b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktop.snap index 3b61a50..ffbc7f9 100644 --- a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktop.snap +++ b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktop.snap @@ -39,7 +39,6 @@ VideoPlayer( id: "UCbxxEi-ImPlbLx5F-fHetEg", name: "RomanSenykMusic - Royalty Free Music", ), - publish_date: "2019-05-30T00:00:00", view_count: 426567, keywords: [ "no copyright music", @@ -64,9 +63,8 @@ VideoPlayer( "motivational music", "montage music", ], - category: Some("Music"), + is_live: false, is_live_content: false, - is_family_safe: Some(true), ), video_streams: [ VideoStream( diff --git a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktopmusic.snap b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktopmusic.snap index 40b85cd..e16d45e 100644 --- a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktopmusic.snap +++ b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_desktopmusic.snap @@ -29,34 +29,10 @@ VideoPlayer( id: "UCbxxEi-ImPlbLx5F-fHetEg", name: "Romansenykmusic", ), - publish_date: "2019-05-30T00:00:00", view_count: 426583, - keywords: [ - "no copyright music", - "background music", - "copyright free music", - "non copyrighted music", - "free music", - "no copyright music cinematic", - "inspiring music", - "inspiring background music", - "cinematic music", - "cinematic background music", - "no copyright music inspiring", - "free music no copyright", - "uplifting music", - "trailer music no copyright", - "trailer music", - "download music", - "free background music", - "orchestral music", - "romansenykmusic", - "motivational music", - "montage music", - ], - category: Some("Music"), + keywords: [], + is_live: false, is_live_content: false, - is_family_safe: Some(true), ), video_streams: [ VideoStream( diff --git a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_ios.snap b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_ios.snap index 08522a5..78bc07b 100644 --- a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_ios.snap +++ b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_ios.snap @@ -29,7 +29,6 @@ VideoPlayer( id: "UCbxxEi-ImPlbLx5F-fHetEg", name: "RomanSenykMusic - Royalty Free Music", ), - publish_date: "~", view_count: 426567, keywords: [ "no copyright music", @@ -54,9 +53,8 @@ VideoPlayer( "motivational music", "montage music", ], - category: None, + is_live: false, is_live_content: false, - is_family_safe: None, ), video_streams: [], video_only_streams: [ diff --git a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_tvhtml5embed.snap b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_tvhtml5embed.snap index 90971d4..e5184a2 100644 --- a/src/client/snapshots/rustypipe__client__player__tests__map_player_data_tvhtml5embed.snap +++ b/src/client/snapshots/rustypipe__client__player__tests__map_player_data_tvhtml5embed.snap @@ -39,7 +39,6 @@ VideoPlayer( id: "UCbxxEi-ImPlbLx5F-fHetEg", name: "RomanSenykMusic - Royalty Free Music", ), - publish_date: "~", view_count: 426567, keywords: [ "no copyright music", @@ -64,9 +63,8 @@ VideoPlayer( "motivational music", "montage music", ], - category: None, + is_live: false, is_live_content: false, - is_family_safe: None, ), video_streams: [ VideoStream( diff --git a/src/model/mod.rs b/src/model/mod.rs index 47a0de5..4d9a7be 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -71,17 +71,14 @@ pub struct VideoPlayerDetails { pub thumbnail: Vec, /// Channel of the video pub channel: ChannelId, - /// Video publishing date. Start date in case of a livestream. - pub publish_date: Option>, /// Number of views / current viewers in case of a livestream. pub view_count: u64, /// List of words that describe the topic of the video pub keywords: Vec, - pub category: Option, + /// True if the video is an active livestream + pub is_live: bool, /// True if the video is/was livestreamed pub is_live_content: bool, - /// True if the video is not age-restricted - pub is_family_safe: Option, } /// Video stream diff --git a/testfiles/player_model/hdr.json b/testfiles/player_model/hdr.json index 1efbc21..3eb900d 100644 --- a/testfiles/player_model/hdr.json +++ b/testfiles/player_model/hdr.json @@ -32,7 +32,6 @@ } ], "channel": { "id": "UCYq-iAOSZBvoUxvfzwKIZWA", "name": "Jacob + Katie Schwarz" }, - "publish_date": "2018-06-12T00:00:00Z", "view_count": 216221243, "keywords": [ "4K", @@ -55,9 +54,8 @@ "ultra HD video", "red digital cinema" ], - "category": "Film & Animation", - "is_live_content": false, - "is_family_safe": true + "is_live": false, + "is_live_content": false }, "video_streams": [ { @@ -1124,5 +1122,7 @@ } ], "subtitles": [], - "expires_in_seconds": 21540 + "expires_in_seconds": 21540, + "hls_manifest_url": null, + "dash_manifest_url": null } diff --git a/testfiles/player_model/multilanguage.json b/testfiles/player_model/multilanguage.json index 13e1715..03ea80b 100644 --- a/testfiles/player_model/multilanguage.json +++ b/testfiles/player_model/multilanguage.json @@ -35,9 +35,8 @@ "publish_date": "2022-07-23T00:00:00Z", "view_count": 71877575, "keywords": [], - "category": "Entertainment", - "is_live_content": false, - "is_family_safe": true + "is_live": false, + "is_live_content": false }, "video_streams": [ { @@ -1069,5 +1068,7 @@ "auto_generated": false } ], - "expires_in_seconds": 21540 + "expires_in_seconds": 21540, + "hls_manifest_url": null, + "dash_manifest_url": null }