diff --git a/ytmapi-rs/src/query/artist.rs b/ytmapi-rs/src/query/artist.rs index 574c2b78..5628f6df 100644 --- a/ytmapi-rs/src/query/artist.rs +++ b/ytmapi-rs/src/query/artist.rs @@ -18,8 +18,10 @@ pub struct GetArtistAlbumsQuery<'a> { params: BrowseParams<'a>, } impl<'a> GetArtistQuery<'a> { - pub fn new(channel_id: ChannelID<'a>) -> GetArtistQuery<'a> { - GetArtistQuery { channel_id } + pub fn new(channel_id: impl Into>) -> GetArtistQuery<'a> { + GetArtistQuery { + channel_id: channel_id.into(), + } } } impl<'a> GetArtistAlbumsQuery<'a> { @@ -28,6 +30,12 @@ impl<'a> GetArtistAlbumsQuery<'a> { } } +impl<'a, T: Into>> From for GetArtistQuery<'a> { + fn from(channel_id: T) -> Self { + GetArtistQuery::new(channel_id.into()) + } +} + impl<'a, A: AuthToken> Query for GetArtistQuery<'a> { type Output = ArtistParams; type Method = PostMethod; diff --git a/ytmapi-rs/src/query/playlist/additems.rs b/ytmapi-rs/src/query/playlist/additems.rs index deec5f58..e1b5fd4d 100644 --- a/ytmapi-rs/src/query/playlist/additems.rs +++ b/ytmapi-rs/src/query/playlist/additems.rs @@ -22,11 +22,13 @@ pub struct AddPlaylistItemsQuery<'a, T: SpecialisedQuery> { id: PlaylistID<'a>, query_type: T, } +/// Helper struct for AddPlaylistItemsQuery #[derive(Default, Debug, Clone, PartialEq)] pub struct AddVideosToPlaylist<'a> { video_ids: Vec>, duplicate_handling_mode: DuplicateHandlingMode, } +/// Helper struct for AddPlaylistItemsQuery #[derive(Debug, Clone, PartialEq)] pub struct AddPlaylistToPlaylist<'a> { source_playlist: PlaylistID<'a>, diff --git a/ytmapi-rs/src/query/playlist/create.rs b/ytmapi-rs/src/query/playlist/create.rs index 771b5229..559ab06c 100644 --- a/ytmapi-rs/src/query/playlist/create.rs +++ b/ytmapi-rs/src/query/playlist/create.rs @@ -21,12 +21,15 @@ pub struct CreatePlaylistQuery<'a, C: CreatePlaylistType> { query_type: C, } +/// Helper struct for CreatePlaylistQuery #[derive(Default, Debug, Clone, PartialEq)] pub struct BasicCreatePlaylist {} +/// Helper struct for CreatePlaylistQuery #[derive(Default, Debug, Clone, PartialEq)] pub struct CreatePlaylistFromVideos<'a> { video_ids: Vec>, } +/// Helper struct for CreatePlaylistQuery #[derive(Debug, Clone, PartialEq)] pub struct CreatePlaylistFromPlaylist<'a> { source_playlist: PlaylistID<'a>, diff --git a/ytmapi-rs/src/query/search.rs b/ytmapi-rs/src/query/search.rs index 4ea3e76b..7b422d86 100644 --- a/ytmapi-rs/src/query/search.rs +++ b/ytmapi-rs/src/query/search.rs @@ -41,10 +41,13 @@ pub enum SpellingMode { WithSuggestions, } +/// Helper struct for SearchQuery type state pattern. #[derive(Default, Debug, Clone, PartialEq)] pub struct BasicSearch; +/// Helper struct for SearchQuery type state pattern. #[derive(Default, Debug, Clone, PartialEq)] pub struct LibrarySearch; +/// Helper struct for SearchQuery type state pattern. #[derive(Default, Debug, Clone, PartialEq)] pub struct UploadSearch; diff --git a/ytmapi-rs/src/query/search/filteredsearch.rs b/ytmapi-rs/src/query/search/filteredsearch.rs index 56def15e..1579d2cc 100644 --- a/ytmapi-rs/src/query/search/filteredsearch.rs +++ b/ytmapi-rs/src/query/search/filteredsearch.rs @@ -30,28 +30,39 @@ pub trait FilteredSearchType: Default { "EgWKAQ".into() } } +/// Helper struct for SearchQuery #[derive(Default, Debug, Clone, PartialEq)] pub struct FilteredSearch { - pub filter: F, + pub(crate) filter: F, } +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct SongsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct VideosFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct AlbumsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct ArtistsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct PlaylistsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct CommunityPlaylistsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct FeaturedPlaylistsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct EpisodesFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct PodcastsFilter; +/// Helper struct for FilteredSearch type state pattern. #[derive(Default, PartialEq, Debug, Clone)] pub struct ProfilesFilter; diff --git a/ytmapi-rs/src/simplified_queries.rs b/ytmapi-rs/src/simplified_queries.rs index 3cf18232..38223e4c 100644 --- a/ytmapi-rs/src/simplified_queries.rs +++ b/ytmapi-rs/src/simplified_queries.rs @@ -205,12 +205,11 @@ impl YtMusic { /// let results = yt.search_artists("Beatles").await.unwrap(); /// yt.get_artist(&results[0].browse_id).await /// # }; - pub async fn get_artist<'a, T: Into>>( + pub async fn get_artist<'a>( &self, - channel_id: T, + query: impl Into>, ) -> Result { - let query = GetArtistQuery::new(channel_id.into()); - self.query(query).await + self.query(query.into()).await } /// Gets a full list albums for an artist. /// ```no_run