Compare commits
No commits in common. "8026b08e2d28d79ac1336655efdeab5c99cfb445" and "4ebee5856e10137da736c5fe84b37fcce647e2ff" have entirely different histories.
8026b08e2d
...
4ebee5856e
48 changed files with 95 additions and 27829 deletions
|
@ -22,8 +22,6 @@ pub async fn download_testfiles(project_root: &Path) {
|
|||
comments_latest(&testfiles).await;
|
||||
recommendations(&testfiles).await;
|
||||
channel_videos(&testfiles).await;
|
||||
channel_shorts(&testfiles).await;
|
||||
channel_livestreams(&testfiles).await;
|
||||
channel_playlists(&testfiles).await;
|
||||
channel_info(&testfiles).await;
|
||||
channel_videos_cont(&testfiles).await;
|
||||
|
@ -260,36 +258,6 @@ async fn channel_videos(testfiles: &Path) {
|
|||
}
|
||||
}
|
||||
|
||||
async fn channel_shorts(testfiles: &Path) {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("channel");
|
||||
json_path.push("channel_shorts.json");
|
||||
if json_path.exists() {
|
||||
return;
|
||||
}
|
||||
|
||||
let rp = rp_testfile(&json_path);
|
||||
rp.query()
|
||||
.channel_shorts("UCh8gHdtzO2tXd593_bjErWg")
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
async fn channel_livestreams(testfiles: &Path) {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("channel");
|
||||
json_path.push("channel_livestreams.json");
|
||||
if json_path.exists() {
|
||||
return;
|
||||
}
|
||||
|
||||
let rp = rp_testfile(&json_path);
|
||||
rp.query()
|
||||
.channel_livestreams("UC2DjFE7Xf11URZqWBigcVOQ")
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
async fn channel_playlists(testfiles: &Path) {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("channel");
|
||||
|
|
|
@ -13,10 +13,7 @@ use crate::{
|
|||
util::{self, TryRemove},
|
||||
};
|
||||
|
||||
use super::{
|
||||
response::{self, channel::ChannelContent},
|
||||
ClientType, MapResponse, RustyPipeQuery, YTContext,
|
||||
};
|
||||
use super::{response, ClientType, MapResponse, RustyPipeQuery, YTContext};
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -30,10 +27,6 @@ struct QChannel<'a> {
|
|||
enum Params {
|
||||
#[serde(rename = "EgZ2aWRlb3PyBgQKAjoA")]
|
||||
Videos,
|
||||
#[serde(rename = "EgZzaG9ydHPyBgUKA5oBAA%3D%3D")]
|
||||
Shorts,
|
||||
#[serde(rename = "EgdzdHJlYW1z8gYECgJ6AA%3D%3D")]
|
||||
Live,
|
||||
#[serde(rename = "EglwbGF5bGlzdHMgAQ%3D%3D")]
|
||||
Playlists,
|
||||
#[serde(rename = "EgVhYm91dPIGBAoCEgA%3D")]
|
||||
|
@ -41,22 +34,20 @@ enum Params {
|
|||
}
|
||||
|
||||
impl RustyPipeQuery {
|
||||
async fn _channel_videos(
|
||||
pub async fn channel_videos(
|
||||
&self,
|
||||
channel_id: &str,
|
||||
params: Params,
|
||||
operation: &str,
|
||||
) -> Result<Channel<Paginator<VideoItem>>, Error> {
|
||||
let context = self.get_context(ClientType::Desktop, true, None).await;
|
||||
let request_body = QChannel {
|
||||
context,
|
||||
browse_id: channel_id,
|
||||
params,
|
||||
params: Params::Videos,
|
||||
};
|
||||
|
||||
self.execute_request::<response::Channel, _, _>(
|
||||
ClientType::Desktop,
|
||||
operation,
|
||||
"channel_videos",
|
||||
channel_id,
|
||||
"browse",
|
||||
&request_body,
|
||||
|
@ -64,30 +55,6 @@ impl RustyPipeQuery {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn channel_videos(
|
||||
&self,
|
||||
channel_id: &str,
|
||||
) -> Result<Channel<Paginator<VideoItem>>, Error> {
|
||||
self._channel_videos(channel_id, Params::Videos, "channel_videos")
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn channel_shorts(
|
||||
&self,
|
||||
channel_id: &str,
|
||||
) -> Result<Channel<Paginator<VideoItem>>, Error> {
|
||||
self._channel_videos(channel_id, Params::Shorts, "channel_shorts")
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn channel_livestreams(
|
||||
&self,
|
||||
channel_id: &str,
|
||||
) -> Result<Channel<Paginator<VideoItem>>, Error> {
|
||||
self._channel_videos(channel_id, Params::Live, "channel_livestreams")
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn channel_playlists(
|
||||
&self,
|
||||
channel_id: &str,
|
||||
|
@ -135,8 +102,8 @@ impl MapResponse<Channel<Paginator<VideoItem>>> for response::Channel {
|
|||
lang: Language,
|
||||
_deobf: Option<&crate::deobfuscate::Deobfuscator>,
|
||||
) -> Result<MapResult<Channel<Paginator<VideoItem>>>, ExtractionError> {
|
||||
let content = map_channel_content(self.contents, self.alerts)?;
|
||||
let grid = match content.content {
|
||||
let content = map_channel_content(self.contents, id, self.alerts)?;
|
||||
let grid = match content {
|
||||
response::channel::ChannelContent::GridRenderer { items } => Some(items),
|
||||
_ => None,
|
||||
};
|
||||
|
@ -145,15 +112,10 @@ impl MapResponse<Channel<Paginator<VideoItem>>> for response::Channel {
|
|||
|
||||
Ok(MapResult {
|
||||
c: map_channel(
|
||||
MapChannelData {
|
||||
header: self.header,
|
||||
metadata: self.metadata,
|
||||
microformat: self.microformat,
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
has_shorts: content.has_shorts,
|
||||
has_live: content.has_live,
|
||||
content: v_res.c,
|
||||
},
|
||||
self.header,
|
||||
self.metadata,
|
||||
self.microformat,
|
||||
v_res.c,
|
||||
id,
|
||||
lang,
|
||||
)?,
|
||||
|
@ -169,8 +131,8 @@ impl MapResponse<Channel<Paginator<PlaylistItem>>> for response::Channel {
|
|||
lang: Language,
|
||||
_deobf: Option<&crate::deobfuscate::Deobfuscator>,
|
||||
) -> Result<MapResult<Channel<Paginator<PlaylistItem>>>, ExtractionError> {
|
||||
let content = map_channel_content(self.contents, self.alerts)?;
|
||||
let grid = match content.content {
|
||||
let content = map_channel_content(self.contents, id, self.alerts)?;
|
||||
let grid = match content {
|
||||
response::channel::ChannelContent::GridRenderer { items } => Some(items),
|
||||
_ => None,
|
||||
};
|
||||
|
@ -181,15 +143,10 @@ impl MapResponse<Channel<Paginator<PlaylistItem>>> for response::Channel {
|
|||
|
||||
Ok(MapResult {
|
||||
c: map_channel(
|
||||
MapChannelData {
|
||||
header: self.header,
|
||||
metadata: self.metadata,
|
||||
microformat: self.microformat,
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
has_shorts: content.has_shorts,
|
||||
has_live: content.has_live,
|
||||
content: p_res.c,
|
||||
},
|
||||
self.header,
|
||||
self.metadata,
|
||||
self.microformat,
|
||||
p_res.c,
|
||||
id,
|
||||
lang,
|
||||
)?,
|
||||
|
@ -205,9 +162,9 @@ impl MapResponse<Channel<ChannelInfo>> for response::Channel {
|
|||
lang: Language,
|
||||
_deobf: Option<&crate::deobfuscate::Deobfuscator>,
|
||||
) -> Result<MapResult<Channel<ChannelInfo>>, ExtractionError> {
|
||||
let content = map_channel_content(self.contents, self.alerts)?;
|
||||
let content = map_channel_content(self.contents, id, self.alerts)?;
|
||||
let mut warnings = Vec::new();
|
||||
let meta = match content.content {
|
||||
let meta = match content {
|
||||
response::channel::ChannelContent::ChannelAboutFullMetadataRenderer(meta) => Some(meta),
|
||||
_ => None,
|
||||
};
|
||||
|
@ -244,15 +201,10 @@ impl MapResponse<Channel<ChannelInfo>> for response::Channel {
|
|||
|
||||
Ok(MapResult {
|
||||
c: map_channel(
|
||||
MapChannelData {
|
||||
header: self.header,
|
||||
metadata: self.metadata,
|
||||
microformat: self.microformat,
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
has_shorts: content.has_shorts,
|
||||
has_live: content.has_live,
|
||||
content: cinfo,
|
||||
},
|
||||
self.header,
|
||||
self.metadata,
|
||||
self.microformat,
|
||||
cinfo,
|
||||
id,
|
||||
lang,
|
||||
)?,
|
||||
|
@ -299,37 +251,25 @@ fn map_vanity_url(url: &str, id: &str) -> Option<String> {
|
|||
})
|
||||
}
|
||||
|
||||
struct MapChannelData<T> {
|
||||
fn map_channel<T>(
|
||||
header: Option<response::channel::Header>,
|
||||
metadata: Option<response::channel::Metadata>,
|
||||
microformat: Option<response::channel::Microformat>,
|
||||
visitor_data: Option<String>,
|
||||
has_shorts: bool,
|
||||
has_live: bool,
|
||||
content: T,
|
||||
}
|
||||
|
||||
fn map_channel<T>(
|
||||
d: MapChannelData<T>,
|
||||
id: &str,
|
||||
lang: Language,
|
||||
) -> Result<Channel<T>, ExtractionError> {
|
||||
let header = d
|
||||
.header
|
||||
.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
|
||||
"channel not found",
|
||||
)))?;
|
||||
let metadata = d
|
||||
.metadata
|
||||
let header = header.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
|
||||
"channel not found",
|
||||
)))?;
|
||||
let metadata = metadata
|
||||
.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
|
||||
"channel not found",
|
||||
)))?
|
||||
.channel_metadata_renderer;
|
||||
let microformat = d
|
||||
.microformat
|
||||
.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
|
||||
"channel not found",
|
||||
)))?;
|
||||
let microformat = microformat.ok_or(ExtractionError::ContentUnavailable(Cow::Borrowed(
|
||||
"channel not found",
|
||||
)))?;
|
||||
|
||||
if metadata.external_id != id {
|
||||
return Err(ExtractionError::WrongResult(format!(
|
||||
|
@ -358,10 +298,7 @@ fn map_channel<T>(
|
|||
banner: header.banner.into(),
|
||||
mobile_banner: header.mobile_banner.into(),
|
||||
tv_banner: header.tv_banner.into(),
|
||||
has_shorts: d.has_shorts,
|
||||
has_live: d.has_live,
|
||||
visitor_data: d.visitor_data,
|
||||
content: d.content,
|
||||
content,
|
||||
},
|
||||
response::channel::Header::CarouselHeaderRenderer(carousel) => {
|
||||
let hdata = carousel
|
||||
|
@ -395,25 +332,17 @@ fn map_channel<T>(
|
|||
banner: Vec::new(),
|
||||
mobile_banner: Vec::new(),
|
||||
tv_banner: Vec::new(),
|
||||
has_shorts: d.has_shorts,
|
||||
has_live: d.has_live,
|
||||
visitor_data: d.visitor_data,
|
||||
content: d.content,
|
||||
content,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
struct MappedChannelContent {
|
||||
content: response::channel::ChannelContent,
|
||||
has_shorts: bool,
|
||||
has_live: bool,
|
||||
}
|
||||
|
||||
fn map_channel_content(
|
||||
contents: Option<response::channel::Contents>,
|
||||
id: &str,
|
||||
alerts: Option<Vec<response::Alert>>,
|
||||
) -> Result<MappedChannelContent, ExtractionError> {
|
||||
) -> Result<response::channel::ChannelContent, ExtractionError> {
|
||||
match contents {
|
||||
Some(contents) => {
|
||||
let tabs = contents.two_column_browse_results_renderer.tabs;
|
||||
|
@ -423,70 +352,42 @@ fn map_channel_content(
|
|||
));
|
||||
}
|
||||
|
||||
let cmp_url_suffix = |endpoint: &response::channel::ChannelTabEndpoint,
|
||||
expect: &str| {
|
||||
endpoint
|
||||
.command_metadata
|
||||
.web_command_metadata
|
||||
.url
|
||||
.ends_with(expect)
|
||||
};
|
||||
|
||||
let mut has_shorts = false;
|
||||
let mut has_live = false;
|
||||
let mut featured_tab = false;
|
||||
|
||||
for tab in &tabs {
|
||||
if cmp_url_suffix(&tab.tab_renderer.endpoint, "/featured")
|
||||
&& (tab.tab_renderer.content.section_list_renderer.is_some()
|
||||
|| tab.tab_renderer.content.rich_grid_renderer.is_some())
|
||||
{
|
||||
featured_tab = true;
|
||||
} else if cmp_url_suffix(&tab.tab_renderer.endpoint, "/shorts") {
|
||||
has_shorts = true;
|
||||
} else if cmp_url_suffix(&tab.tab_renderer.endpoint, "/streams") {
|
||||
has_live = true;
|
||||
}
|
||||
}
|
||||
|
||||
let channel_content = tabs
|
||||
let (channel_content, target_id) = tabs
|
||||
.into_iter()
|
||||
.filter_map(|tab| {
|
||||
let content = tab.tab_renderer.content;
|
||||
match (content.rich_grid_renderer, content.section_list_renderer) {
|
||||
(Some(rich_grid), _) => Some(ChannelContent::GridRenderer {
|
||||
items: rich_grid.contents,
|
||||
}),
|
||||
(None, Some(section_list)) => {
|
||||
let mut contents = section_list.contents;
|
||||
contents.try_swap_remove(0).and_then(|mut i| {
|
||||
i.item_section_renderer.contents.try_swap_remove(0)
|
||||
})
|
||||
match (content.section_list_renderer, content.rich_grid_renderer) {
|
||||
(Some(mut section_list_renderer), _) => {
|
||||
let content =
|
||||
section_list_renderer.contents.try_swap_remove(0).and_then(
|
||||
|mut i| i.item_section_renderer.contents.try_swap_remove(0),
|
||||
);
|
||||
|
||||
content.map(|c| (c, section_list_renderer.target_id))
|
||||
}
|
||||
(None, Some(rich_grid_renderer)) => Some((
|
||||
response::channel::ChannelContent::GridRenderer {
|
||||
items: rich_grid_renderer.contents,
|
||||
},
|
||||
rich_grid_renderer.target_id,
|
||||
)),
|
||||
(None, None) => None,
|
||||
}
|
||||
})
|
||||
.next();
|
||||
.next()
|
||||
.ok_or(ExtractionError::InvalidData(Cow::Borrowed(
|
||||
"could not extract content",
|
||||
)))?;
|
||||
|
||||
let content = match channel_content {
|
||||
Some(content) => content,
|
||||
None => {
|
||||
// YouTube may show the "Featured" tab if the requested tab is empty/does not exist
|
||||
if featured_tab {
|
||||
response::channel::ChannelContent::None
|
||||
} else {
|
||||
return Err(ExtractionError::InvalidData(Cow::Borrowed(
|
||||
"could not extract content",
|
||||
)));
|
||||
}
|
||||
if let Some(target_id) = target_id {
|
||||
// YouTube falls back to the featured page if the channel does not have a "videos" tab.
|
||||
// This is the case for YouTube Music channels.
|
||||
if target_id.starts_with(&format!("browse-feed{}featured", id)) {
|
||||
return Ok(response::channel::ChannelContent::None);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Ok(MappedChannelContent {
|
||||
content,
|
||||
has_shorts,
|
||||
has_live,
|
||||
})
|
||||
Ok(channel_content)
|
||||
}
|
||||
None => Err(response::alerts_to_err(alerts)),
|
||||
}
|
||||
|
@ -506,18 +407,16 @@ mod tests {
|
|||
};
|
||||
|
||||
#[rstest]
|
||||
#[case::base("videos_base", "UC2DjFE7Xf11URZqWBigcVOQ")]
|
||||
#[case::music("videos_music", "UC_vmjW5e1xEHhYjY2a0kK1A")]
|
||||
#[case::withshorts("videos_shorts", "UCh8gHdtzO2tXd593_bjErWg")]
|
||||
#[case::live("videos_live", "UChs0pSaEoNLV4mevBFGaoKA")]
|
||||
#[case::empty("videos_empty", "UCxBa895m48H5idw5li7h-0g")]
|
||||
#[case::upcoming("videos_upcoming", "UCcvfHa-GHSOHFAjU0-Ie57A")]
|
||||
#[case::richgrid("videos_20221011_richgrid", "UCh8gHdtzO2tXd593_bjErWg")]
|
||||
#[case::richgrid2("videos_20221011_richgrid2", "UC2DjFE7Xf11URZqWBigcVOQ")]
|
||||
#[case::base("base", "UC2DjFE7Xf11URZqWBigcVOQ")]
|
||||
#[case::music("music", "UC_vmjW5e1xEHhYjY2a0kK1A")]
|
||||
#[case::shorts("shorts", "UCh8gHdtzO2tXd593_bjErWg")]
|
||||
#[case::livestreams("livestreams", "UC2DjFE7Xf11URZqWBigcVOQ")]
|
||||
#[case::live("live", "UChs0pSaEoNLV4mevBFGaoKA")]
|
||||
#[case::empty("empty", "UCxBa895m48H5idw5li7h-0g")]
|
||||
#[case::upcoming("upcoming", "UCcvfHa-GHSOHFAjU0-Ie57A")]
|
||||
#[case::richgrid("20221011_richgrid", "UCh8gHdtzO2tXd593_bjErWg")]
|
||||
#[case::richgrid2("20221011_richgrid2", "UC2DjFE7Xf11URZqWBigcVOQ")]
|
||||
fn map_channel_videos(#[case] name: &str, #[case] id: &str) {
|
||||
let filename = format!("testfiles/channel/channel_{}.json", name);
|
||||
let filename = format!("testfiles/channel/channel_videos_{}.json", name);
|
||||
let json_path = Path::new(&filename);
|
||||
let json_file = File::open(json_path).unwrap();
|
||||
|
||||
|
@ -532,12 +431,12 @@ mod tests {
|
|||
map_res.warnings
|
||||
);
|
||||
|
||||
if name == "videos_upcoming" {
|
||||
insta::assert_ron_snapshot!(format!("map_channel_{}", name), map_res.c, {
|
||||
if name == "upcoming" {
|
||||
insta::assert_ron_snapshot!(format!("map_channel_videos_{}", name), map_res.c, {
|
||||
".content.items[1:].publish_date" => "[date]",
|
||||
});
|
||||
} else {
|
||||
insta::assert_ron_snapshot!(format!("map_channel_{}", name), map_res.c, {
|
||||
insta::assert_ron_snapshot!(format!("map_channel_videos_{}", name), map_res.c, {
|
||||
".content.items[].publish_date" => "[date]",
|
||||
});
|
||||
}
|
||||
|
|
|
@ -275,7 +275,6 @@ impl MapResponse<VideoPlayer> for response::Player {
|
|||
expires_in_seconds: streaming_data.expires_in_seconds,
|
||||
hls_manifest_url: streaming_data.hls_manifest_url,
|
||||
dash_manifest_url: streaming_data.dash_manifest_url,
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
},
|
||||
warnings,
|
||||
})
|
||||
|
|
|
@ -169,7 +169,6 @@ impl MapResponse<Playlist> for response::Playlist {
|
|||
channel,
|
||||
last_update,
|
||||
last_update_txt,
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
},
|
||||
warnings,
|
||||
})
|
||||
|
|
|
@ -3,7 +3,9 @@ use serde_with::serde_as;
|
|||
use serde_with::{DefaultOnError, VecSkipError};
|
||||
|
||||
use super::url_endpoint::NavigationEndpoint;
|
||||
use super::{Alert, ChannelBadge, ContentsRenderer, ResponseContext, Thumbnails, YouTubeListItem};
|
||||
use super::{Alert, ChannelBadge};
|
||||
use super::{ContentRenderer, ContentsRenderer};
|
||||
use super::{Thumbnails, YouTubeListItem};
|
||||
use crate::serializer::ignore_any;
|
||||
use crate::serializer::{text::Text, MapResult, VecLogError};
|
||||
|
||||
|
@ -19,7 +21,6 @@ pub(crate) struct Channel {
|
|||
pub microformat: Option<Microformat>,
|
||||
#[serde_as(as = "Option<DefaultOnError>")]
|
||||
pub alerts: Option<Vec<Alert>>,
|
||||
pub response_context: ResponseContext,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -41,19 +42,11 @@ pub(crate) struct TabsRenderer {
|
|||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct TabRendererWrap {
|
||||
pub tab_renderer: TabRenderer,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct TabRenderer {
|
||||
#[serde(default)]
|
||||
pub content: TabContent,
|
||||
pub endpoint: ChannelTabEndpoint,
|
||||
pub tab_renderer: ContentRenderer<TabContent>,
|
||||
}
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Default, Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct TabContent {
|
||||
#[serde(default)]
|
||||
|
@ -65,28 +58,14 @@ pub(crate) struct TabContent {
|
|||
pub rich_grid_renderer: Option<RichGridRenderer>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct ChannelTabEndpoint {
|
||||
pub command_metadata: ChannelTabCommandMetadata,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct ChannelTabCommandMetadata {
|
||||
pub web_command_metadata: ChannelTabWebCommandMetadata,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct ChannelTabWebCommandMetadata {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct SectionListRenderer {
|
||||
pub contents: Vec<ItemSectionRendererWrap>,
|
||||
/// - **Videos**: browse-feedUC2DjFE7Xf11URZqWBigcVOQvideos (...)
|
||||
/// - **Playlists**: browse-feedUC2DjFE7Xf11URZqWBigcVOQplaylists104 (...)
|
||||
/// - **Info**: None
|
||||
pub target_id: Option<String>,
|
||||
}
|
||||
|
||||
/// Seems to be currently A/B tested, as of 11.10.2022
|
||||
|
@ -96,6 +75,10 @@ pub(crate) struct SectionListRenderer {
|
|||
pub(crate) struct RichGridRenderer {
|
||||
#[serde_as(as = "VecLogError<_>")]
|
||||
pub contents: MapResult<Vec<YouTubeListItem>>,
|
||||
/// - **Videos**: browse-feedUC2DjFE7Xf11URZqWBigcVOQvideos (...)
|
||||
/// - **Playlists**: browse-feedUC2DjFE7Xf11URZqWBigcVOQplaylists104 (...)
|
||||
/// - **Info**: None
|
||||
pub target_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
|
@ -4,7 +4,7 @@ use serde::Deserialize;
|
|||
use serde_with::serde_as;
|
||||
use serde_with::{json::JsonString, DefaultOnError};
|
||||
|
||||
use super::{ResponseContext, Thumbnails};
|
||||
use super::Thumbnails;
|
||||
use crate::serializer::{text::Text, MapResult, VecLogError};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -14,7 +14,6 @@ pub(crate) struct Player {
|
|||
pub streaming_data: Option<StreamingData>,
|
||||
pub captions: Option<Captions>,
|
||||
pub video_details: Option<VideoDetails>,
|
||||
pub response_context: ResponseContext,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
|
@ -6,8 +6,7 @@ use crate::serializer::{ignore_any, MapResult, VecLogError};
|
|||
use crate::util::MappingError;
|
||||
|
||||
use super::{
|
||||
Alert, ContentRenderer, ContentsRenderer, ContinuationEndpoint, ResponseContext, Thumbnails,
|
||||
ThumbnailsWrap,
|
||||
Alert, ContentRenderer, ContentsRenderer, ContinuationEndpoint, Thumbnails, ThumbnailsWrap,
|
||||
};
|
||||
|
||||
#[serde_as]
|
||||
|
@ -19,7 +18,6 @@ pub(crate) struct Playlist {
|
|||
pub sidebar: Option<Sidebar>,
|
||||
#[serde_as(as = "Option<DefaultOnError>")]
|
||||
pub alerts: Option<Vec<Alert>>,
|
||||
pub response_context: ResponseContext,
|
||||
}
|
||||
|
||||
#[serde_as]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use serde::Deserialize;
|
||||
use serde_with::{json::JsonString, serde_as};
|
||||
|
||||
use super::{video_item::YouTubeListRendererWrap, ResponseContext};
|
||||
use super::video_item::YouTubeListRendererWrap;
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -10,7 +10,6 @@ pub(crate) struct Search {
|
|||
#[serde_as(as = "Option<JsonString>")]
|
||||
pub estimated_results: Option<u64>,
|
||||
pub contents: Contents,
|
||||
pub response_context: ResponseContext,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use fancy_regex::Regex;
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::Deserialize;
|
||||
use serde_with::{json::JsonString, serde_as, DefaultOnError, VecSkipError};
|
||||
use time::{Duration, OffsetDateTime};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use super::{ChannelBadge, ContinuationEndpoint, Thumbnails};
|
||||
use crate::{
|
||||
|
@ -10,7 +8,7 @@ use crate::{
|
|||
param::Language,
|
||||
serializer::{
|
||||
ignore_any,
|
||||
text::{AccessibilityText, Text, TextComponent},
|
||||
text::{Text, TextComponent},
|
||||
MapResult, VecLogError,
|
||||
},
|
||||
timeago,
|
||||
|
@ -23,7 +21,6 @@ use crate::{
|
|||
pub(crate) enum YouTubeListItem {
|
||||
#[serde(alias = "gridVideoRenderer", alias = "compactVideoRenderer")]
|
||||
VideoRenderer(VideoRenderer),
|
||||
ReelItemRenderer(ReelItemRenderer),
|
||||
|
||||
#[serde(alias = "gridPlaylistRenderer")]
|
||||
PlaylistRenderer(PlaylistRenderer),
|
||||
|
@ -101,7 +98,6 @@ pub(crate) struct VideoRenderer {
|
|||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub badges: Vec<VideoBadge>,
|
||||
/// Contains Short/Live tag
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub thumbnail_overlays: Vec<TimeOverlay>,
|
||||
/// Abbreviated video description (on startpage)
|
||||
|
@ -114,27 +110,6 @@ pub(crate) struct VideoRenderer {
|
|||
pub upcoming_event_data: Option<UpcomingEventData>,
|
||||
}
|
||||
|
||||
/// Short video item
|
||||
#[serde_as]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct ReelItemRenderer {
|
||||
pub video_id: String,
|
||||
pub thumbnail: Thumbnails,
|
||||
#[serde_as(as = "Text")]
|
||||
pub headline: String,
|
||||
/// Contains `No views` if the view count is zero
|
||||
#[serde_as(as = "Option<Text>")]
|
||||
pub view_count_text: Option<String>,
|
||||
/// video duration
|
||||
///
|
||||
/// Example: `the horror maze - 44 seconds - play video`
|
||||
///
|
||||
/// Dashes may be `\u2013` (emdash)
|
||||
#[serde_as(as = "Option<AccessibilityText>")]
|
||||
pub accessibility: Option<String>,
|
||||
}
|
||||
|
||||
/// Playlist displayed in search results
|
||||
#[serde_as]
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -388,39 +363,6 @@ impl<T> YouTubeListMapper<T> {
|
|||
}
|
||||
}
|
||||
|
||||
fn map_short_video(&self, video: ReelItemRenderer) -> VideoItem {
|
||||
static ACCESSIBILITY_SEP_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(" [-\u{2013}] (.+) [-\u{2013}] ").unwrap());
|
||||
|
||||
VideoItem {
|
||||
id: video.video_id,
|
||||
title: video.headline,
|
||||
length: video.accessibility.and_then(|acc| {
|
||||
ACCESSIBILITY_SEP_REGEX
|
||||
.captures(&acc)
|
||||
.ok()
|
||||
.flatten()
|
||||
.and_then(|cap| {
|
||||
cap.get(1).and_then(|c| {
|
||||
timeago::parse_timeago(self.lang, c.as_str())
|
||||
.map(|ta| Duration::from(ta).whole_seconds() as u32)
|
||||
})
|
||||
})
|
||||
}),
|
||||
thumbnail: video.thumbnail.into(),
|
||||
channel: None,
|
||||
publish_date: None,
|
||||
publish_date_txt: None,
|
||||
view_count: video
|
||||
.view_count_text
|
||||
.map(|txt| util::parse_numeric(&txt).unwrap_or_default()),
|
||||
is_live: false,
|
||||
is_short: true,
|
||||
is_upcoming: false,
|
||||
short_description: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn map_playlist(playlist: PlaylistRenderer) -> PlaylistItem {
|
||||
PlaylistItem {
|
||||
id: playlist.playlist_id,
|
||||
|
@ -471,10 +413,6 @@ impl YouTubeListMapper<YouTubeItem> {
|
|||
YouTubeListItem::VideoRenderer(video) => {
|
||||
self.items.push(YouTubeItem::Video(self.map_video(video)));
|
||||
}
|
||||
YouTubeListItem::ReelItemRenderer(video) => {
|
||||
self.items
|
||||
.push(YouTubeItem::Video(self.map_short_video(video)));
|
||||
}
|
||||
YouTubeListItem::PlaylistRenderer(playlist) => self
|
||||
.items
|
||||
.push(YouTubeItem::Playlist(Self::map_playlist(playlist))),
|
||||
|
@ -511,9 +449,6 @@ impl YouTubeListMapper<VideoItem> {
|
|||
YouTubeListItem::VideoRenderer(video) => {
|
||||
self.items.push(self.map_video(video));
|
||||
}
|
||||
YouTubeListItem::ReelItemRenderer(video) => {
|
||||
self.items.push(self.map_short_video(video));
|
||||
}
|
||||
YouTubeListItem::ContinuationItemRenderer {
|
||||
continuation_endpoint,
|
||||
} => self.ctoken = Some(continuation_endpoint.continuation_command.token),
|
||||
|
|
|
@ -109,7 +109,6 @@ impl MapResponse<SearchResult> for response::Search {
|
|||
c: SearchResult {
|
||||
items: Paginator::new(self.estimated_results, mapper.items, mapper.ctoken),
|
||||
corrected_query: mapper.corrected_query,
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
},
|
||||
warnings: mapper.warnings,
|
||||
})
|
||||
|
|
|
@ -142,9 +142,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgszMUUzZDlGLWxiRSipqr2ZBg%3D%3D"),
|
||||
content: ChannelInfo(
|
||||
create_date: Some("2009-04-04"),
|
||||
view_count: Some(186854342),
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -142,9 +142,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgttaWpyTVpUN1AyZyioqr2ZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: None,
|
||||
items: [
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -113,9 +113,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: true,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgtQdE9zVVR3NVBDbyjz0ZKaBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: None,
|
||||
items: [
|
||||
|
|
|
@ -142,9 +142,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: true,
|
||||
visitor_data: Some("Cgs4ZFVmMzVlU1dxbyiBqpeaBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: None,
|
||||
items: [
|
||||
|
|
|
@ -142,9 +142,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgszNU5rbDVZS2hMcyim4K2ZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: None,
|
||||
items: [
|
||||
|
|
|
@ -30,9 +30,6 @@ Channel(
|
|||
banner: [],
|
||||
mobile_banner: [],
|
||||
tv_banner: [],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("Cgtvc2s4UllvTGl6byigxseZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: Some(0),
|
||||
items: [],
|
||||
|
|
|
@ -126,9 +126,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgtkYXJITElwYmd4OCj85a2ZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: Some(21),
|
||||
items: [
|
||||
|
|
|
@ -113,9 +113,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgtCV1l2R2Rzb2ZSZyiu4a2ZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: Some(0),
|
||||
items: [],
|
||||
|
|
|
@ -113,9 +113,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("CgtneXVRbGtSMWtlYyj75a2ZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: None,
|
||||
items: [
|
||||
|
|
|
@ -130,9 +130,6 @@ Channel(
|
|||
height: 1192,
|
||||
),
|
||||
],
|
||||
has_shorts: false,
|
||||
has_live: false,
|
||||
visitor_data: Some("Cgs4Ri1tLW1KNWozNCjGk8yZBg%3D%3D"),
|
||||
content: Paginator(
|
||||
count: None,
|
||||
items: [
|
||||
|
|
|
@ -424,5 +424,4 @@ VideoPlayer(
|
|||
expires_in_seconds: 21540,
|
||||
hls_manifest_url: None,
|
||||
dash_manifest_url: Some("https://manifest.googlevideo.com/api/manifest/dash/expire/1659481355/ei/q1jpYtOPEYSBgQeHmqbwAQ/ip/2003%3Ade%3Aaf0e%3A2f00%3Ade47%3A297%3Aa6db%3A774e/id/a4fbddf14c6649b4/source/youtube/requiressl/yes/playback_host/rr5---sn-h0jeenek.googlevideo.com/mh/mQ/mm/31%2C29/mn/sn-h0jeenek%2Csn-h0jelnez/ms/au%2Crdu/mv/m/mvi/5/pl/37/hfr/1/as/fmp4_audio_clear%2Cfmp4_sd_hd_clear/initcwndbps/1527500/vprv/1/mt/1659459429/fvip/4/itag_bl/376%2C377%2C384%2C385%2C612%2C613%2C617%2C619%2C623%2C628%2C655%2C656%2C660%2C662%2C666%2C671/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Chfr%2Cas%2Cvprv%2Citag/sig/AOq0QJ8wRAIgMm4a_MIHA3YUszKeruSy3exs5JwNjJAyLAwxL0yPdNMCIANb9GDMSTp_NT-PPhbvYMwRULJ5a9BO6MYD9FuWprC1/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRQIgETSOwhwWVMy7gmrFXZlJu655ToLzSwOEsT16oRyrWhACIQDkvOEw1fImz5omu4iVIRNFe-z-JC9v8WUyx281dW2NOw%3D%3D"),
|
||||
visitor_data: Some("Cgt2aHFtQU5YZFBvYyirsaWXBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -541,5 +541,4 @@ VideoPlayer(
|
|||
expires_in_seconds: 21540,
|
||||
hls_manifest_url: None,
|
||||
dash_manifest_url: Some("https://manifest.googlevideo.com/api/manifest/dash/expire/1659481355/ei/q1jpYtq3BJCX1gKVyJGQDg/ip/2003%3Ade%3Aaf0e%3A2f00%3Ade47%3A297%3Aa6db%3A774e/id/a4fbddf14c6649b4/source/youtube/requiressl/yes/playback_host/rr4---sn-h0jelnez.googlevideo.com/mh/mQ/mm/31%2C26/mn/sn-h0jelnez%2Csn-4g5edn6k/ms/au%2Conr/mv/m/mvi/4/pl/37/hfr/all/as/fmp4_audio_clear%2Cwebm_audio_clear%2Cwebm2_audio_clear%2Cfmp4_sd_hd_clear%2Cwebm2_sd_hd_clear/initcwndbps/1513750/spc/lT-KhrZGE2opztWyVdAtyUNlb8dXPDs/vprv/1/mt/1659459429/fvip/4/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Chfr%2Cas%2Cspc%2Cvprv%2Citag/sig/AOq0QJ8wRgIhAPEjHK19PKVHqQeia6WF4qubuMYk74LGi8F8lk5ZMPkFAiEAsaB2pKQWBvuPnNUnbdQXHc-izgsHJUP793woC2xNJlg%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRQIgOY4xu4H9wqPVZ7vF2i0hFcOnqrur1XGoA43a7ZEuuSUCIQCyPxBKXUQrKFmknNEGpX5GSWySKgMw_xHBikWpKpKwvg%3D%3D"),
|
||||
visitor_data: Some("CgtoS1pCMVJTNUJISSirsaWXBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -365,5 +365,4 @@ VideoPlayer(
|
|||
expires_in_seconds: 21540,
|
||||
hls_manifest_url: None,
|
||||
dash_manifest_url: Some("https://manifest.googlevideo.com/api/manifest/dash/expire/1659487474/ei/knDpYub6BojEgAf6jbLgDw/ip/2003%3Ade%3Aaf0e%3A2f00%3Ade47%3A297%3Aa6db%3A774e/id/a4fbddf14c6649b4/source/youtube/requiressl/yes/playback_host/rr5---sn-h0jeenek.googlevideo.com/mh/mQ/mm/31%2C29/mn/sn-h0jeenek%2Csn-h0jelnez/ms/au%2Crdu/mv/m/mvi/5/pl/37/hfr/all/as/fmp4_audio_clear%2Cwebm_audio_clear%2Cwebm2_audio_clear%2Cfmp4_sd_hd_clear%2Cwebm2_sd_hd_clear/initcwndbps/1418750/spc/lT-Khox4YuJQ2wmH79zYALRvsWTPCUc/vprv/1/mt/1659465669/fvip/4/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Chfr%2Cas%2Cspc%2Cvprv%2Citag/sig/AOq0QJ8wRAIgErABhAEaoKHUDu9dDbpxE_8gR4b8WWAi61fnu8UKnuICIEYrEKcHvqHdO4V3R7cvSGwi_HGH34IlQsKbziOfMBov/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRQIgJxHmH0Sxo3cY_pW_ZzQ3hW9-7oz6K_pZWcUdrDDQ2sQCIQDJYNINQwLgKelgbO3CZYx7sMxdUAFpWdokmRBQ77vwvw%3D%3D"),
|
||||
visitor_data: Some("CgszSHZWNWs0SDhpTSiS4aWXBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -160,5 +160,4 @@ VideoPlayer(
|
|||
expires_in_seconds: 21540,
|
||||
hls_manifest_url: Some("https://manifest.googlevideo.com/api/manifest/hls_variant/expire/1659481355/ei/q1jpYq-xHs7NgQev0bfwAQ/ip/2003%3Ade%3Aaf0e%3A2f00%3Ade47%3A297%3Aa6db%3A774e/id/a4fbddf14c6649b4/source/youtube/requiressl/yes/playback_host/rr4---sn-h0jelnez.googlevideo.com/mh/mQ/mm/31%2C29/mn/sn-h0jelnez%2Csn-h0jeenek/ms/au%2Crdu/mv/m/mvi/4/pl/37/hfr/1/demuxed/1/tts_caps/1/maudio/1/initcwndbps/1513750/vprv/1/go/1/mt/1659459429/fvip/5/nvgoi/1/short_key/1/ncsapi/1/keepalive/yes/fexp/24001373%2C24007246/dover/13/itag/0/playlist_type/DVR/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Chfr%2Cdemuxed%2Ctts_caps%2Cmaudio%2Cvprv%2Cgo%2Citag%2Cplaylist_type/sig/AOq0QJ8wRQIhAIYnEHvIgJtJ8hehAXNtVY3qsgsq_GdOhWf2hkJZe6lCAiBxaRY_nubYp6hBizcAg_KFkKnkG-t2XYLRQ5wGdM3AjA%3D%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRgIhAM_91Kk_0VLuSsR6nLCY7LdtWojyRAzXSScd_X9ShRROAiEA1AF4VY04F71NsAI8_j3iqjuXnWL9s6NoXHq7P8-bHx8%3D/file/index.m3u8"),
|
||||
dash_manifest_url: None,
|
||||
visitor_data: Some("Cgs4TXV4dk13WVEyWSirsaWXBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -541,5 +541,4 @@ VideoPlayer(
|
|||
expires_in_seconds: 21540,
|
||||
hls_manifest_url: None,
|
||||
dash_manifest_url: Some("https://manifest.googlevideo.com/api/manifest/dash/expire/1659481355/ei/q1jpYv-eJ9uF6dsPhvyH8As/ip/2003%3Ade%3Aaf0e%3A2f00%3Ade47%3A297%3Aa6db%3A774e/id/a4fbddf14c6649b4/source/youtube/requiressl/yes/playback_host/rr4---sn-h0jelnez.googlevideo.com/mh/mQ/mm/31%2C29/mn/sn-h0jelnez%2Csn-h0jeenek/ms/au%2Crdu/mv/m/mvi/4/pl/37/hfr/all/as/fmp4_audio_clear%2Cfmp4_sd_hd_clear/initcwndbps/1527500/vprv/1/mt/1659459429/fvip/5/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Chfr%2Cas%2Cvprv%2Citag/sig/AOq0QJ8wRQIhANKWS7GCN4pSoHIQ6BMZdOaHAD0I25nHwRj7ds4qrxdEAiBsd9l8WIceqF7-2xyR82DGecCiS9hgUIPJhdNhkwVpHg%3D%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRQIgMbu-wTOcXGCwGh27y0YZHktumKM1sopgxfQf8LCcCnECIQDnhFbgddOxwiQbnMOIcCn6ncpN54UyALRNigUSCp9Deg%3D%3D"),
|
||||
visitor_data: Some("CgtacUJOMG81dTI3cyirsaWXBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -3142,5 +3142,4 @@ Playlist(
|
|||
)),
|
||||
last_update: "[date]",
|
||||
last_update_txt: Some("Last updated on Aug 7, 2022"),
|
||||
visitor_data: Some("CgtZdi1GV3N3TnBuQSi46K-YBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -2088,5 +2088,4 @@ Playlist(
|
|||
)),
|
||||
last_update: "[date]",
|
||||
last_update_txt: Some("Last updated on Jul 2, 2014"),
|
||||
visitor_data: Some("CgtXY0lqNWN5VlNmTSik8q-YBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -3041,5 +3041,4 @@ Playlist(
|
|||
channel: None,
|
||||
last_update: "[date]",
|
||||
last_update_txt: Some("Updated today"),
|
||||
visitor_data: Some("CgtLZVdRQ1dkM2VDVSi46K-YBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -734,5 +734,4 @@ SearchResult(
|
|||
endpoint: browse,
|
||||
),
|
||||
corrected_query: Some("doobydobap"),
|
||||
visitor_data: Some("Cgs4MEJMc3FmVzVadyiNy4-aBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -10,5 +10,4 @@ SearchResult(
|
|||
endpoint: browse,
|
||||
),
|
||||
corrected_query: None,
|
||||
visitor_data: Some("Cgs1Q0NxX3llelBxWSi85ZGaBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -691,5 +691,4 @@ SearchResult(
|
|||
endpoint: browse,
|
||||
),
|
||||
corrected_query: None,
|
||||
visitor_data: Some("CgstZjhyS1IyR1R6dyiX4JGaBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -750,5 +750,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SC1plZXJybnVMaTVFGAYyOCIRIgtaZWVycm51TGk1RTABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("CgtCeURHR09uNlJ5TSjOiLqZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -824,5 +824,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SC1plZXJybnVMaTVFGAYyOCIRIgtaZWVycm51TGk1RTABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("Cgs2V0p6ZW5ab1ozTSjkrpaaBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -1282,5 +1282,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SC25GREJ4QlVmRTc0GAYyOCIRIgtuRkRCeEJVZkU3NDABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("Cgtidzg4MlRTb3FKSSiqipeaBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -54,5 +54,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SC0hSS3UwY3Zycl9vGAYyOCIRIgtIUkt1MGN2cnJfbzABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("CgtxUUdrc1VSVE54Zyja1KiZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -771,5 +771,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SCzByYjlDZk92b2prGAYyOCIRIgswcmI5Q2ZPdm9qazABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("CgtoY1pQUF8wNW1qayjSjpSZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -1239,5 +1239,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SC25GREJ4QlVmRTc0GAYyOCIRIgtuRkRCeEJVZkU3NDABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("CgtIV0JjSUtDQm9LQSjUjpSZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -830,5 +830,4 @@ VideoDetails(
|
|||
ctoken: None,
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("CgtnQS1WdzlNNkNCSSiSmKiZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -576,5 +576,4 @@ VideoDetails(
|
|||
ctoken: None,
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("CgtzclhqZVpoajVhVSi76qeZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -787,5 +787,4 @@ VideoDetails(
|
|||
ctoken: Some("Eg0SC1plZXJybnVMaTVFGAYyOCIRIgtaZWVycm51TGk1RTABeAIwAUIhZW5nYWdlbWVudC1wYW5lbC1jb21tZW50cy1zZWN0aW9u"),
|
||||
endpoint: next,
|
||||
),
|
||||
visitor_data: Some("Cgtjemd0bDVxU1N1QSjRjpSZBg%3D%3D"),
|
||||
)
|
||||
|
|
|
@ -252,7 +252,7 @@ impl MapResponse<VideoDetails> for response::VideoDetails {
|
|||
let mut res = map_recommendations(
|
||||
r,
|
||||
sr.secondary_results.continuations,
|
||||
self.response_context.visitor_data.clone(),
|
||||
self.response_context.visitor_data,
|
||||
lang,
|
||||
);
|
||||
warnings.append(&mut res.warnings);
|
||||
|
@ -343,7 +343,6 @@ impl MapResponse<VideoDetails> for response::VideoDetails {
|
|||
None,
|
||||
crate::param::ContinuationEndpoint::Next,
|
||||
),
|
||||
visitor_data: self.response_context.visitor_data,
|
||||
},
|
||||
warnings,
|
||||
})
|
||||
|
|
|
@ -112,12 +112,8 @@ pub struct VideoPlayer {
|
|||
pub subtitles: Vec<Subtitle>,
|
||||
/// Lifetime of the stream URLs in seconds
|
||||
pub expires_in_seconds: u32,
|
||||
/// HLS manifest URL (for livestreams)
|
||||
pub hls_manifest_url: Option<String>,
|
||||
/// Dash manifest URL (for livestreams)
|
||||
pub dash_manifest_url: Option<String>,
|
||||
/// YouTube visitor data cookie
|
||||
pub visitor_data: Option<String>,
|
||||
}
|
||||
|
||||
/// Video metadata from the player
|
||||
|
@ -465,8 +461,6 @@ pub struct Playlist {
|
|||
pub last_update: Option<Date>,
|
||||
/// Textual last update date
|
||||
pub last_update_txt: Option<String>,
|
||||
/// YouTube visitor data cookie
|
||||
pub visitor_data: Option<String>,
|
||||
}
|
||||
|
||||
/// YouTube video extracted from a playlist
|
||||
|
@ -549,8 +543,6 @@ pub struct VideoDetails {
|
|||
///
|
||||
/// Is initially empty.
|
||||
pub latest_comments: Paginator<Comment>,
|
||||
/// YouTube visitor data cookie
|
||||
pub visitor_data: Option<String>,
|
||||
}
|
||||
|
||||
/// Chapter of a video
|
||||
|
@ -683,12 +675,6 @@ pub struct Channel<T> {
|
|||
pub mobile_banner: Vec<Thumbnail>,
|
||||
/// Banner image shown above the channel (16:9 fullscreen format for TV)
|
||||
pub tv_banner: Vec<Thumbnail>,
|
||||
/// Does the channel have a *Shorts* tab?
|
||||
pub has_shorts: bool,
|
||||
/// Does the channel have a *Live* tab?
|
||||
pub has_live: bool,
|
||||
/// YouTube visitor data cookie
|
||||
pub visitor_data: Option<String>,
|
||||
/// Content fetched from the channel
|
||||
pub content: T,
|
||||
}
|
||||
|
@ -759,8 +745,6 @@ pub struct SearchResult {
|
|||
/// for the corrected search term and displays it on top of the
|
||||
/// search results page.
|
||||
pub corrected_query: Option<String>,
|
||||
/// YouTube visitor data cookie
|
||||
pub visitor_data: Option<String>,
|
||||
}
|
||||
|
||||
/// YouTube item (Video/Channel/Playlist)
|
||||
|
|
|
@ -82,27 +82,17 @@ impl Mul<u8> for TimeAgo {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<TimeAgo> for Duration {
|
||||
fn from(ta: TimeAgo) -> Self {
|
||||
match ta.unit {
|
||||
TimeUnit::Second => Duration::seconds(ta.n as i64),
|
||||
TimeUnit::Minute => Duration::minutes(ta.n as i64),
|
||||
TimeUnit::Hour => Duration::hours(ta.n as i64),
|
||||
TimeUnit::Day => Duration::days(ta.n as i64),
|
||||
TimeUnit::Week => Duration::weeks(ta.n as i64),
|
||||
TimeUnit::Month => Duration::days(ta.n as i64 * 30),
|
||||
TimeUnit::Year => Duration::days(ta.n as i64 * 365),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TimeAgo> for OffsetDateTime {
|
||||
fn from(ta: TimeAgo) -> Self {
|
||||
let ts = util::now_sec();
|
||||
match ta.unit {
|
||||
TimeUnit::Second => ts - Duration::seconds(ta.n as i64),
|
||||
TimeUnit::Minute => ts - Duration::minutes(ta.n as i64),
|
||||
TimeUnit::Hour => ts - Duration::hours(ta.n as i64),
|
||||
TimeUnit::Day => ts - Duration::days(ta.n as i64),
|
||||
TimeUnit::Week => ts - Duration::weeks(ta.n as i64),
|
||||
TimeUnit::Month => ts.replace_date(util::shift_months(ts.date(), -(ta.n as i32))),
|
||||
TimeUnit::Year => ts.replace_date(util::shift_years(ts.date(), -(ta.n as i32))),
|
||||
_ => ts - Duration::from(ta),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -12,8 +12,6 @@ use rustypipe::model::{
|
|||
};
|
||||
use rustypipe::param::search_filter::{self, SearchFilter};
|
||||
|
||||
const VISITOR_DATA_3TAB_CHANNEL_LAYOUT: &str = "CgtOa256ckVkcG5YVSiirbyaBg%3D%3D";
|
||||
|
||||
//#PLAYER
|
||||
|
||||
#[rstest]
|
||||
|
@ -910,75 +908,6 @@ async fn channel_videos() {
|
|||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn channel_shorts() {
|
||||
let rp = RustyPipe::builder()
|
||||
.strict()
|
||||
.visitor_data(VISITOR_DATA_3TAB_CHANNEL_LAYOUT)
|
||||
.build();
|
||||
let channel = rp
|
||||
.query()
|
||||
.channel_shorts("UCh8gHdtzO2tXd593_bjErWg")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// dbg!(&channel);
|
||||
assert_eq!(channel.id, "UCh8gHdtzO2tXd593_bjErWg");
|
||||
assert_eq!(channel.name, "Doobydobap");
|
||||
assert!(
|
||||
channel.subscriber_count.unwrap() > 2800000,
|
||||
"expected >2.8M subscribers, got {}",
|
||||
channel.subscriber_count.unwrap()
|
||||
);
|
||||
assert!(!channel.avatar.is_empty(), "got no thumbnails");
|
||||
assert_eq!(channel.verification, Verification::Verified);
|
||||
assert!(channel
|
||||
.description
|
||||
.contains("Hi, I\u{2019}m Tina, aka Doobydobap"));
|
||||
assert_eq!(
|
||||
channel.vanity_url.as_ref().unwrap(),
|
||||
"https://www.youtube.com/c/Doobydobap"
|
||||
);
|
||||
assert!(!channel.banner.is_empty(), "got no banners");
|
||||
assert!(!channel.mobile_banner.is_empty(), "got no mobile banners");
|
||||
assert!(!channel.tv_banner.is_empty(), "got no tv banners");
|
||||
|
||||
assert!(
|
||||
!channel.content.items.is_empty() && !channel.content.is_exhausted(),
|
||||
"got no shorts"
|
||||
);
|
||||
|
||||
let next = channel.content.next(&rp.query()).await.unwrap().unwrap();
|
||||
assert!(
|
||||
!next.is_exhausted() && !next.items.is_empty(),
|
||||
"no more shorts"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn channel_livestreams() {
|
||||
let rp = RustyPipe::builder()
|
||||
.visitor_data(VISITOR_DATA_3TAB_CHANNEL_LAYOUT)
|
||||
.strict()
|
||||
.build();
|
||||
let channel = rp
|
||||
.query()
|
||||
.channel_livestreams("UC2DjFE7Xf11URZqWBigcVOQ")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// dbg!(&channel);
|
||||
assert_channel_eevblog(&channel);
|
||||
|
||||
assert!(
|
||||
!channel.content.items.is_empty() && !channel.content.is_exhausted(),
|
||||
"got no streams"
|
||||
);
|
||||
|
||||
let next = channel.content.next(&rp.query()).await.unwrap().unwrap();
|
||||
assert!(!next.items.is_empty(), "no more streams");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn channel_playlists() {
|
||||
let rp = RustyPipe::builder().strict().build();
|
||||
|
|
Loading…
Add table
Reference in a new issue