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::PlaylistCont;
|
||||
pub(crate) use search::Search;
|
||||
pub(crate) use search::SearchSuggestion;
|
||||
pub(crate) use trends::Startpage;
|
||||
pub(crate) use trends::Trending;
|
||||
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 super::{video_item::YouTubeListRendererWrap, ResponseContext};
|
||||
|
|
@ -24,3 +24,10 @@ pub(crate) struct Contents {
|
|||
pub(crate) struct TwoColumnSearchResultsRenderer {
|
||||
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::{
|
||||
error::{Error, ExtractionError},
|
||||
|
|
@ -79,12 +79,8 @@ impl RustyPipeQuery {
|
|||
.http_request_txt(self.client.inner.http.get(url).build()?)
|
||||
.await?;
|
||||
|
||||
let parsed = serde_json::from_str::<(
|
||||
IgnoredAny,
|
||||
Vec<(String, IgnoredAny, IgnoredAny)>,
|
||||
IgnoredAny,
|
||||
)>(&response)
|
||||
.map_err(|e| Error::Extraction(ExtractionError::InvalidData(e.to_string().into())))?;
|
||||
let parsed = serde_json::from_str::<response::SearchSuggestion>(&response)
|
||||
.map_err(|e| Error::Extraction(ExtractionError::InvalidData(e.to_string().into())))?;
|
||||
|
||||
Ok(parsed.1.into_iter().map(|item| item.0).collect())
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue