fix: use response model for search suggestion
This commit is contained in:
parent
f420200f52
commit
20ecea65ef
3 changed files with 12 additions and 8 deletions
|
|
@ -33,6 +33,7 @@ pub(crate) use player::Player;
|
||||||
pub(crate) use playlist::Playlist;
|
pub(crate) use playlist::Playlist;
|
||||||
pub(crate) use playlist::PlaylistCont;
|
pub(crate) use playlist::PlaylistCont;
|
||||||
pub(crate) use search::Search;
|
pub(crate) use search::Search;
|
||||||
|
pub(crate) use search::SearchSuggestion;
|
||||||
pub(crate) use trends::Startpage;
|
pub(crate) use trends::Startpage;
|
||||||
pub(crate) use trends::Trending;
|
pub(crate) use trends::Trending;
|
||||||
pub(crate) use url_endpoint::ResolvedUrl;
|
pub(crate) use url_endpoint::ResolvedUrl;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use serde::Deserialize;
|
use serde::{de::IgnoredAny, Deserialize};
|
||||||
use serde_with::{json::JsonString, serde_as};
|
use serde_with::{json::JsonString, serde_as};
|
||||||
|
|
||||||
use super::{video_item::YouTubeListRendererWrap, ResponseContext};
|
use super::{video_item::YouTubeListRendererWrap, ResponseContext};
|
||||||
|
|
@ -24,3 +24,10 @@ pub(crate) struct Contents {
|
||||||
pub(crate) struct TwoColumnSearchResultsRenderer {
|
pub(crate) struct TwoColumnSearchResultsRenderer {
|
||||||
pub primary_contents: YouTubeListRendererWrap,
|
pub primary_contents: YouTubeListRendererWrap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub(crate) struct SearchSuggestion(
|
||||||
|
IgnoredAny,
|
||||||
|
pub Vec<(String, IgnoredAny, IgnoredAny)>,
|
||||||
|
IgnoredAny,
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use serde::{de::IgnoredAny, Serialize};
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{Error, ExtractionError},
|
error::{Error, ExtractionError},
|
||||||
|
|
@ -79,12 +79,8 @@ impl RustyPipeQuery {
|
||||||
.http_request_txt(self.client.inner.http.get(url).build()?)
|
.http_request_txt(self.client.inner.http.get(url).build()?)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let parsed = serde_json::from_str::<(
|
let parsed = serde_json::from_str::<response::SearchSuggestion>(&response)
|
||||||
IgnoredAny,
|
.map_err(|e| Error::Extraction(ExtractionError::InvalidData(e.to_string().into())))?;
|
||||||
Vec<(String, IgnoredAny, IgnoredAny)>,
|
|
||||||
IgnoredAny,
|
|
||||||
)>(&response)
|
|
||||||
.map_err(|e| Error::Extraction(ExtractionError::InvalidData(e.to_string().into())))?;
|
|
||||||
|
|
||||||
Ok(parsed.1.into_iter().map(|item| item.0).collect())
|
Ok(parsed.1.into_iter().map(|item| item.0).collect())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue