### Setup Functions Source: https://ytmusicapi.readthedocs.io/en/stable/_sources/reference/setup.rst.txt Provides documentation for the `setup` and `setup_oauth` functions within the ytmusicapi library. ```APIDOC ## Setup Functions ### Description This section documents the core setup functions for the ytmusicapi library. ### Functions - `setup()`: Configures the YT Music API client. - `setup_oauth()`: Configures the YT Music API client using OAuth credentials. ### See Also - :doc:`../setup/index` ``` -------------------------------- ### Account Information Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/library.html An example of the expected JSON response when retrieving account information. ```json { "accountName": "Sample User", "channelHandle": "@SampleUser" "accountPhotoUrl": "https://yt3.ggpht.com/sample-user-photo" } ``` -------------------------------- ### ytmusicapi.setup.setup Source: https://ytmusicapi.readthedocs.io/ Performs setup operations in the ytmusicapi library. ```APIDOC ## ytmusicapi.setup.setup ### Description Performs setup operations. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### Get Song Related Content Example Output Source: https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html An example of the JSON response structure for related song content, including similar songs, playlists, and artists. ```json [ { "title": "You might also like", "contents": [ { "title": "High And Dry", "videoId": "7fv84nPfTH0", "artists": [{ "name": "Radiohead", "id": "UCr_iyUANcn9OX_yy9piYoLw" }], "thumbnails": [ { "url": "https://lh3.googleusercontent.com/TWWT47cHLv3yAugk4h9eOzQ46FHmXc_g-KmBVy2d4sbg_F-Gv6xrPglztRVzp8D_l-yzOnvh-QToM8s=w60-h60-l90-rj", "width": 60, "height": 60 } ], "isExplicit": false, "album": { "name": "The Bends", "id": "MPREb_xsmDKhqhQrG" } } ] }, { "title": "Recommended playlists", "contents": [ { "title": "'90s Alternative Rock Hits", "playlistId": "RDCLAK5uy_m_h-nx7OCFaq9AlyXv78lG0AuloqW_NUA", "thumbnails": [...], "description": "Playlist • YouTube Music" } ] }, { "title": "Similar artists", "contents": [ { "title": "Noel Gallagher", "browseId": "UCu7yYcX_wIZgG9azR3PqrxA", "subscribers": "302K", "thumbnails": [...] } ] }, { "title": "Oasis", "contents": [ { "title": "Shakermaker", "year": "2014", "browseId": "MPREb_WNGQWp5czjD", "thumbnails": [...] } ] }, { "title": "About the artist", "contents": "Oasis were a rock band consisting of Liam Gallagher, Paul ... (full description shortened for documentation)" } ] ``` -------------------------------- ### Uploaded Album Structure Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/uploads.html Example structure for an uploaded album, including its tracks. ```json { "title": "18 Months", "type": "Album", "thumbnails": [...], "trackCount": 7, "duration": "24 minutes", "audioPlaylistId": "MLPRb_po_55chars", "tracks": [ { "entityId": "t_po_22chars", "videoId": "FVo-UZoPygI", "title": "Feel So Close", "duration": "4:15", "duration_seconds": 255, "artists": None, "album": { "name": "18 Months", "id": "FEmusic_library_privately_owned_release_detailb_po_55chars" }, "likeStatus": "INDIFFERENT", "thumbnails": None } ] } ``` -------------------------------- ### setup() Source: https://ytmusicapi.readthedocs.io/en/stable/reference/index.html Sets up the YTMusic API client, likely for authentication or configuration. ```APIDOC ## setup() ### Description Sets up the YTMusic API client, likely for authentication or configuration. ### Method setup ### Parameters This method does not explicitly list parameters in the source. Refer to the library's implementation for details on setup arguments. ``` -------------------------------- ### Get Watch Playlist Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Demonstrates the structure of the watch playlist data returned by the get_watch_playlist method. This includes track details, playlist ID, and lyrics token. Note that the 'INDIFFERENT' likeStatus may be ambiguous. ```json { "tracks": [ { "videoId": "9mWr4c_ig54", "title": "Foolish Of Me (feat. Jonathan Mendelsohn)", "length": "3:07", "thumbnail": [ { "url": "https://lh3.googleusercontent.com/ulK2YaLtOW0PzcN7ufltG6e4ae3WZ9Bvg8CCwhe6LOccu1lCKxJy2r5AsYrsHeMBSLrGJCNpJqXgwczk=w60-h60-l90-rj", "width": 60, "height": 60 }... ], "inLibrary": false, "feedbackTokens": { "add": "AB9zfpIGg9XN4u2iJ...", "remove": "AB9zfpJdzWLcdZtC..." }, "pinnedToListenAgain": true, "listenAgainFeedbackTokens": { "pin": "AB9zfpK8kP5mQ7rT...", "unpin": "AB9zfpLy3L9vB2xN..." }, "likeStatus": "INDIFFERENT", "videoType": "MUSIC_VIDEO_TYPE_ATV", "artists": [ { "name": "Seven Lions", "id": "UCYd2yzYRx7b9FYnBSlbnknA" }, { "name": "Jason Ross", "id": "UCVCD9Iwnqn2ipN9JIF6B-nA" }, { "name": "Crystal Skies", "id": "UCTJZESxeZ0J_M7JXyFUVmvA" } ], "album": { "name": "Foolish Of Me", "id": "MPREb_C8aRK1qmsDJ" }, "year": "2020", "counterpart": { "videoId": "E0S4W34zFMA", "title": "Foolish Of Me [ABGT404] (feat. Jonathan Mendelsohn)", "length": "3:07", "thumbnail": [...], "feedbackTokens": null, "likeStatus": "LIKE", "artists": [ { "name": "Jason Ross", "id": null }, { "name": "Seven Lions", "id": null }, { "name": "Crystal Skies", "id": null } ], "views": "6.6K" } },... ], "playlistId": "RDAMVM4y33h81phKU", "lyrics": "MPLYt_HNNclO0Ddoc-17" } ``` -------------------------------- ### ytmusicapi.setup.main Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.html Entry point for the ytmusicapi setup process, handling command-line arguments. ```APIDOC ## ytmusicapi.setup.main ### Description This is the main entry point for the setup process. It parses command-line arguments and initiates the setup flow. ### Returns * ytmusicapi.auth.oauth.token.RefreshingToken | str - A RefreshingToken object or a configuration string. ``` -------------------------------- ### Example Headers for Browser Authentication Source: https://ytmusicapi.readthedocs.io/en/stable/_sources/setup/browser.rst.txt This is an example of the request headers that should be copied from your browser for authentication. Ensure all headers from 'accept: */*' to the end of the section are included. ```JSON { "accept": "*/*", "accept-language": "en,en-US;q=0.9,en;q=0.8", "content-type": "application/json", "cookie": "VISITOR_INFO1_LIVE=...; YSC=...; GPS=...; wide=...; SID=...; HSID=...; APISID=...; SAPISID=...; __Secure-3PAPISID=...; __Secure-3PSID=...; __Secure-3PAPISIDCC=...; __Secure-3PSIDCC=...; AEC=...; LOGIN_INFO=...; PREF=...; SIDCC=...", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" } ``` -------------------------------- ### Install ytmusicapi Source: https://ytmusicapi.readthedocs.io/en/stable/_sources/setup/index.rst.txt Use this command to install the ytmusicapi library via pip. ```bash pip install ytmusicapi ``` -------------------------------- ### Example Explore Data Structure Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html This is an example of the JSON structure returned by the get_explore() method, illustrating the different sections like new releases, top songs, moods, trending, and new videos. ```json { "new_releases": [ { "title": "Hangang", "type": "Album", "artists": [ { "id": "UCpo4SbqmPXpCVA5RFj-Gq5Q", "name": "Dept" } ], "browseId": "MPREb_rGl39ZNEl95", "audioPlaylistId": "OLAK5uy_mTZAp8a-agh1at-cVUGrwPhTJoM5GnKTk", "thumbnails": [...], "isExplicit": false } ], "top_songs": { "playlist": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI", "items": [ { "title": "Outside (Better Days)", "videoId": "oT79YlRtXDg", "playlistId": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI", "videoType": "MUSIC_VIDEO_TYPE_ATV", "artists": [ { "name": "MO3", "id": "UCdFt4Cvhr7Okaxo6hZg5K8g" }, { "name": "OG Bobby Billions", "id": "UCLusb4T2tW3gOpJS1fJ-A9g" } ], "thumbnails": [...], "isExplicit": true, "album": { "name": "Outside (Better Days)", "id": "MPREb_fX4Yv8frUNv" }, "rank": "1", "trend": "up" } ] }, "moods_and_genres": [ { "title": "Chill", "params": "ggMPOg1uXzVuc0dnZlhpV3Ba" } ], "top_episodes": [ { "title": "132. Lean Into Failure: How to Make Mistakes That Work | Think Fast, Talk Smart: Communication...", "description": "...", "duration": "25 min", "videoId": "xAEGaW2my7E", "browseId": "MPEDxAEGaW2my7E", "videoType": "MUSIC_VIDEO_TYPE_PODCAST_EPISODE", "date": "Mar 5, 2024", "thumbnails": [...], "podcast": { "id": "PLxq_lXOUlvQDUNyoBYLkN8aVt5yAwEtG9", "name": "Stanford Graduate School of Business" } } ], "trending": { "playlist": "VLOLAK5uy_kNWGJvgWVqlt5LsFDL9Sdluly4M8TvGkM", "items": [ { "title": "Permission to Dance", "videoId": "CuklIb9d3fI", "videoType": "MUSIC_VIDEO_TYPE_OMV", "playlistId": "OLAK5uy_kNWGJvgWVqlt5LsFDL9Sdluly4M8TvGkM", "artists": [ { "name": "BTS", "id": "UC9vrvNSL3xcWGSkV86REBSg" } ], "thumbnails": [...], "isExplicit": false, "views": "108M" }, { "title": "Stanford GSB Podcasts", "podcast": { "name": "Stanford GSB Podcasts", "id": "PLxq_lXOUlvQDUNyoBYLkN8aVt5yAwEtG9" }, "browseId": "MPEDxAEGaW2my7E", "videoId": "xAEGaW2my7E", "videoType": "MUSIC_VIDEO_TYPE_PODCAST_EPISODE", "playlistId": "OLAK5uy_kNWGJvgWVqlt5LsFDL9Sdluly4M8TvGkM", "date": "Mar 5, 2024", "thumbnails": [] } ] }, "new_videos": [ { "title": "EVERY CHANCE I GET (Official Music Video) (feat. Lil Baby & Lil Durk)", "videoId": "BTivsHlVcGU", "artists": [ { "name": "DJ Khaled", "id": "UC0Kgvj5t_c9EMWpEDWJuR1Q" } ], "playlistId": null, "thumbnails": [...], "views": "46M" } ] } ``` -------------------------------- ### Uploaded Artist Track Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/uploads.html Example structure for an uploaded track associated with an artist. ```json [ { "entityId": "t_po_CICr2crg7OWpchDKwoakAQ", "videoId": "Dtffhy8WJgw", "title": "Hold Me (Original Mix)", "artists": [ { "name": "Jakko", "id": "FEmusic_library_privately_owned_artist_detaila_po_CICr2crg7OWpchIFamFra28" } ], "album": null, "likeStatus": "LIKE", "thumbnails": [...] } ] ``` -------------------------------- ### Example Library Channels Response Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html This is an example of the JSON response structure when retrieving channels from the library. It includes channel identifiers, names, and subscriber counts. ```json [ { "browseId": "UCRFF8xw5dg9mL4r5ryFOtKw", "artist": "Jumpers Jump", "subscribers": "1.54M", "thumbnails": [...] }, { "browseId": "UCQ3f2_sO3NJyDkuCxCNSOVA", "artist": "BROWN BAG", "subscribers": "74.2K", "thumbnails": [...] } ] ``` -------------------------------- ### Basic Usage Example Source: https://ytmusicapi.readthedocs.io/en/stable/index.html Demonstrates creating a playlist, searching for a song, and adding it to the playlist using OAuth authentication. ```python from ytmusicapi import YTMusic yt = YTMusic('oauth.json') playlistId = yt.create_playlist('test', 'test description') search_results = yt.search('Oasis Wonderwall') yt.add_playlist_items(playlistId, [search_results[0]['videoId']]) ``` -------------------------------- ### YouTube Music Search Results Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Demonstrates the structure of search results when performing a default search with one result per category. This example includes various item types like videos, songs, albums, playlists, and artists. ```json [ { "category": "Top result", "resultType": "video", "videoId": "vU05Eksc_iM", "title": "Wonderwall", "artists": [ { "name": "Oasis", "id": "UCmMUZbaYdNH0bEd1PAlAqsA" } ], "views": "1.4M", "videoType": "MUSIC_VIDEO_TYPE_OMV", "duration": "4:38", "duration_seconds": 278 }, { "category": "Songs", "resultType": "song", "videoId": "ZrOKjDZOtkA", "title": "Wonderwall", "artists": [ { "name": "Oasis", "id": "UCmMUZbaYdNH0bEd1PAlAqsA" } ], "album": { "name": "(What's The Story) Morning Glory? (Remastered)", "id": "MPREb_9nqEki4ZDpp" }, "duration": "4:19", "duration_seconds": 259, "isExplicit": false, "inLibrary": false, "feedbackTokens": { "add": null, "remove": null }, "pinnedToListenAgain": false, "listenAgainFeedbackTokens": { "pin": null, "unpin": null } }, { "category": "Albums", "resultType": "album", "browseId": "MPREb_IInSY5QXXrW", "playlistId": "OLAK5uy_kunInnOpcKECWIBQGB0Qj6ZjquxDvfckg", "title": "(What's The Story) Morning Glory?", "type": "Album", "artist": "Oasis", "year": "1995", "isExplicit": false }, { "category": "Community playlists", "resultType": "playlist", "browseId": "VLPLK1PkWQlWtnNfovRdGWpKffO1Wdi2kvDx", "title": "Wonderwall - Oasis", "author": "Tate Henderson", "itemCount": "174" } , { "category": "Videos", "resultType": "video", "videoId": "bx1Bh8ZvH84", "title": "Wonderwall", "artists": [ { "name": "Oasis", "id": "UCmMUZbaYdNH0bEd1PAlAqsA" } ], "views": "386M", "duration": "4:38", "duration_seconds": 278 }, { "category": "Artists", "resultType": "artist", "browseId": "UCmMUZbaYdNH0bEd1PAlAqsA", "artist": "Oasis", "shuffleId": "RDAOkjHYJjL1a3xspEyVkhHAsg", "radioId": "RDEMkjHYJjL1a3xspEyVkhHAsg" }, { "category": "Profiles", "resultType": "profile", "title": "Taylor Swift Time", "name": "@TaylorSwiftTime", "browseId": "UCSCRK7XlVQ6fBdEl00kX6pQ", "thumbnails": ... } ] ``` -------------------------------- ### Uploaded Song Structure Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/uploads.html Illustrates the structure of a single uploaded song object returned by the API. ```json { "entityId": "t_po_CICr2crg7OWpchDpjPjrBA", "videoId": "Uise6RPKoek", "artists": [ { 'name': 'Coldplay', 'id': 'FEmusic_library_privately_owned_artist_detaila_po_CICr2crg7OWpchIIY29sZHBsYXk', } ], "title": "A Sky Full Of Stars", "album": "Ghost Stories", "likeStatus": "LIKE", "thumbnails": [...] } ``` -------------------------------- ### Browser Auth Source: https://ytmusicapi.readthedocs.io/en/stable/reference/index.html Functions for browser-based authentication setup. ```APIDOC ## Browser Auth Functions ### Description Functions for setting up and checking browser-based authentication. ### Functions - `is_browser()` - `setup_browser()` ``` -------------------------------- ### User Information Structure Source: https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html This is an example of the dictionary structure returned when retrieving a user's page information. ```json { "name": "4Tune - No Copyright Music", "videos": { "browseId": "UC44hbeRoCZVVMVg5z0FfIww", "results": [ { "title": "Epic Music Soundtracks 2019", "videoId": "bJonJjgS2mM", "playlistId": "RDAMVMbJonJjgS2mM", "thumbnails": [ { "url": "https://i.ytimg.com/vi/bJon...", "width": 800, "height": 450 } ], "views": "19K" } ] }, "playlists": { "browseId": "UC44hbeRoCZVVMVg5z0FfIww", "results": [ { "title": "♚ Machinimasound | Playlist", "playlistId": "PLRm766YvPiO9ZqkBuEzSTt6Bk4eWIr3gB", "thumbnails": [ { "url": "https://i.ytimg.com/vi/...", "width": 400, "height": 225 } ] } ], "params": "6gO3AUNvWU..." } } ``` -------------------------------- ### Album Metadata Structure Source: https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html This is an example of the dictionary structure returned when retrieving album metadata. ```json { "title": "Revival", "type": "Album", "thumbnails": [], "description": "Revival is the...", "descriptionRuns": [ {"text": "Revival is the..."}, ], "artists": [ { "name": "Eminem", "id": "UCedvOgsKFzcK3hA5taf3KoQ" } ], "year": "2017", "trackCount": 19, "duration": "1 hour, 17 minutes", "audioPlaylistId": "OLAK5uy_nMr9h2VlS-2PULNz3M3XVXQj_P3C2bqaY", "tracks": [ { "videoId": "iKLU7z_xdYQ", "title": "Walk On Water (feat. Beyoncé)", "artists": [ { "name": "Eminem", "id": "UCedvOgsKFzcK3hA5taf3KoQ" } ], "album": "Revival", "likeStatus": "INDIFFERENT", "thumbnails": null, "isAvailable": true, "isExplicit": true, "duration": "5:03", "duration_seconds": 303, "trackNumber": 0, "inLibrary": false, "feedbackTokens": { "add": "AB9zfpK...", "remove": "AB9zfpK..." }, "pinnedToListenAgain": false, "listenAgainFeedbackTokens": { "pin": "AB9zfpJ...", "unpin": "AB9zfpL..." }, "creditsBrowseId": "MPTCiKLU7z_xdYQ" } ], "other_versions": [ { "title": "Revival", "year": "Eminem", "browseId": "MPREb_fefKFOTEZSp", "thumbnails": [...], "isExplicit": false }, ], "duration_seconds": 4657 } ``` -------------------------------- ### Song Playability Status Structure Source: https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html This is an example of the playability status structure returned for a song. ```json { "playabilityStatus": { "status": "OK", "playableInEmbed": true, "audioOnlyPlayability": { "audioOnlyPlayabilityRenderer": { "trackingParams": "CAEQx2kiEwiuv9X5i5H1AhWBvlUKHRoZAHk=" } } } } ``` -------------------------------- ### Get Album Browse ID Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Converts an audio playlist ID (starting with OLAK5uy_) into an album's browse ID (starting with MPREb_). This is helpful when you have a playlist ID and need to access album-specific functions. ```python ytmusic.get_album_browse_id('OLAK5uy_nMr9h2VlS-2PULNz3M3XVXQj_P3C2bqaY') ``` -------------------------------- ### Get Song Lyrics Source: https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html Retrieves lyrics for a song or video. Optionally returns lyrics with timestamps if available. Requires a browseId starting with 'MPLYt...' obtained from get_watch_playlist. ```python from ytmusicapi import YTMusic # Example usage: ytmusic = YTMusic() lyrics = ytmusic.get_lyrics("MPLYt_some_lyrics_id") print(lyrics) # With timestamps: timed_lyrics = ytmusic.get_lyrics("MPLYt_some_lyrics_id", timestamps=True) print(timed_lyrics) ``` -------------------------------- ### ytmusicapi.setup.setup Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.html Requests browser headers from the user and returns a configuration string for YTMusic. ```APIDOC ## ytmusicapi.setup.setup ### Description Requests browser headers from the user via the command line and returns a string that can be passed to the YTMusic() constructor. Optionally saves headers to a file. ### Parameters * **filepath** (Optional[str]) - Optional filepath to store headers to. * **headers_raw** (Optional[str]) - Optional request headers copied from browser. Otherwise requested from terminal. ### Returns * str - Configuration headers string. ``` -------------------------------- ### Get Watch Playlist Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/watch.html Retrieves a watch playlist for a given video or playlist. This is the playlist that appears when a track is played in YouTube Music. The `likeStatus` may be `INDIFFERENT` or `DISLIKE` due to ambiguous data. ```python from ytmusicapi import YTMusic # Example usage with a videoId watch_playlist_video = YTMusic().get_watch_playlist(videoId="9mWr4c_ig54") # Example usage with a playlistId watch_playlist_playlist = YTMusic().get_watch_playlist(playlistId="PLx0svrj2ksPo4_f-f-f-f-f-f-f-f-f-f") # Example usage with radio=True watch_playlist_radio = YTMusic().get_watch_playlist(videoId="9mWr4c_ig54", radio=True) # Example usage with shuffle=True (only works with playlistId) watch_playlist_shuffle = YTMusic().get_watch_playlist(playlistId="PLx0svrj2ksPo4_f-f-f-f-f-f-f-f-f-f", shuffle=True) ``` -------------------------------- ### ytmusicapi.setup() Source: https://ytmusicapi.readthedocs.io/en/stable/reference/setup.html Requests browser headers from the user via command line and returns a string that can be passed to YTMusic(). Optionally, headers can be stored to a file. ```APIDOC ## ytmusicapi.setup() ### Description Requests browser headers from the user via command line and returns a string that can be passed to YTMusic(). Optionally, headers can be stored to a file. ### Method `setup(_filepath: str | None = None_, _headers_raw: str | None = None_) -> str` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **filepath** (`Optional[str]`) – Optional filepath to store headers to. * **headers_raw** (`Optional[str]`) – Optional request headers copied from browser. Otherwise requested from terminal ### Return Type `str` ### Returns configuration headers string ``` -------------------------------- ### ytmusicapi.setup.setup_oauth Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.html Initiates the OAuth flow from the terminal and returns a configuration string for YTMusic. ```APIDOC ## ytmusicapi.setup.setup_oauth ### Description Starts the OAuth flow from the terminal and returns a string that can be passed to the YTMusic() constructor. Allows specifying client ID, client secret, session, proxies, and file path for storing tokens. Can optionally open the default browser. ### Parameters * **client_id** (str) - Optional. Used to specify the client_id oauth should use for authentication flow. If provided, client_secret MUST also be passed or both will be ignored. * **client_secret** (str) - Optional. Same as client_id but for the oauth client secret. * **filepath** (Optional[str]) - Optional filepath to store headers to. * **session** (Optional[requests.sessions.Session]) - Session to use for authentication. * **proxies** (Optional[dict[str, str]]) - Proxies to use for authentication. * **open_browser** (bool) - If True, open the default browser with the setup link. ### Returns * ytmusicapi.auth.oauth.token.RefreshingToken - The RefreshingToken object obtained from the OAuth flow. ``` -------------------------------- ### setup_oauth() Source: https://ytmusicapi.readthedocs.io/en/stable/reference/index.html Sets up the YTMusic API client for OAuth authentication. ```APIDOC ## setup_oauth() ### Description Sets up the YTMusic API client for OAuth authentication. ### Method setup_oauth ### Parameters This method does not explicitly list parameters in the source. Refer to the library's implementation for details on OAuth setup arguments. ``` -------------------------------- ### ytmusicapi.setup.setup_oauth Source: https://ytmusicapi.readthedocs.io/ Sets up OAuth authentication in the ytmusicapi library. ```APIDOC ## ytmusicapi.setup.setup_oauth ### Description Sets up OAuth authentication. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### ytmusicapi.setup Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/modules.html Functions for setting up and configuring the ytmusicapi library, including OAuth. ```APIDOC ## Module: ytmusicapi.setup ### Description Contains functions for setting up and configuring the ytmusicapi library, including handling command-line arguments and OAuth authentication. ### Functions - **main()** - Description: The main entry point for the setup process. - **parse_args()** - Description: Parses command-line arguments for setup. - **setup()** - Description: Performs the initial setup of the ytmusicapi library. - **setup_oauth()** - Description: Sets up OAuth credentials for authentication. ``` -------------------------------- ### Get Shuffle Playlist with ytmusicapi Source: https://ytmusicapi.readthedocs.io/en/stable/_sources/faq.rst.txt Use `get_watch_playlist_shuffle` with either `playlistId` or `audioPlaylistId` to get the shuffle playlist. ```python get_watch_playlist_shuffle ``` -------------------------------- ### User Information Example Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Shows the structure of the dictionary returned by get_user(), including user name, videos, and playlists with their respective browse IDs and results. ```json { "name": "4Tune - No Copyright Music", "videos": { "browseId": "UC44hbeRoCZVVMVg5z0FfIww", "results": [ { "title": "Epic Music Soundtracks 2019", "videoId": "bJonJjgS2mM", "playlistId": "RDAMVMbJonJjgS2mM", "thumbnails": [ { "url": "https://i.ytimg.com/vi/bJon...", "width": 800, "height": 450 } ], "views": "19K" } ] }, "playlists": { "browseId": "UC44hbeRoCZVVMVg5z0FfIww", "results": [ { "title": "♚ Machinimasound | Playlist", "playlistId": "PLRm766YvPiO9ZqkBuEzSTt6Bk4eWIr3gB", "thumbnails": [ { "url": "https://i.ytimg.com/vi/…", "width": 400, "height": 225 } ] } ], "params": "6gO3AUNvWU..." } } ``` -------------------------------- ### Get Mood Categories Source: https://ytmusicapi.readthedocs.io/en/stable/reference/explore.html Fetches "Moods & Genres" categories from YouTube Music. Use this to get parameters for `get_mood_playlists`. ```python ytmusic.get_mood_categories() ``` -------------------------------- ### ytmusicapi.setup_oauth() Source: https://ytmusicapi.readthedocs.io/en/stable/reference/setup.html Starts the OAuth flow from the terminal and returns a string that can be passed to YTMusic(). Supports specifying client ID, client secret, session, proxies, and an optional file path for storing headers. The browser can be opened automatically. ```APIDOC ## ytmusicapi.setup_oauth() ### Description Starts oauth flow from the terminal and returns a string that can be passed to YTMusic(). Supports specifying client ID, client secret, session, proxies, and an optional file path for storing headers. The browser can be opened automatically. ### Method `setup_oauth(_client_id: str_, _client_secret: str_, _filepath: str | None = None_, _session: requests.sessions.Session | None = None_, _proxies: dict[str, str] | None = None_, _open_browser: bool = False_) -> ytmusicapi.auth.oauth.token.RefreshingToken` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **client_id** (`str`) – Optional. Used to specify the client_id oauth should use for authentication flow. If provided, client_secret MUST also be passed or both will be ignored. * **client_secret** (`str`) – Optional. Same as client_id but for the oauth client secret. * **session** (`Optional[Session]`) – Session to use for authentication * **proxies** (`Optional[dict[str, str]]`) – Proxies to use for authentication * **filepath** (`Optional[str]`) – Optional filepath to store headers to. * **open_browser** (`bool`) – If True, open the default browser with the setup link ### Return Type `RefreshingToken` ### Returns configuration headers string ``` -------------------------------- ### ytmusicapi.setup.parse_args Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.html Parses a list of string arguments into a namespace object. ```APIDOC ## ytmusicapi.setup.parse_args ### Description Parses a list of string arguments, typically from the command line, into an argparse.Namespace object. ### Parameters * **_args** (list[str]) - A list of string arguments to parse. ### Returns * argparse.Namespace - The parsed arguments as a namespace object. ``` -------------------------------- ### Get Base JS URL in Python Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Retrieves the URL for the base.js script from YouTube Music. This is a utility function to get a necessary resource URL. ```python ytm.get_basejs_url() ``` -------------------------------- ### Get User Playlists and Videos Source: https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html Demonstrates how to retrieve a user's page and then fetch their playlists and videos using the returned parameters. ```python result = get_user(channelId) get_user_playlists(channelId, result["playlists"]["params"]) get_user_videos(channelId, result["videos"]["params"]) ``` -------------------------------- ### Get Playlist Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Fetches playlist items for a given playlist ID, with options to control the number of items returned, retrieve related playlists, and get suggested items. ```APIDOC ## get_playlist ### Description Returns a list of playlist items. ### Parameters #### Path Parameters - **playlistId** (str) - Playlist id #### Query Parameters - **limit** (Optional[int]) - How many songs to return. `None` retrieves them all. Default: 100 - **related** (bool) - Whether to fetch 10 related playlists or not. Default: False - **suggestions_limit** (int) - How many suggestions to return. The result is a list of suggested playlist items (videos) contained in a “suggestions” key. 7 items are retrieved in each internal request. Default: 0 ### Response #### Success Response (200) - **dict[str, Any]** - Playlist items ``` -------------------------------- ### Get Radio Playlist ID Format Source: https://ytmusicapi.readthedocs.io/en/stable/faq.html For songs and videos, prepend 'RDAMVM' to the videoId to get the radio playlist ID. For playlists and albums, prepend 'RDAMPL' to the playlistId. ```text RDAMVM + videoId ``` ```text RDAMPL + playlistId ``` -------------------------------- ### Setup Headers via Raw Input Source: https://ytmusicapi.readthedocs.io/en/stable/reference/setup.html Use this function to provide raw request headers directly as a string. This is useful if you have already copied headers and want to use them without terminal interaction. ```python ytmusicapi.setup(headers_raw="User-Agent: ...") ``` -------------------------------- ### Get Podcast Channel Information Source: https://ytmusicapi.readthedocs.io/en/stable/reference/podcasts.html Retrieves information about a podcast channel, including its metadata and a limited list of recent episodes. Use this to get a general overview of a channel and its latest content. ```python ytmusic.get_channel("UCGwuxdEeCf0TIA2RbPOj-8g") ``` -------------------------------- ### ytmusicapi.setup_oauth Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.html Starts the OAuth flow from the terminal and returns a string that can be passed to YTMusic(). This function facilitates obtaining authentication tokens for OAuth-based access. ```APIDOC ## Function ytmusicapi.setup_oauth Starts oauth flow from the terminal and returns a string that can be passed to YTMusic() ### Parameters * **client_id** (str) - Optional. Used to specify the client_id oauth should use for authentication flow. If provided, client_secret MUST also be passed or both will be ignored. * **client_secret** (str) - Optional. Same as client_id but for the oauth client secret. * **filepath** (Optional[str]) - Optional filepath to store headers to. * **session** (Optional[Session]) - Session to use for authentication. * **proxies** (Optional[dict[str, str]]) - Proxies to use for authentication. * **open_browser** (bool) - If True, open the default browser with the setup link. ### Return type `ytmusicapi.auth.oauth.token.RefreshingToken` ### Returns Configuration headers string. ``` -------------------------------- ### ytmusicapi.continuations.get_continuations Source: https://ytmusicapi.readthedocs.io/ Gets continuations from the ytmusicapi library. ```APIDOC ## ytmusicapi.continuations.get_continuations ### Description Gets continuations. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### Example Library Structure Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Illustrates the nested dictionary structure returned by library-related functions, showing categories, playlists, and song details. ```python { 'For you': [ { 'params': 'ggMPOg1uX1ZwN0pHT2NBT1Fk', 'title': '1980s' }, { 'params': 'ggMPOg1uXzZQbDB5eThLRTQ3', 'title': 'Feel Good' }, ... ], 'Genres': [ { 'params': 'ggMPOg1uXzVLbmZnaWI4STNs', 'title': 'Dance & Electronic' }, { 'params': 'ggMPOg1uX3NjZllsNGVEMkZo', 'title': 'Decades' }, ... ], 'Moods & moments': [ { 'params': 'ggMPOg1uXzVuc0dnZlhpV3Ba', 'title': 'Chill' }, { 'params': 'ggMPOg1uX2ozUHlwbWM3ajNq', 'title': 'Commute' }, ... ], } ``` -------------------------------- ### Example Song Credits Data Structure Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Illustrates the expected JSON structure for song credits, showing how different roles like 'performed_by', 'written_by', and 'produced_by' are organized, along with any 'other_sections'. ```json { "performed_by": { "localized_title": "Performed by" "data": [ "Eminem", "Beyoncé" ] }, "written_by": { "localized_title": "Written by", "data": [ "Marshall Mathers", "Beyoncé Knowles", "Holly Hafermann" ] }, "produced_by": { "localized_title": "Produced by", "data": [ "Rick Rubin" ] }, "music_metadata_provided_by": { "localized_title": "Music metadata provided by" "data": [ "Eminem Catalog PS" ] }, "other_sections": [ { "localized_title": "Piano", "data": [ "Skylar Grey" ] } ] } ``` -------------------------------- ### Get User Information and Playlists/Videos Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.mixins.html Retrieves a user's basic information and demonstrates how to subsequently fetch their playlists and videos using the provided parameters. ```python result = get_user(channelId) get_user_playlists(channelId, result["playlists"]["params"]) get_user_videos(channelId, result["videos"]["params"]) ``` -------------------------------- ### ytmusicapi.continuations.get_validated_continuations Source: https://ytmusicapi.readthedocs.io/ Gets validated continuations from the ytmusicapi library. ```APIDOC ## ytmusicapi.continuations.get_validated_continuations ### Description Gets validated continuations. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### ytmusicapi.continuations.get_reloadable_continuations Source: https://ytmusicapi.readthedocs.io/ Gets reloadable continuations from the ytmusicapi library. ```APIDOC ## ytmusicapi.continuations.get_reloadable_continuations ### Description Gets reloadable continuations. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### ytmusicapi.auth.browser.setup_browser Source: https://ytmusicapi.readthedocs.io/en/stable/reference/api/ytmusicapi.auth.html Sets up browser authentication, optionally using a provided file path for credentials or raw header string. This function is crucial for initiating authenticated requests from a browser context. ```APIDOC ## setup_browser ### Description Sets up browser authentication. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters * **filepath** (str | None) - Optional - filepath to credentials * **headers_raw** (str | None) - Optional - raw headers string ### Response #### Success Response * **str** - A string representing the setup browser authentication. ### Response Example ```json "browser_auth_string" ``` ``` -------------------------------- ### ytmusicapi.continuations.get_continuation_token Source: https://ytmusicapi.readthedocs.io/ Gets a continuation token from the ytmusicapi library. ```APIDOC ## ytmusicapi.continuations.get_continuation_token ### Description Gets a continuation token. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### ytmusicapi.continuations.get_continuation_string Source: https://ytmusicapi.readthedocs.io/ Gets a continuation string from the ytmusicapi library. ```APIDOC ## ytmusicapi.continuations.get_continuation_string ### Description Gets a continuation string. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### Setup Headers via Terminal Input Source: https://ytmusicapi.readthedocs.io/en/stable/reference/setup.html Use this function to retrieve browser headers by pasting them into the terminal. Optionally, save the headers to a file. ```python ytmusicapi.setup(_filepath = "headers.json") ``` -------------------------------- ### ytmusicapi.continuations.get_continuation_params Source: https://ytmusicapi.readthedocs.io/ Gets continuation parameters from the ytmusicapi library. ```APIDOC ## ytmusicapi.continuations.get_continuation_params ### Description Gets continuation parameters. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ```