fix: add model conversion, generic string arg
This commit is contained in:
parent
3458924018
commit
630ea5960f
2 changed files with 17 additions and 6 deletions
|
|
@ -29,7 +29,8 @@ struct QVideo<'a> {
|
||||||
|
|
||||||
impl RustyPipeQuery {
|
impl RustyPipeQuery {
|
||||||
/// Get the metadata for a video
|
/// Get the metadata for a video
|
||||||
pub async fn video_details(&self, video_id: &str) -> Result<VideoDetails, Error> {
|
pub async fn video_details<S: AsRef<str>>(&self, video_id: S) -> Result<VideoDetails, Error> {
|
||||||
|
let video_id = video_id.as_ref();
|
||||||
let context = self.get_context(ClientType::Desktop, true, None).await;
|
let context = self.get_context(ClientType::Desktop, true, None).await;
|
||||||
let request_body = QVideo {
|
let request_body = QVideo {
|
||||||
context,
|
context,
|
||||||
|
|
@ -49,11 +50,12 @@ impl RustyPipeQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the comments for a video using the continuation token obtained from `rusty_pipe_query.video_details()`
|
/// Get the comments for a video using the continuation token obtained from `rusty_pipe_query.video_details()`
|
||||||
pub async fn video_comments(
|
pub async fn video_comments<S: AsRef<str>>(
|
||||||
&self,
|
&self,
|
||||||
ctoken: &str,
|
ctoken: S,
|
||||||
visitor_data: Option<&str>,
|
visitor_data: Option<&str>,
|
||||||
) -> Result<Paginator<Comment>, Error> {
|
) -> Result<Paginator<Comment>, Error> {
|
||||||
|
let ctoken = ctoken.as_ref();
|
||||||
let context = self
|
let context = self
|
||||||
.get_context(ClientType::Desktop, true, visitor_data)
|
.get_context(ClientType::Desktop, true, visitor_data)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{
|
use super::{
|
||||||
AlbumItem, ArtistId, ArtistItem, Channel, ChannelId, ChannelItem, ChannelTag, MusicArtist,
|
AlbumItem, ArtistId, ArtistItem, Channel, ChannelId, ChannelItem, ChannelRssVideo, ChannelTag,
|
||||||
MusicItem, MusicPlaylistItem, PlaylistItem, PlaylistVideo, TrackItem, VideoId, VideoItem,
|
MusicArtist, MusicItem, MusicPlaylistItem, PlaylistItem, PlaylistVideo, TrackItem, VideoId,
|
||||||
YouTubeItem,
|
VideoItem, YouTubeItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Trait for casting generic YouTube/YouTube music items to a specific kind.
|
/// Trait for casting generic YouTube/YouTube music items to a specific kind.
|
||||||
|
|
@ -168,6 +168,15 @@ impl From<PlaylistVideo> for VideoId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ChannelRssVideo> for VideoId {
|
||||||
|
fn from(video: ChannelRssVideo) -> Self {
|
||||||
|
Self {
|
||||||
|
id: video.id,
|
||||||
|
name: video.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<TrackItem> for VideoId {
|
impl From<TrackItem> for VideoId {
|
||||||
fn from(track: TrackItem) -> Self {
|
fn from(track: TrackItem) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
Reference in a new issue