pub struct YtMusic<A: AuthToken> { /* private fields */ }Expand description
A handle to the YouTube Music API, wrapping a http client. Generic over AuthToken, as different AuthTokens may allow different queries to be executed. It is recommended to re-use these as they internally contain a connection pool.
§Documentation note
Examples given for methods on this struct will use fake or mock constructors. When using in a real environment, you will need to construct using a real token or cookie.
Implementations§
Source§impl<A: AuthToken> YtMusic<A>
impl<A: AuthToken> YtMusic<A>
Sourcepub async fn search<'a, Q: Into<SearchQuery<'a, BasicSearch>>>(
&self,
query: Q,
) -> Result<SearchResults>
Available on crate feature simplified-queries only.
pub async fn search<'a, Q: Into<SearchQuery<'a, BasicSearch>>>( &self, query: Q, ) -> Result<SearchResults>
simplified-queries only.API Search Query that returns results for each category if available.
§Usage
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search("Beatles").awaitSourcepub async fn search_artists<'a, Q: Into<SearchQuery<'a, FilteredSearch<ArtistsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultArtist>>
Available on crate feature simplified-queries only.
pub async fn search_artists<'a, Q: Into<SearchQuery<'a, FilteredSearch<ArtistsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultArtist>>
simplified-queries only.API Search Query for Artists only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_artists("Beatles").awaitSourcepub async fn search_albums<'a, Q: Into<SearchQuery<'a, FilteredSearch<AlbumsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultAlbum>>
Available on crate feature simplified-queries only.
pub async fn search_albums<'a, Q: Into<SearchQuery<'a, FilteredSearch<AlbumsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultAlbum>>
simplified-queries only.API Search Query for Albums only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_albums("Beatles").awaitSourcepub async fn search_songs<'a, Q: Into<SearchQuery<'a, FilteredSearch<SongsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultSong>>
Available on crate feature simplified-queries only.
pub async fn search_songs<'a, Q: Into<SearchQuery<'a, FilteredSearch<SongsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultSong>>
simplified-queries only.API Search Query for Songs only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_songs("Beatles").awaitSourcepub async fn search_playlists<'a, Q: Into<SearchQuery<'a, FilteredSearch<PlaylistsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultPlaylist>>
Available on crate feature simplified-queries only.
pub async fn search_playlists<'a, Q: Into<SearchQuery<'a, FilteredSearch<PlaylistsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultPlaylist>>
simplified-queries only.API Search Query for Playlists only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_playlists("Beatles").awaitSourcepub async fn search_community_playlists<'a, Q: Into<SearchQuery<'a, FilteredSearch<CommunityPlaylistsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultPlaylist>>
Available on crate feature simplified-queries only.
pub async fn search_community_playlists<'a, Q: Into<SearchQuery<'a, FilteredSearch<CommunityPlaylistsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultPlaylist>>
simplified-queries only.API Search Query for Community Playlists only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_community_playlists("Beatles").awaitSourcepub async fn search_featured_playlists<'a, Q: Into<SearchQuery<'a, FilteredSearch<FeaturedPlaylistsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultFeaturedPlaylist>>
Available on crate feature simplified-queries only.
pub async fn search_featured_playlists<'a, Q: Into<SearchQuery<'a, FilteredSearch<FeaturedPlaylistsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultFeaturedPlaylist>>
simplified-queries only.API Search Query for Featured Playlists only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_featured_playlists("Beatles").awaitSourcepub async fn search_episodes<'a, Q: Into<SearchQuery<'a, FilteredSearch<EpisodesFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultEpisode>>
Available on crate feature simplified-queries only.
pub async fn search_episodes<'a, Q: Into<SearchQuery<'a, FilteredSearch<EpisodesFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultEpisode>>
simplified-queries only.API Search Query for Episodes only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_episodes("Beatles").awaitSourcepub async fn search_podcasts<'a, Q: Into<SearchQuery<'a, FilteredSearch<PodcastsFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultPodcast>>
Available on crate feature simplified-queries only.
pub async fn search_podcasts<'a, Q: Into<SearchQuery<'a, FilteredSearch<PodcastsFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultPodcast>>
simplified-queries only.API Search Query for Podcasts only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_podcasts("Beatles").awaitSourcepub async fn search_videos<'a, Q: Into<SearchQuery<'a, FilteredSearch<VideosFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultVideo>>
Available on crate feature simplified-queries only.
pub async fn search_videos<'a, Q: Into<SearchQuery<'a, FilteredSearch<VideosFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultVideo>>
simplified-queries only.API Search Query for Videos only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_videos("Beatles").awaitSourcepub async fn search_profiles<'a, Q: Into<SearchQuery<'a, FilteredSearch<ProfilesFilter>>>>(
&self,
query: Q,
) -> Result<Vec<SearchResultProfile>>
Available on crate feature simplified-queries only.
pub async fn search_profiles<'a, Q: Into<SearchQuery<'a, FilteredSearch<ProfilesFilter>>>>( &self, query: Q, ) -> Result<Vec<SearchResultProfile>>
simplified-queries only.API Search Query for Profiles only.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.search_profiles("Beatles").awaitSourcepub async fn get_artist<'a>(
&self,
query: impl Into<GetArtistQuery<'a>>,
) -> Result<ArtistParams>
Available on crate feature simplified-queries only.
pub async fn get_artist<'a>( &self, query: impl Into<GetArtistQuery<'a>>, ) -> Result<ArtistParams>
simplified-queries only.Gets information about an artist and their top releases.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_artists("Beatles").await.unwrap();
yt.get_artist(&results[0].browse_id).awaitSourcepub async fn get_artist_albums<'a, T: Into<ArtistChannelID<'a>>, U: Into<BrowseParams<'a>>>(
&self,
channel_id: T,
browse_params: U,
) -> Result<Vec<GetArtistAlbumsAlbum>>
Available on crate feature simplified-queries only.
pub async fn get_artist_albums<'a, T: Into<ArtistChannelID<'a>>, U: Into<BrowseParams<'a>>>( &self, channel_id: T, browse_params: U, ) -> Result<Vec<GetArtistAlbumsAlbum>>
simplified-queries only.Gets a full list albums for an artist.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_artists("Beatles").await.unwrap();
let artist_top_albums = yt.get_artist(&results[0].browse_id).await.unwrap().top_releases.albums.unwrap();
yt.get_artist_albums(
artist_top_albums.browse_id.unwrap(),
artist_top_albums.params.unwrap(),
).awaitSourcepub async fn get_album<'a, T: Into<AlbumID<'a>>>(
&self,
album_id: T,
) -> Result<GetAlbum>
Available on crate feature simplified-queries only.
pub async fn get_album<'a, T: Into<AlbumID<'a>>>( &self, album_id: T, ) -> Result<GetAlbum>
simplified-queries only.Gets information about an album and its tracks.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_albums("Dark Side Of The Moon").await.unwrap();
yt.get_album(&results[0].album_id).awaitSourcepub async fn get_watch_playlist_from_video_id<'a, S: Into<VideoID<'a>>>(
&self,
video_id: S,
) -> Result<WatchPlaylist>
Available on crate feature simplified-queries only.
pub async fn get_watch_playlist_from_video_id<'a, S: Into<VideoID<'a>>>( &self, video_id: S, ) -> Result<WatchPlaylist>
simplified-queries only.Gets the information that’s available when playing a song or playlist; upcoming tracks and lyrics.
§Partially implemented
Tracks are not implemented - empty vector always returned.
See GetWatchPlaylistQuery and YtMusic.query()
for more ways to construct and run
a GetWatchPlaylistQuery.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_songs("While My Guitar Gently Weeps").await.unwrap();
yt.get_watch_playlist_from_video_id(&results[0].video_id).awaitSourcepub async fn get_lyrics<'a, T: Into<LyricsID<'a>>>(
&self,
lyrics_id: T,
) -> Result<Lyrics>
Available on crate feature simplified-queries only.
pub async fn get_lyrics<'a, T: Into<LyricsID<'a>>>( &self, lyrics_id: T, ) -> Result<Lyrics>
simplified-queries only.Gets song lyrics and the source.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_songs("While My Guitar Gently Weeps").await.unwrap();
let watch_playlist = yt.get_watch_playlist_from_video_id(&results[0].video_id).await.unwrap();
yt.get_lyrics(watch_playlist.lyrics_id).awaitSourcepub async fn get_playlist<'a, T: Into<PlaylistID<'a>>>(
&self,
playlist_id: T,
) -> Result<GetPlaylist>
Available on crate feature simplified-queries only.
pub async fn get_playlist<'a, T: Into<PlaylistID<'a>>>( &self, playlist_id: T, ) -> Result<GetPlaylist>
simplified-queries only.Gets information about a playlist and its tracks.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_featured_playlists("Heavy metal").await.unwrap();
yt.get_playlist(&results[0].playlist_id).awaitSourcepub async fn get_search_suggestions<'a, S: Into<GetSearchSuggestionsQuery<'a>>>(
&self,
query: S,
) -> Result<Vec<SearchSuggestion>>
Available on crate feature simplified-queries only.
pub async fn get_search_suggestions<'a, S: Into<GetSearchSuggestionsQuery<'a>>>( &self, query: S, ) -> Result<Vec<SearchSuggestion>>
simplified-queries only.Gets search suggestions
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_search_suggestions("The Beat").await;Sourcepub async fn get_library_playlists(&self) -> Result<GetLibraryPlaylists>
Available on crate feature simplified-queries only.
pub async fn get_library_playlists(&self) -> Result<GetLibraryPlaylists>
simplified-queries only.Gets a list of all playlists in your Library.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_library_playlists().await;Sourcepub async fn get_library_artists(&self) -> Result<GetLibraryArtists>
Available on crate feature simplified-queries only.
pub async fn get_library_artists(&self) -> Result<GetLibraryArtists>
simplified-queries only.Gets a list of all artists in your Library.
§Additional functionality
See GetLibraryArtistsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_library_artists().await;Sourcepub async fn get_library_songs(
&self,
) -> Result<<GetLibrarySongsQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_library_songs( &self, ) -> Result<<GetLibrarySongsQuery as Query<A>>::Output>
simplified-queries only.Gets a list of all songs in your Library.
§Additional functionality
See GetLibrarySongsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_library_songs().await;Sourcepub async fn get_library_albums(&self) -> Result<GetLibraryAlbums>
Available on crate feature simplified-queries only.
pub async fn get_library_albums(&self) -> Result<GetLibraryAlbums>
simplified-queries only.Gets a list of all albums in your Library.
§Additional functionality
See GetLibraryAlbumsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_library_albums().await;Sourcepub async fn get_library_artist_subscriptions(
&self,
) -> Result<GetLibraryArtistSubscriptions>
Available on crate feature simplified-queries only.
pub async fn get_library_artist_subscriptions( &self, ) -> Result<GetLibraryArtistSubscriptions>
simplified-queries only.Gets a list of all artist subscriptions in your Library.
§Additional functionality
See GetLibraryArtistSubscriptionsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_library_artist_subscriptions().await;Sourcepub async fn get_history(&self) -> Result<Vec<HistoryPeriod>>
Available on crate feature simplified-queries only.
pub async fn get_history(&self) -> Result<Vec<HistoryPeriod>>
simplified-queries only.Gets your recently played history.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_history().await;Sourcepub async fn remove_history_items(
&self,
feedback_tokens: Vec<FeedbackTokenRemoveFromHistory<'_>>,
) -> Result<Vec<ApiOutcome>>
Available on crate feature simplified-queries only.
pub async fn remove_history_items( &self, feedback_tokens: Vec<FeedbackTokenRemoveFromHistory<'_>>, ) -> Result<Vec<ApiOutcome>>
simplified-queries only.Removes a list of items from your recently played history.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let history = yt.get_history().await.unwrap();
let first_history_token = match history.first().unwrap().items.first().unwrap() {
ytmapi_rs::parse::HistoryItem::Song(i) => &i.feedback_token_remove,
ytmapi_rs::parse::HistoryItem::Video(i) => &i.feedback_token_remove,
ytmapi_rs::parse::HistoryItem::Episode(i) => &i.feedback_token_remove,
ytmapi_rs::parse::HistoryItem::UploadSong(i) => &i.feedback_token_remove,
}.into();
yt.remove_history_items(vec![first_history_token]).awaitpub async fn edit_song_library_status( &self, query: EditSongLibraryStatusQuery<'_>, ) -> Result<Vec<ApiOutcome>>
simplified-queries only.Sourcepub async fn rate_song<'a, T: Into<VideoID<'a>>>(
&self,
video_id: T,
rating: LikeStatus,
) -> Result<()>
Available on crate feature simplified-queries only.
pub async fn rate_song<'a, T: Into<VideoID<'a>>>( &self, video_id: T, rating: LikeStatus, ) -> Result<()>
simplified-queries only.Sets the like status for a song.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_songs("While My Guitar Gently Weeps").await.unwrap();
yt.rate_song(&results[0].video_id, ytmapi_rs::common::LikeStatus::Liked).awaitSourcepub async fn rate_playlist<'a, T: Into<PlaylistID<'a>>>(
&self,
playlist_id: T,
rating: LikeStatus,
) -> Result<()>
Available on crate feature simplified-queries only.
pub async fn rate_playlist<'a, T: Into<PlaylistID<'a>>>( &self, playlist_id: T, rating: LikeStatus, ) -> Result<()>
simplified-queries only.Sets the like status for a playlist. A ‘Liked’ playlist will be added to your library, an ‘Indifferent’ will be removed, and a ‘Disliked’ will reduce the chance of it appearing in your recommendations.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.search_featured_playlists("Heavy metal")
.await
.unwrap();
yt.rate_playlist(
&results[0].playlist_id,
ytmapi_rs::common::LikeStatus::Liked,
).awaitSourcepub async fn delete_playlist<'a, T: Into<PlaylistID<'a>>>(
&self,
playlist_id: T,
) -> Result<()>
Available on crate feature simplified-queries only.
pub async fn delete_playlist<'a, T: Into<PlaylistID<'a>>>( &self, playlist_id: T, ) -> Result<()>
simplified-queries only.Deletes a playlist you own.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_library_playlists().await.unwrap();
yt.delete_playlist(&results.playlists[0].playlist_id).awaitSourcepub async fn create_playlist<T: CreatePlaylistType>(
&self,
query: CreatePlaylistQuery<'_, T>,
) -> Result<PlaylistID<'static>>
Available on crate feature simplified-queries only.
pub async fn create_playlist<T: CreatePlaylistType>( &self, query: CreatePlaylistQuery<'_, T>, ) -> Result<PlaylistID<'static>>
simplified-queries only.Creates a new playlist.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let playlists = yt.search_featured_playlists("Heavy metal")
.await
.unwrap();
let query = ytmapi_rs::query::CreatePlaylistQuery::new(
"My heavy metal playlist",
None,
ytmapi_rs::query::PrivacyStatus::Public,
)
.with_source(&playlists[0].playlist_id);
yt.create_playlist(query).awaitSourcepub async fn add_video_items_to_playlist<'a, T: Into<PlaylistID<'a>>>(
&self,
playlist_id: T,
video_ids: Vec<VideoID<'a>>,
) -> Result<Vec<AddPlaylistItem>>
Available on crate feature simplified-queries only.
pub async fn add_video_items_to_playlist<'a, T: Into<PlaylistID<'a>>>( &self, playlist_id: T, video_ids: Vec<VideoID<'a>>, ) -> Result<Vec<AddPlaylistItem>>
simplified-queries only.Adds video items to a playlist you own.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let ytmapi_rs::parse::LibraryPlaylist { playlist_id, .. } =
yt.get_library_playlists().await.unwrap().playlists.pop().unwrap();
let songs = yt.search_songs("Master of puppets").await.unwrap();
yt.add_video_items_to_playlist(
playlist_id,
songs.iter().map(|s| (&s.video_id).into()).collect()
).awaitSourcepub async fn add_playlist_to_playlist<'a, T: Into<PlaylistID<'a>>, U: Into<PlaylistID<'a>>>(
&self,
destination_playlist: T,
source_playlist: U,
) -> Result<Vec<AddPlaylistItem>>
Available on crate feature simplified-queries only.
pub async fn add_playlist_to_playlist<'a, T: Into<PlaylistID<'a>>, U: Into<PlaylistID<'a>>>( &self, destination_playlist: T, source_playlist: U, ) -> Result<Vec<AddPlaylistItem>>
simplified-queries only.Appends another playlist to a playlist you own.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let ytmapi_rs::parse::LibraryPlaylist { playlist_id, .. } =
yt.get_library_playlists().await.unwrap().playlists.pop().unwrap();
let source_playlist = yt.search_featured_playlists("Heavy metal")
.await
.unwrap();
yt.add_playlist_to_playlist(
playlist_id,
&source_playlist[0].playlist_id
).awaitSourcepub async fn remove_playlist_items<'a, T: Into<PlaylistID<'a>>>(
&self,
playlist_id: T,
video_items: Vec<SetVideoID<'a>>,
) -> Result<()>
Available on crate feature simplified-queries only.
pub async fn remove_playlist_items<'a, T: Into<PlaylistID<'a>>>( &self, playlist_id: T, video_items: Vec<SetVideoID<'a>>, ) -> Result<()>
simplified-queries only.Removes items from a playlist you own.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let ytmapi_rs::parse::LibraryPlaylist { playlist_id, .. } =
yt.get_library_playlists().await.unwrap().playlists.pop().unwrap();
let source_playlist = yt.search_featured_playlists("Heavy metal")
.await
.unwrap();
let outcome = yt.add_playlist_to_playlist(
&playlist_id,
&source_playlist[0].playlist_id
).await.unwrap();
yt.remove_playlist_items(
playlist_id,
outcome.iter().map(|o| (&o.set_video_id).into()).collect(),
).awaitSourcepub async fn edit_playlist(
&self,
query: EditPlaylistQuery<'_>,
) -> Result<ApiOutcome>
Available on crate feature simplified-queries only.
pub async fn edit_playlist( &self, query: EditPlaylistQuery<'_>, ) -> Result<ApiOutcome>
simplified-queries only.Makes changes to a playlist.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let playlists = yt.get_library_playlists()
.await
.unwrap()
.playlists;
let query = ytmapi_rs::query::EditPlaylistQuery::new_title(
&playlists[0].playlist_id,
"Better playlist title",
)
.with_new_description("Edited description");
yt.edit_playlist(query).awaitSourcepub async fn get_library_upload_songs(
&self,
) -> Result<<GetLibraryUploadSongsQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_library_upload_songs( &self, ) -> Result<<GetLibraryUploadSongsQuery as Query<A>>::Output>
simplified-queries only.Gets a list of all uploaded songs in your Library.
§Additional functionality
See GetLibraryUploadSongsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_library_upload_songs().awaitSourcepub async fn get_library_upload_artists(
&self,
) -> Result<<GetLibraryUploadArtistsQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_library_upload_artists( &self, ) -> Result<<GetLibraryUploadArtistsQuery as Query<A>>::Output>
simplified-queries only.Gets a list of all uploaded artists in your Library.
§Additional functionality
See GetLibraryUploadArtistsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_library_upload_artists().awaitSourcepub async fn get_library_upload_albums(
&self,
) -> Result<<GetLibraryUploadAlbumsQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_library_upload_albums( &self, ) -> Result<<GetLibraryUploadAlbumsQuery as Query<A>>::Output>
simplified-queries only.Gets a list of all uploaded albums in your Library.
§Additional functionality
See GetLibraryUploadAlbumsQuery and YtMusic.query()
for more ways to construct and run.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_library_upload_albums().awaitSourcepub async fn get_library_upload_album<'a, T: Into<UploadAlbumID<'a>>>(
&self,
upload_album_id: T,
) -> Result<<GetLibraryUploadAlbumQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_library_upload_album<'a, T: Into<UploadAlbumID<'a>>>( &self, upload_album_id: T, ) -> Result<<GetLibraryUploadAlbumQuery<'_> as Query<A>>::Output>
simplified-queries only.Gets information and tracks for an uploaded album in your Library.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let albums = yt.get_library_upload_albums().await.unwrap();
yt.get_library_upload_album(&albums[0].album_id).awaitSourcepub async fn get_library_upload_artist<'a, T: Into<UploadArtistID<'a>>>(
&self,
upload_artist_id: T,
) -> Result<<GetLibraryUploadArtistQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_library_upload_artist<'a, T: Into<UploadArtistID<'a>>>( &self, upload_artist_id: T, ) -> Result<<GetLibraryUploadArtistQuery<'_> as Query<A>>::Output>
simplified-queries only.Gets all tracks for an uploaded artist in your Library.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let artists = yt.get_library_upload_artists().await.unwrap();
yt.get_library_upload_artist(&artists[0].artist_id).awaitSourcepub async fn delete_upload_entity<'a, T: Into<UploadEntityID<'a>>>(
&self,
upload_entity_id: T,
) -> Result<<DeleteUploadEntityQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn delete_upload_entity<'a, T: Into<UploadEntityID<'a>>>( &self, upload_entity_id: T, ) -> Result<<DeleteUploadEntityQuery<'_> as Query<A>>::Output>
simplified-queries only.Deletes an upload entity from your library - this is either a song or an album.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let albums = yt.get_library_upload_albums().await.unwrap();
yt.delete_upload_entity(&albums[0].entity_id).awaitSourcepub async fn get_taste_profile(
&self,
) -> Result<<GetTasteProfileQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_taste_profile( &self, ) -> Result<<GetTasteProfileQuery as Query<A>>::Output>
simplified-queries only.Fetches suggested artists from taste profile https://music.youtube.com/tasteprofile. Tasteprofile allows users to pick artists to update their recommendations.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_taste_profile().awaitSourcepub async fn set_taste_profile<'a, I, II>(
&self,
taste_tokens: II,
) -> Result<<SetTasteProfileQuery<'a, I> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn set_taste_profile<'a, I, II>( &self, taste_tokens: II, ) -> Result<<SetTasteProfileQuery<'a, I> as Query<A>>::Output>
simplified-queries only.Sets artists as favourites to influence your recommendations.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_taste_profile().await.unwrap();
yt.set_taste_profile(results.into_iter()
.take(5)
.map(|r| r.taste_tokens))
.awaitSourcepub async fn get_mood_categories(
&self,
) -> Result<<GetMoodCategoriesQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_mood_categories( &self, ) -> Result<<GetMoodCategoriesQuery as Query<A>>::Output>
simplified-queries only.Fetches ‘Moods & Genres’ categories.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_mood_categories().awaitSourcepub async fn get_mood_playlists<'a, T: Into<MoodCategoryParams<'a>>>(
&self,
mood_params: T,
) -> Result<<GetMoodPlaylistsQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_mood_playlists<'a, T: Into<MoodCategoryParams<'a>>>( &self, mood_params: T, ) -> Result<<GetMoodPlaylistsQuery<'_> as Query<A>>::Output>
simplified-queries only.Returns a list of playlists for a given mood category.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let results = yt.get_mood_categories().await.unwrap();
yt.get_mood_playlists(&results[0].mood_categories[0].params).awaitSourcepub async fn get_song_tracking_url<'a, T: Into<VideoID<'a>>>(
&self,
video_id: T,
) -> Result<SongTrackingUrl<'static>>
Available on crate feature simplified-queries only.
pub async fn get_song_tracking_url<'a, T: Into<VideoID<'a>>>( &self, video_id: T, ) -> Result<SongTrackingUrl<'static>>
simplified-queries only.Get the ‘SongTrackingUrl’ for a song. This is used to add items to
history using add_history_item().
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let song = yt.search_songs("While My Guitar Gently Weeps")
.await
.unwrap()
.into_iter()
.next()
.unwrap();
yt.get_song_tracking_url(song.video_id).awaitSourcepub async fn add_history_item<'a, T: Into<SongTrackingUrl<'a>>>(
&self,
song_url: T,
) -> Result<<AddHistoryItemQuery<'a> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn add_history_item<'a, T: Into<SongTrackingUrl<'a>>>( &self, song_url: T, ) -> Result<<AddHistoryItemQuery<'a> as Query<A>>::Output>
simplified-queries only.Adds an item to the accounts history.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let song = yt.search_songs("While My Guitar Gently Weeps")
.await
.unwrap()
.into_iter()
.next()
.unwrap();
let url = yt.get_song_tracking_url(song.video_id).await.unwrap();
yt.add_history_item(url).awaitSourcepub async fn get_channel(
&self,
channel_id: impl Into<PodcastChannelID<'_>>,
) -> Result<<GetChannelQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_channel( &self, channel_id: impl Into<PodcastChannelID<'_>>, ) -> Result<<GetChannelQuery<'_> as Query<A>>::Output>
simplified-queries only.Gets information about a Channel of Podcasts.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let podcasts = yt.search_podcasts("Rustacean").await.unwrap();
let podcast = yt.get_podcast(&podcasts[0].podcast_id).await.unwrap();
yt.get_channel(podcast.channels[0].id.as_ref().unwrap()).awaitSourcepub async fn get_channel_episodes<'a>(
&self,
channel_id: impl Into<PodcastChannelID<'a>>,
podcast_channel_params: impl Into<PodcastChannelParams<'a>>,
) -> Result<<GetChannelEpisodesQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_channel_episodes<'a>( &self, channel_id: impl Into<PodcastChannelID<'a>>, podcast_channel_params: impl Into<PodcastChannelParams<'a>>, ) -> Result<<GetChannelEpisodesQuery<'_> as Query<A>>::Output>
simplified-queries only.Gets a list of all Episodes for a Channel. Note, if GetPodcastChannel
doesn’t contain episode_params, you can be sure that all episodes are
already included at episodes key.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let podcasts = yt.search_podcasts("Rustacean").await.unwrap();
let podcast = yt.get_podcast(&podcasts[0].podcast_id).await.unwrap();
let channel_id = podcast.channels[0].id.as_ref().unwrap();
let channel = yt.get_channel(channel_id).await.unwrap();
match channel.episode_params {
Some(p) => yt.get_channel_episodes(channel_id, p).await,
None => Ok(channel.episodes),
}Sourcepub async fn get_podcast(
&self,
podcast_id: impl Into<PodcastID<'_>>,
) -> Result<<GetPodcastQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_podcast( &self, podcast_id: impl Into<PodcastID<'_>>, ) -> Result<<GetPodcastQuery<'_> as Query<A>>::Output>
simplified-queries only.Gets information about a Podcast, including Episodes.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let podcasts = yt.search_podcasts("Rustacean").await.unwrap();
yt.get_podcast(&podcasts[0].podcast_id).awaitSourcepub async fn get_episode(
&self,
episode_id: impl Into<EpisodeID<'_>>,
) -> Result<<GetEpisodeQuery<'_> as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_episode( &self, episode_id: impl Into<EpisodeID<'_>>, ) -> Result<<GetEpisodeQuery<'_> as Query<A>>::Output>
simplified-queries only.let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
let episodes = yt.search_episodes("Ratatui").await.unwrap();
yt.get_episode(&episodes[0].episode_id).awaitSourcepub async fn get_new_episodes(
&self,
) -> Result<<GetNewEpisodesQuery as Query<A>>::Output>
Available on crate feature simplified-queries only.
pub async fn get_new_episodes( &self, ) -> Result<<GetNewEpisodesQuery as Query<A>>::Output>
simplified-queries only.Gets the special ‘New Episodes’ playlist.
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await.unwrap();
yt.get_new_episodes().awaitSource§impl YtMusic<BrowserToken>
impl YtMusic<BrowserToken>
Sourcepub fn from_browser_token(token: BrowserToken) -> YtMusic<BrowserToken>
pub fn from_browser_token(token: BrowserToken) -> YtMusic<BrowserToken>
Create a new API handle using a BrowserToken. Utilises the default TLS option for the enabled features.
§Panics
This will panic in some situations - see https://docs.rs/reqwest/latest/reqwest/struct.Client.html#panics
Create a new API handle using a real browser authentication cookie saved to a file on disk. Utilises the default TLS option for the enabled features.
§Panics
This will panic in some situations - see https://docs.rs/reqwest/latest/reqwest/struct.Client.html#panics
Create a new API handle using a real browser authentication cookie in a String. Utilises the default TLS option for the enabled features.
§Panics
This will panic in some situations - see https://docs.rs/reqwest/latest/reqwest/struct.Client.html#panics
Source§impl YtMusic<OAuthToken>
impl YtMusic<OAuthToken>
Sourcepub fn from_oauth_token(token: OAuthToken) -> YtMusic<OAuthToken>
pub fn from_oauth_token(token: OAuthToken) -> YtMusic<OAuthToken>
Create a new API handle using an OAuthToken. Utilises the default TLS option for the enabled features.
§Panics
This will panic in some situations - see https://docs.rs/reqwest/latest/reqwest/struct.Client.html#panics
Sourcepub async fn refresh_token(&mut self) -> Result<OAuthToken>
pub async fn refresh_token(&mut self) -> Result<OAuthToken>
Refresh the internal oauth token, and return a clone of it (for user to store locally, e.g).
Sourcepub fn get_token_hash(&self) -> u64
pub fn get_token_hash(&self) -> u64
Get a hash of the internal oauth token, for use in comparison operations.
Source§impl<A: AuthToken> YtMusic<A>
impl<A: AuthToken> YtMusic<A>
Sourcepub async fn raw_query<'a, Q: Query<A>>(
&self,
query: &'a Q,
) -> Result<RawResult<'a, Q, A>>
pub async fn raw_query<'a, Q: Query<A>>( &self, query: &'a Q, ) -> Result<RawResult<'a, Q, A>>
Return a raw result from YouTube music for query Q that requires further processing.
§Note
The returned raw result will hold a reference to the query it was called with. Therefore, passing an owned value is not permitted.
§Usage
use ytmapi_rs::auth::BrowserToken;
use ytmapi_rs::parse::ParseFrom;
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await?;
let query =
ytmapi_rs::query::SearchQuery::new("Beatles").with_filter(ytmapi_rs::query::ArtistsFilter);
let raw_result = yt.raw_query(&query).await?;
let result: Vec<ytmapi_rs::parse::SearchResultArtist> =
ParseFrom::parse_from(raw_result.process()?)?;
assert_eq!(result[0].artist, "The Beatles");Sourcepub async fn processed_query<'a, Q: Query<A>>(
&self,
query: &'a Q,
) -> Result<ProcessedResult<'a, Q>>
pub async fn processed_query<'a, Q: Query<A>>( &self, query: &'a Q, ) -> Result<ProcessedResult<'a, Q>>
Return a result from YouTube music that has had errors removed and been processed into parsable JSON.
§Note
The returned raw result will hold a reference to the query it was called with. Therefore, passing an owned value is not permitted.
§Usage
use ytmapi_rs::auth::BrowserToken;
use ytmapi_rs::parse::ParseFrom;
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await?;
let query =
ytmapi_rs::query::SearchQuery::new("Beatles").with_filter(ytmapi_rs::query::ArtistsFilter);
let processed_result = yt.processed_query(&query).await?;
let result: Vec<ytmapi_rs::parse::SearchResultArtist> =
ParseFrom::parse_from(processed_result)?;
assert_eq!(result[0].artist, "The Beatles");Sourcepub async fn json_query<Q: Query<A>>(
&self,
query: impl Borrow<Q>,
) -> Result<String>
pub async fn json_query<Q: Query<A>>( &self, query: impl Borrow<Q>, ) -> Result<String>
Return the raw JSON returned by YouTube music for Query Q. Return a result from YouTube music that has had errors removed and been processed into parsable JSON.
§Usage
let yt = ytmapi_rs::YtMusic::from_cookie("FAKE COOKIE").await?;
let query =
ytmapi_rs::query::SearchQuery::new("Beatles").with_filter(ytmapi_rs::query::ArtistsFilter);
let json_string = yt.json_query(query).await?;
assert!(serde_json::from_str::<serde_json::Value>(&json_string).is_ok());Sourcepub async fn query<Q: Query<A>>(
&self,
query: impl Borrow<Q>,
) -> Result<Q::Output>
pub async fn query<Q: Query<A>>( &self, query: impl Borrow<Q>, ) -> Result<Q::Output>
Return a result from YouTube music that has had errors removed and been processed into parsable JSON.
§Usage
let yt = ytmapi_rs::YtMusic::from_cookie("").await?;
let query =
ytmapi_rs::query::SearchQuery::new("Beatles").with_filter(ytmapi_rs::query::ArtistsFilter);
let result = yt.query(query).await?;
assert_eq!(result[0].artist, "The Beatles");Sourcepub fn stream<'a, Q>(
&'a self,
query: &'a Q,
) -> impl Stream<Item = Result<Q::Output>> + 'a
pub fn stream<'a, Q>( &'a self, query: &'a Q, ) -> impl Stream<Item = Result<Q::Output>> + 'a
Stream a query that has ‘continuations’, i.e can continue to stream results.
§Return type lifetime notes
The returned Impl Stream is tied to the lifetime of self, since it’s self’s client that will emit the results. It’s also tied to the lifetime of query, but ideally it could take either owned or borrowed query.
§Usage
use futures::stream::TryStreamExt;
let yt = ytmapi_rs::YtMusic::from_cookie("").await?;
let query = ytmapi_rs::query::GetLibrarySongsQuery::default();
let results = yt.stream(&query).try_collect::<Vec<_>>().await?;Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for YtMusic<A>where
A: Freeze,
impl<A> !RefUnwindSafe for YtMusic<A>
impl<A> Send for YtMusic<A>where
A: Send,
impl<A> Sync for YtMusic<A>where
A: Sync,
impl<A> Unpin for YtMusic<A>where
A: Unpin,
impl<A> !UnwindSafe for YtMusic<A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more