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 {
|
||||
/// 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 request_body = QVideo {
|
||||
context,
|
||||
|
|
@ -49,11 +50,12 @@ impl RustyPipeQuery {
|
|||
}
|
||||
|
||||
/// 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,
|
||||
ctoken: &str,
|
||||
ctoken: S,
|
||||
visitor_data: Option<&str>,
|
||||
) -> Result<Paginator<Comment>, Error> {
|
||||
let ctoken = ctoken.as_ref();
|
||||
let context = self
|
||||
.get_context(ClientType::Desktop, true, visitor_data)
|
||||
.await;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::{
|
||||
AlbumItem, ArtistId, ArtistItem, Channel, ChannelId, ChannelItem, ChannelTag, MusicArtist,
|
||||
MusicItem, MusicPlaylistItem, PlaylistItem, PlaylistVideo, TrackItem, VideoId, VideoItem,
|
||||
YouTubeItem,
|
||||
AlbumItem, ArtistId, ArtistItem, Channel, ChannelId, ChannelItem, ChannelRssVideo, ChannelTag,
|
||||
MusicArtist, MusicItem, MusicPlaylistItem, PlaylistItem, PlaylistVideo, TrackItem, VideoId,
|
||||
VideoItem, YouTubeItem,
|
||||
};
|
||||
|
||||
/// 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 {
|
||||
fn from(track: TrackItem) -> Self {
|
||||
Self {
|
||||
|
|
|
|||
Reference in a new issue