From a1c42784cff921c3c1f37dbbec94048c90c27d1b Mon Sep 17 00:00:00 2001 From: estefaniabarrosa Date: Sun, 5 Apr 2026 19:38:15 +0100 Subject: [PATCH] attempted Spotify API lab. Faced issues due to recent API changes (top tracks endpoint returning 403). Authentication works, but unable to complete exercise as expected. Code and debugging attempts included --- .cache | 1 + .ipynb_checkpoints/lab-apis-checkpoint.ipynb | 2098 ++++++++++++++++++ lab-apis.ipynb | 1680 +++++++++++++- 3 files changed, 3705 insertions(+), 74 deletions(-) create mode 100644 .cache create mode 100644 .ipynb_checkpoints/lab-apis-checkpoint.ipynb diff --git a/.cache b/.cache new file mode 100644 index 0000000..04b26bd --- /dev/null +++ b/.cache @@ -0,0 +1 @@ +{"access_token": "BQDNeptqi9wO-Y2JvH_PBHcmNJE18cdOdddYgnXyCvLs9-5c4eC7CZWLvKrk8-IlGG_RGcczM75qwaFiN06dbXkTvExu8J2N0R0wFwTesQPonhrU86GZvq8xtUvL17CJZ8LmKAhKDjmkBOWqKZRWg4cYOMKEz_JGA1mDmCkmK6YtuK5RB2ZxEzzyRaSJlFLYKSnrDJxF2Tz7H0Xz2BsJoAWGo0rs5CfORNlkPtqv7OJffE4R90gNDbM7IyE", "token_type": "Bearer", "expires_in": 3600, "scope": "user-top-read", "expires_at": 1775417444, "refresh_token": "AQDU48dIgUztRHNJRGhk4lDB89nDe2C2GtcShxRp8xA9v39ychaTDBJotwt9Gf7WzA2Z3z0W859lkJH7vy0gUr0yFK6bqnC4t_hyovtKxNrAvVqkZJyid6uFICwY-cuJiN0"} \ No newline at end of file diff --git a/.ipynb_checkpoints/lab-apis-checkpoint.ipynb b/.ipynb_checkpoints/lab-apis-checkpoint.ipynb new file mode 100644 index 0000000..d5fa476 --- /dev/null +++ b/.ipynb_checkpoints/lab-apis-checkpoint.ipynb @@ -0,0 +1,2098 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "27422808-8a16-4be1-897f-57b379af8991", + "metadata": {}, + "source": [ + "# Lab | APIs" + ] + }, + { + "cell_type": "markdown", + "id": "50f30950-3e31-499a-92ea-1535422c570b", + "metadata": {}, + "source": [ + "In order to use the `Spotify` API (`SpotiPy`), create an account in `Spotify` and follow [these](https://developer.spotify.com/documentation/general/guides/app-settings/) steps. " + ] + }, + { + "cell_type": "markdown", + "id": "a0479b95-6ca5-415e-b894-1f5cb17b055b", + "metadata": {}, + "source": [ + "## Authentication and initializing the API" + ] + }, + { + "cell_type": "markdown", + "id": "47d71611-c617-4972-a0c3-7090c24b399c", + "metadata": {}, + "source": [ + "Save your client ID and your client secret in your preferred way, and read it or load it into the following variables:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "319cfd4e-f6fb-4419-80e0-e3983cd25e43", + "metadata": {}, + "outputs": [], + "source": [ + "#CLIENT_ID = \"4109b2d9f5014671863bb2df1d1fbdd3\"\n", + "#CLIENT_SECRET = \"5cb719fae80c4191a9c0b288f51bfe50\"" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "04e12954-fd70-4311-88a5-fb7e2c29799c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: spotipy in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (2.26.0)\n", + "Requirement already satisfied: redis>=3.5.3 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from spotipy) (7.4.0)\n", + "Requirement already satisfied: requests>=2.25.0 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from spotipy) (2.32.5)\n", + "Requirement already satisfied: urllib3>=1.26.0 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from spotipy) (2.6.3)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from requests>=2.25.0->spotipy) (3.4.5)\n", + "Requirement already satisfied: idna<4,>=2.5 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from requests>=2.25.0->spotipy) (3.11)\n", + "Requirement already satisfied: certifi>=2017.4.17 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from requests>=2.25.0->spotipy) (2026.2.25)\n" + ] + } + ], + "source": [ + "# If you havent done so, install the spotipy wrapper\n", + "!pip install spotipy" + ] + }, + { + "cell_type": "markdown", + "id": "dc0e86da-8846-4207-84c3-cd20b9e01d0e", + "metadata": {}, + "source": [ + "Once you have done it, we will start initializing the API." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ea44c82a-5c07-4dbc-beb2-bba2601bb75e", + "metadata": {}, + "outputs": [], + "source": [ + "CLIENT_ID = \"48cd2d99fdcd4c83a81f77991a3f0b20\"\n", + "CLIENT_SECRET = \"8fe7bcd10d9441eb833e64b6ec0a1267\"" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "03034bc6-9858-412a-83b7-18abdc345d7e", + "metadata": {}, + "outputs": [], + "source": [ + "#import spotipy\n", + "#from spotipy.oauth2 import SpotifyClientCredentials\n", + "\n", + "#Initialize SpotiPy with user credentials\n", + "#sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=CLIENT_ID,client_secret=CLIENT_SECRET))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "0a7e7ee9-0c5b-4ca9-91f2-df45f7d68fa2", + "metadata": {}, + "outputs": [], + "source": [ + "import spotipy\n", + "from spotipy.oauth2 import SpotifyOAuth\n", + "\n", + "sp = spotipy.Spotify(auth_manager=SpotifyOAuth(\n", + " client_id=CLIENT_ID,\n", + " client_secret=CLIENT_SECRET,\n", + " redirect_uri=\"http://127.0.0.1:9090/callback\",\n", + " scope=\"user-top-read\"\n", + "))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "74355ee2-0200-4414-b10c-49252d079fe5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'display_name': 'Estefania Barrosa',\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/user/kon0cibdlep7kv3v50sh0ldt7'},\n", + " 'followers': {'href': None, 'total': 6},\n", + " 'href': 'https://api.spotify.com/v1/users/kon0cibdlep7kv3v50sh0ldt7',\n", + " 'id': 'kon0cibdlep7kv3v50sh0ldt7',\n", + " 'images': [{'height': 300,\n", + " 'url': 'https://i.scdn.co/image/ab6775700000ee858ef813e233964f52d41cff2d',\n", + " 'width': 300},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67757000003b828ef813e233964f52d41cff2d',\n", + " 'width': 64}],\n", + " 'type': 'user',\n", + " 'uri': 'spotify:user:kon0cibdlep7kv3v50sh0ldt7'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.current_user()" + ] + }, + { + "cell_type": "markdown", + "id": "8fed9628-08d7-4290-a4be-5527696b01c5", + "metadata": {}, + "source": [ + "## Using the search method" + ] + }, + { + "cell_type": "markdown", + "id": "6575a3c6-f25a-4905-b1f3-c0efd50dcc1e", + "metadata": {}, + "source": [ + "Now, let's use the search method by introducing a \"query\". For example, let's try searching for \"Lady Gaga\":" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "7772a1e0-9692-4d04-a590-76111a272d8d", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'tracks': {'href': 'https://api.spotify.com/v1/search?offset=0&limit=10&query=Lady%20Gaga&type=track',\n", + " 'limit': 10,\n", + " 'next': 'https://api.spotify.com/v1/search?offset=10&limit=10&query=Lady%20Gaga&type=track',\n", + " 'offset': 0,\n", + " 'previous': None,\n", + " 'total': 14,\n", + " 'items': [{'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'href': 'https://api.spotify.com/v1/albums/10FLjwfpbxLmW8c25Xyc2N',\n", + " 'id': '10FLjwfpbxLmW8c25Xyc2N',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b27382ea2e9e1858aa012c57cd45'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e0282ea2e9e1858aa012c57cd45'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000485182ea2e9e1858aa012c57cd45'}],\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'release_date': '2024-08-16',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 251667,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72409273'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2plbrEY59IikOBgBGLjaoe'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2plbrEY59IikOBgBGLjaoe',\n", + " 'id': '2plbrEY59IikOBgBGLjaoe',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2plbrEY59IikOBgBGLjaoe'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 294573,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70918596'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/0SiywuOBRcynK0uKGWdCnn'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/0SiywuOBRcynK0uKGWdCnn',\n", + " 'id': '0SiywuOBRcynK0uKGWdCnn',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Bad Romance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:0SiywuOBRcynK0uKGWdCnn'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 223398,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72412581'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2LHNTC9QZxsL3nWpt8iaSR'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Abracadabra',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2LHNTC9QZxsL3nWpt8iaSR'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m'},\n", + " 'href': 'https://api.spotify.com/v1/artists/6vWDO969PvNqNYHIOW5v0m',\n", + " 'id': '6vWDO969PvNqNYHIOW5v0m',\n", + " 'name': 'Beyoncé',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6vWDO969PvNqNYHIOW5v0m'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 220640,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905541'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/4TCL0qqKyqsMZml0G3M9IM'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/4TCL0qqKyqsMZml0G3M9IM',\n", + " 'id': '4TCL0qqKyqsMZml0G3M9IM',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Telephone',\n", + " 'track_number': 6,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:4TCL0qqKyqsMZml0G3M9IM'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 274213,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905526'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1HHeOs6zRdF8Ck58easiAY'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1HHeOs6zRdF8Ck58easiAY',\n", + " 'id': '1HHeOs6zRdF8Ck58easiAY',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Alejandro',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1HHeOs6zRdF8Ck58easiAY'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1qwlxZTNLe1jq3b0iidlue'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1qwlxZTNLe1jq3b0iidlue',\n", + " 'id': '1qwlxZTNLe1jq3b0iidlue',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e691217483df8798445c82e2'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e691217483df8798445c82e2'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e691217483df8798445c82e2'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame',\n", + " 'release_date': '2008-01-01',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 15,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1qwlxZTNLe1jq3b0iidlue'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 237200,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70824409'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1QV6tiMFM6fSOKOGLMHYYg'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'id': '1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Poker Face',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1QV6tiMFM6fSOKOGLMHYYg'},\n", + " {'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'id': '1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851d8a389abdf9cb2d03b85ff54'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'release_date': '2025-09-03',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 228518,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72407034'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/3NFs3XUduzBfvc5Bx1gmzh'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'id': '3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:3NFs3XUduzBfvc5Bx1gmzh'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'href': 'https://api.spotify.com/v1/albums/4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'id': '4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e2d156fdc691f57900134342'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e2d156fdc691f57900134342'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e2d156fdc691f57900134342'}],\n", + " 'is_playable': True,\n", + " 'name': 'A Star Is Born Soundtrack',\n", + " 'release_date': '2018-10-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 34,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 215733,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71813192'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2VxeLyX666F8uXCJ0dZF8B'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2VxeLyX666F8uXCJ0dZF8B',\n", + " 'id': '2VxeLyX666F8uXCJ0dZF8B',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Shallow',\n", + " 'track_number': 12,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2VxeLyX666F8uXCJ0dZF8B'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6LY3AerY6KNGOPsNPL63Kk',\n", + " 'id': '6LY3AerY6KNGOPsNPL63Kk',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273a5d31644260279be8d0c46c0'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02a5d31644260279be8d0c46c0'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851a5d31644260279be8d0c46c0'}],\n", + " 'is_playable': True,\n", + " 'name': 'Born This Way (International Special Edition Version)',\n", + " 'release_date': '2011-05-23',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 249066,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71104998'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/7F25roCtYi55JouckaayPC'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/7F25roCtYi55JouckaayPC',\n", + " 'id': '7F25roCtYi55JouckaayPC',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Judas',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:7F25roCtYi55JouckaayPC'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 251667,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72409273'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/7so0lgd0zP2Sbgs2d7a1SZ'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/7so0lgd0zP2Sbgs2d7a1SZ',\n", + " 'id': '7so0lgd0zP2Sbgs2d7a1SZ',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'track_number': 14,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:7so0lgd0zP2Sbgs2d7a1SZ'}]}}" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results = sp.search(q='Lady Gaga', limit=10)\n", + "results" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "edc14c95-474b-4e2a-aea3-bdfd0a205546", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['tracks'])" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results.keys() # We can see that we only have tracks" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "ad8ef934-1dbb-4008-ac8e-f5c29823fe6a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['href', 'limit', 'next', 'offset', 'previous', 'total', 'items'])" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"].keys() # Let's check the values" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "004b7814-4dd5-408e-b7ba-1da87f9250cb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/search?offset=0&limit=10&query=Lady%20Gaga&type=track'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"href\"] # Query we have searched " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "7285cedd-fbe1-47cf-98d5-a7fdc3e5c8b8", + "metadata": { + "scrolled": true, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 223398,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72412581'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2LHNTC9QZxsL3nWpt8iaSR'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Abracadabra',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2LHNTC9QZxsL3nWpt8iaSR'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/3edjzMAVB9RYRd4UcZBchx'},\n", + " 'href': 'https://api.spotify.com/v1/albums/3edjzMAVB9RYRd4UcZBchx',\n", + " 'id': '3edjzMAVB9RYRd4UcZBchx',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b5d4b4ed17ec86c4b3944af2'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b5d4b4ed17ec86c4b3944af2'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b5d4b4ed17ec86c4b3944af2'}],\n", + " 'is_playable': True,\n", + " 'name': 'A Star Is Born Soundtrack (Without Dialogue)',\n", + " 'release_date': '2018-10-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 19,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:3edjzMAVB9RYRd4UcZBchx'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 210200,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71813195'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2rbDhOo9Fh61Bbu23T2qCk'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2rbDhOo9Fh61Bbu23T2qCk',\n", + " 'id': '2rbDhOo9Fh61Bbu23T2qCk',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Always Remember Us This Way',\n", + " 'track_number': 9,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2rbDhOo9Fh61Bbu23T2qCk'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 294573,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70918596'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/0SiywuOBRcynK0uKGWdCnn'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/0SiywuOBRcynK0uKGWdCnn',\n", + " 'id': '0SiywuOBRcynK0uKGWdCnn',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Bad Romance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:0SiywuOBRcynK0uKGWdCnn'},\n", + " {'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'href': 'https://api.spotify.com/v1/albums/10FLjwfpbxLmW8c25Xyc2N',\n", + " 'id': '10FLjwfpbxLmW8c25Xyc2N',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b27382ea2e9e1858aa012c57cd45'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e0282ea2e9e1858aa012c57cd45'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000485182ea2e9e1858aa012c57cd45'}],\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'release_date': '2024-08-16',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 251667,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72409273'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2plbrEY59IikOBgBGLjaoe'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2plbrEY59IikOBgBGLjaoe',\n", + " 'id': '2plbrEY59IikOBgBGLjaoe',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2plbrEY59IikOBgBGLjaoe'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m'},\n", + " 'href': 'https://api.spotify.com/v1/artists/6vWDO969PvNqNYHIOW5v0m',\n", + " 'id': '6vWDO969PvNqNYHIOW5v0m',\n", + " 'name': 'Beyoncé',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6vWDO969PvNqNYHIOW5v0m'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 220640,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905541'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/4TCL0qqKyqsMZml0G3M9IM'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/4TCL0qqKyqsMZml0G3M9IM',\n", + " 'id': '4TCL0qqKyqsMZml0G3M9IM',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Telephone',\n", + " 'track_number': 6,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:4TCL0qqKyqsMZml0G3M9IM'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 274213,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905526'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1HHeOs6zRdF8Ck58easiAY'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1HHeOs6zRdF8Ck58easiAY',\n", + " 'id': '1HHeOs6zRdF8Ck58easiAY',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Alejandro',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1HHeOs6zRdF8Ck58easiAY'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1qwlxZTNLe1jq3b0iidlue'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1qwlxZTNLe1jq3b0iidlue',\n", + " 'id': '1qwlxZTNLe1jq3b0iidlue',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e691217483df8798445c82e2'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e691217483df8798445c82e2'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e691217483df8798445c82e2'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame',\n", + " 'release_date': '2008-01-01',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 15,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1qwlxZTNLe1jq3b0iidlue'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 237200,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70824409'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1QV6tiMFM6fSOKOGLMHYYg'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'id': '1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Poker Face',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1QV6tiMFM6fSOKOGLMHYYg'},\n", + " {'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'id': '1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851d8a389abdf9cb2d03b85ff54'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'release_date': '2025-09-03',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 228518,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72407034'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/3NFs3XUduzBfvc5Bx1gmzh'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'id': '3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:3NFs3XUduzBfvc5Bx1gmzh'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'href': 'https://api.spotify.com/v1/albums/4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'id': '4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e2d156fdc691f57900134342'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e2d156fdc691f57900134342'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e2d156fdc691f57900134342'}],\n", + " 'is_playable': True,\n", + " 'name': 'A Star Is Born Soundtrack',\n", + " 'release_date': '2018-10-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 34,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 215733,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71813192'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2VxeLyX666F8uXCJ0dZF8B'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2VxeLyX666F8uXCJ0dZF8B',\n", + " 'id': '2VxeLyX666F8uXCJ0dZF8B',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Shallow',\n", + " 'track_number': 12,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2VxeLyX666F8uXCJ0dZF8B'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6LY3AerY6KNGOPsNPL63Kk',\n", + " 'id': '6LY3AerY6KNGOPsNPL63Kk',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273a5d31644260279be8d0c46c0'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02a5d31644260279be8d0c46c0'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851a5d31644260279be8d0c46c0'}],\n", + " 'is_playable': True,\n", + " 'name': 'Born This Way (International Special Edition Version)',\n", + " 'release_date': '2011-05-23',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 249066,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71104998'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/7F25roCtYi55JouckaayPC'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/7F25roCtYi55JouckaayPC',\n", + " 'id': '7F25roCtYi55JouckaayPC',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Judas',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:7F25roCtYi55JouckaayPC'}]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"items\"] #items (actual tracks)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "529fff56-47d3-4d78-8ff5-9530fe290d1d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"limit\"]#Limit we have chosen" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "92c64c57-3bd2-4d42-bbd1-84a040f1e02a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/search?offset=10&limit=10&query=Lady%20Gaga&type=track'" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"next\"] #link to the next page (next 10 tracks)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "f5ccdf79-5d9e-40de-adb9-2cc1e5b7c74a", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"offset\"] # Actual offset (starting point)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "356730c1-60a2-4ea8-bd2c-e0522bab8a4d", + "metadata": {}, + "outputs": [], + "source": [ + "results[\"tracks\"][\"previous\"] #Previous search" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "7c44c8fd-63ea-45ba-94bd-5c5e8e1458b3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"total\"] # Number of matches" + ] + }, + { + "cell_type": "markdown", + "id": "7a127c64-3274-4ecc-aa0f-83ae34af4655", + "metadata": {}, + "source": [ + "## Exploring the tracks" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "6c3541a2-0fd2-41e0-9b27-60a7dc36c4cb", + "metadata": { + "scrolled": true, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 223398,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72412581'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2LHNTC9QZxsL3nWpt8iaSR'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Abracadabra',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2LHNTC9QZxsL3nWpt8iaSR'}" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"items\"][0] # Explore the first song" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "f2c35eb2-3ea6-4329-9f29-7c062f466638", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['album', 'artists', 'disc_number', 'duration_ms', 'explicit', 'external_ids', 'external_urls', 'href', 'id', 'is_local', 'is_playable', 'name', 'track_number', 'type', 'uri'])" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"items\"][0].keys() # We will focus on album, artists, id, name, popularity, type and uri" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "889ca3c3-b0c8-4037-96fb-6add847f537f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Track artists\n", + "results[\"tracks\"][\"items\"][0][\"artists\"] " + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "a9c6a0b2-cea7-48ff-8c51-179d15388aa2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Lady Gaga\n" + ] + } + ], + "source": [ + "# Track artists names\n", + "for artist in results[\"tracks\"][\"items\"][0][\"artists\"]:\n", + " print(artist[\"name\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "6a826e9c-d2e7-4537-a82c-3dc3a2b80b9f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'2LHNTC9QZxsL3nWpt8iaSR'" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Track ID\n", + "results[\"tracks\"][\"items\"][0][\"id\"] " + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "a5bd871b-6087-4680-819c-1a1d8ba879bc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Abracadabra'" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Track name\n", + "results[\"tracks\"][\"items\"][0][\"name\"] " + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "812661f1-29db-452f-a719-cdfbe95ba9f6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'name': 'Abracadabra',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'popularity': None,\n", + " 'duration_ms': 223398}" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Popularity index\n", + "track = results[\"tracks\"][\"items\"][0]\n", + "\n", + "track_id = track[\"id\"]\n", + "full_track = sp.track(track_id)\n", + "\n", + "track_info = {\n", + " \"name\": track.get(\"name\"),\n", + " \"id\": track_id,\n", + " \"popularity\": full_track.get(\"popularity\"),\n", + " \"duration_ms\": track.get(\"duration_ms\")\n", + "}\n", + "\n", + "track_info" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "64eb9980-ea6b-4a41-899e-f9ee4f694de9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Abracadabra None\n", + "Always Remember Us This Way None\n", + "Bad Romance None\n", + "Die With A Smile None\n", + "Telephone None\n", + "Alejandro None\n", + "Poker Face None\n", + "The Dead Dance None\n", + "Shallow None\n", + "Judas None\n" + ] + } + ], + "source": [ + "for item in results[\"tracks\"][\"items\"]:\n", + " full = sp.track(item[\"id\"])\n", + " print(full.get(\"name\"), full.get(\"popularity\"))" + ] + }, + { + "cell_type": "markdown", + "id": "0e81c762-e6c5-424e-a4eb-12ab45dffb9f", + "metadata": {}, + "source": [ + "Spotify songs are identified by either a \"url\", a \"uri\", or an \"id\". \n", + "\n", + "- The `id` is an alphanumeric code, and it's the nuclear part of the identifier.\n", + "\n", + "- The `uri` contains \"spotify:track\" before the id. An uri is useful because it can be searched manually in the Spotify app.\n", + "\n", + "- The `url` is a link to the song on the Spotify web player.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "8bcdccfc-dde9-4f4b-8af5-3caa335b89b5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'spotify:track:2plbrEY59IikOBgBGLjaoe'" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results[\"tracks\"][\"items\"][0][\"uri\"]" + ] + }, + { + "cell_type": "markdown", + "id": "71c3c9c1-4ec2-42bf-a243-b21105ae1699", + "metadata": {}, + "source": [ + "## Exercise 1: Discovering New Music through Your Favorite Artists\n", + "\n", + "**Objective:** \n", + "Uncover new music by exploring the top tracks of your favorite artists and their related artists.\n", + "\n", + "**Instructions:**\n", + "\n", + "1. **List Your Favorite Artists**:\n", + " - Make a list of your three favorite artists and store it in a variable named `artists`.\n", + " - Example: `artists = [\"Los Fabulosos Cadillacs\", \"Manu Chao\", \"Muchachito Bombo Infierno\"]`.\n", + "\n", + "2. **Fetch Top Tracks**:\n", + " - Write a function named `get_top_tracks`.\n", + " - This function should accept an artist's name and return the name of the first 5 top tracks by that artist.\n", + " - Use the function `get_top_tracks` to get the first 5 top tracks for each artist in your `artists` list and store the results in a new list named `top_tracks_list`.\n", + "\n", + "3. **Discover Related Artists**:\n", + " - Write a function named `find_related_artists`.\n", + " - This function should accept an artist's name and return the names of the first 5 artists related to the provided artist.\n", + " - Store the results in a list named `related_artists_list`.\n", + "\n", + "**Challenge:** \n", + "Combine the above steps to create a playlist that includes the top tracks of your favorite artists and the top tracks of the artists related to them." + ] + }, + { + "cell_type": "markdown", + "id": "0c442378-e26f-47c8-b4f1-b4fa07089935", + "metadata": {}, + "source": [ + "**Hint Section for 3. **Discover Related Artists**:**\n", + "\n", + "1. **Getting Artist ID**:\n", + " - Remember that every artist on Spotify has a unique identifier: their `id`. To get the related artists, you first need to fetch the ID of the given artist.\n", + " - Consider using the `sp.search` method to query the artist's name. The method requires a `q` parameter, which is your query (in this case, the artist's name). It also has a `limit` parameter, which specifies the number of tracks it returns. In this case, 1 track is enough, since we just want the artist ID. \n", + " - Each track in the results has an associated 'artists' field. This field is a list containing details about all artists involved in that track.\n", + " - For most tracks, especially those by a single artist, this list will contain one artist. From this artist's details, you can extract the 'id' field, which is the unique identifier for that artist on Spotify.\n", + "\n", + "\n", + "3. **Fetching Related Artists**:\n", + " - Once you have the artist's ID, you can use another SpotiPy method to fetch related artists. Think about which SpotiPy method allows you to get related artists using an artist's ID. Here is the documentation link: https://spotipy.readthedocs.io/en/2.22.1/. \n", + " - This method will return a list of related artists. You'll need to extract the relevant details (artist names) from this list.\n", + "\n", + "4. **Iterating for Multiple Artists**:\n", + " - Once you have a function that returns related artists names for one artist, you can use a list comprehension to apply this function to a list of artist names.\n", + "\n", + "5. **Testing**:\n", + " - Always test your function with one artist name first. Once you're confident it works, then apply it to the entire list.\n", + "\n", + "Remember, the key is to break the problem down into manageable steps. Use the SpotiPy documentation as a resource to understand available methods and their return structures." + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "29694252-f217-454d-8881-681b2b6eeb1e", + "metadata": {}, + "outputs": [], + "source": [ + "artists=[\"Ed Sheeran\", \"Alex Warren\", \"Elena Rose\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "f929430e-e9c2-47a9-8462-b88485418a71", + "metadata": {}, + "outputs": [], + "source": [ + "def get_top_tracks(artist_name):\n", + " result = sp.search(q=artist_name, type='artist', limit=1)\n", + "\n", + " artists_found = result[\"artists\"][\"items\"]\n", + "\n", + " if not artists_found:\n", + " return []\n", + "\n", + " artist_id = artists_found[0][\"id\"]\n", + "\n", + " top_tracks = sp.artist_top_tracks(artist_id, country='US')\n", + "\n", + " return [track[\"name\"] for track in top_tracks[\"tracks\"][:5]]" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "51ccd2b7-4c9c-427a-9fca-c1d3a06a7117", + "metadata": {}, + "outputs": [], + "source": [ + "# Note:\n", + "# Spotify removed the endpoint used to fetch an artist's official top tracks\n", + "# (GET /artists/{id}/top-tracks) in February 2026.\n", + "# To continue the exercise, i approximate the result by searching tracks for the artist\n", + "# and keeping the first 5 matches." + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "29e5a046-a98c-4b82-9e9f-733ef70295ee", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks with Params: {'country': 'US'} returned 403 due to Forbidden\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[51]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mget_top_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mEd Sheeran\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[49]\u001b[39m\u001b[32m, line 11\u001b[39m, in \u001b[36mget_top_tracks\u001b[39m\u001b[34m(artist_name)\u001b[39m\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m []\n\u001b[32m 9\u001b[39m artist_id = artists_found[\u001b[32m0\u001b[39m][\u001b[33m\"\u001b[39m\u001b[33mid\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m---> \u001b[39m\u001b[32m11\u001b[39m top_tracks = \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43martist_top_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[43martist_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mUS\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m [track[\u001b[33m\"\u001b[39m\u001b[33mname\u001b[39m\u001b[33m\"\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m track \u001b[38;5;129;01min\u001b[39;00m top_tracks[\u001b[33m\"\u001b[39m\u001b[33mtracks\u001b[39m\u001b[33m\"\u001b[39m][:\u001b[32m5\u001b[39m]]\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:454\u001b[39m, in \u001b[36mSpotify.artist_top_tracks\u001b[39m\u001b[34m(self, artist_id, country)\u001b[39m\n\u001b[32m 448\u001b[39m warnings.warn(\n\u001b[32m 449\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou\u001b[39m\u001b[33m'\u001b[39m\u001b[33mre using `artist_top_tracks(...)`, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 450\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mwhich is marked as deprecated by Spotify.\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 451\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 452\u001b[39m )\n\u001b[32m 453\u001b[39m trid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33martist\u001b[39m\u001b[33m\"\u001b[39m, artist_id)\n\u001b[32m--> \u001b[39m\u001b[32m454\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43martists/\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrid\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/top-tracks\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None" + ] + } + ], + "source": [ + "get_top_tracks(\"Ed Sheeran\")" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "3faefafe-8c2a-4beb-b0e6-8d545a3c391d", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks with Params: {'country': 'US'} returned 403 due to Forbidden\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[52]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43martist_top_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[43martist_id\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:454\u001b[39m, in \u001b[36mSpotify.artist_top_tracks\u001b[39m\u001b[34m(self, artist_id, country)\u001b[39m\n\u001b[32m 448\u001b[39m warnings.warn(\n\u001b[32m 449\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou\u001b[39m\u001b[33m'\u001b[39m\u001b[33mre using `artist_top_tracks(...)`, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 450\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mwhich is marked as deprecated by Spotify.\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 451\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 452\u001b[39m )\n\u001b[32m 453\u001b[39m trid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33martist\u001b[39m\u001b[33m\"\u001b[39m, artist_id)\n\u001b[32m--> \u001b[39m\u001b[32m454\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43martists/\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrid\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/top-tracks\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None" + ] + } + ], + "source": [ + "sp.artist_top_tracks(artist_id)" + ] + }, + { + "cell_type": "markdown", + "id": "94ad5fdc-22e5-4521-8aa1-c6833eb7e949", + "metadata": {}, + "source": [ + "## Playlists\n", + "\n", + "The `sp.featured_playlists()` method in `spotipy` fetches a list of Spotify's featured playlists at a given moment. These are curated playlists that Spotify often highlights on the platform's homepage. The method provides a snapshot of the playlists that are being promoted or featured by Spotify at the time of the request.\n", + "\n", + "Once you've fetched the featured playlists, you can extract their IDs (and other details)." + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "25fb0cf8-c13a-41b0-b8f8-7e0700fd1e41", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/browse/featured-playlists with Params: {'locale': None, 'country': None, 'timestamp': None, 'limit': 20, 'offset': 0} returned 403 due to Forbidden\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 403, code: -1 - https://api.spotify.com/v1/browse/featured-playlists?limit=20&offset=0:\n Forbidden, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/browse/featured-playlists?limit=20&offset=0", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[53]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfeatured_playlists\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# We get a playlist id of a playlist we like\u001b[39;00m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:1721\u001b[39m, in \u001b[36mSpotify.featured_playlists\u001b[39m\u001b[34m(self, locale, country, timestamp, limit, offset)\u001b[39m\n\u001b[32m 1692\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Get a list of Spotify featured playlists\u001b[39;00m\n\u001b[32m 1693\u001b[39m \n\u001b[32m 1694\u001b[39m \u001b[33;03m .. deprecated::\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 1714\u001b[39m \u001b[33;03m items.\u001b[39;00m\n\u001b[32m 1715\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 1716\u001b[39m warnings.warn(\n\u001b[32m 1717\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou\u001b[39m\u001b[33m'\u001b[39m\u001b[33mre using `featured_playlists(...)`, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 1718\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mwhich is marked as deprecated by Spotify.\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 1719\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 1720\u001b[39m )\n\u001b[32m-> \u001b[39m\u001b[32m1721\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1722\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mbrowse/featured-playlists\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 1723\u001b[39m \u001b[43m \u001b[49m\u001b[43mlocale\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlocale\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1724\u001b[39m \u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1725\u001b[39m \u001b[43m \u001b[49m\u001b[43mtimestamp\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimestamp\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1726\u001b[39m \u001b[43m \u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1727\u001b[39m \u001b[43m \u001b[49m\u001b[43moffset\u001b[49m\u001b[43m=\u001b[49m\u001b[43moffset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1728\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 403, code: -1 - https://api.spotify.com/v1/browse/featured-playlists?limit=20&offset=0:\n Forbidden, reason: None" + ] + } + ], + "source": [ + "sp.featured_playlists() # We get a playlist id of a playlist we like" + ] + }, + { + "cell_type": "markdown", + "id": "90f558f3-c638-4df4-b5a4-e24f7847d52a", + "metadata": {}, + "source": [ + "### Getting a Playlist's Details\n", + "To fetch details about a specific playlist, you can use the playlist method. You'll need the playlist's Spotify ID." + ] + }, + { + "cell_type": "markdown", + "id": "0eef529f-617f-4ea3-8156-07472ac8e6d5", + "metadata": {}, + "source": [ + "In this example, we will use the following playlist id: *37i9dQZF1DXd9zR7tdziuQ*" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "46d35121-9256-4cf4-81f5-118b87f7af32", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ with Params: {'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ?additional_types=track:\n Resource not found, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 404 Client Error: Not Found for url: https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ?additional_types=track", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[54]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m playlist_id = \u001b[33m\"\u001b[39m\u001b[33m37i9dQZF1DXd9zR7tdziuQ\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m playlist = \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43mplaylist\u001b[49m\u001b[43m(\u001b[49m\u001b[43mplaylist_id\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:682\u001b[39m, in \u001b[36mSpotify.playlist\u001b[39m\u001b[34m(self, playlist_id, fields, market, additional_types)\u001b[39m\n\u001b[32m 671\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Gets playlist by id.\u001b[39;00m\n\u001b[32m 672\u001b[39m \n\u001b[32m 673\u001b[39m \u001b[33;03m Parameters:\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 679\u001b[39m \u001b[33;03m valid types are: track and episode\u001b[39;00m\n\u001b[32m 680\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 681\u001b[39m plid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33mplaylist\u001b[39m\u001b[33m\"\u001b[39m, playlist_id)\n\u001b[32m--> \u001b[39m\u001b[32m682\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 683\u001b[39m \u001b[43m \u001b[49m\u001b[33;43mf\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mplaylists/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mplid\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 684\u001b[39m \u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfields\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 685\u001b[39m \u001b[43m \u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 686\u001b[39m \u001b[43m \u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m,\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 687\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ?additional_types=track:\n Resource not found, reason: None" + ] + } + ], + "source": [ + "playlist_id = \"37i9dQZF1DXd9zR7tdziuQ\"\n", + "playlist = sp.playlist(playlist_id)" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "5260f67f-6024-4fee-8449-30904f03bf76", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'playlist' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[56]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[43mplaylist\u001b[49m[\u001b[33m'\u001b[39m\u001b[33mname\u001b[39m\u001b[33m'\u001b[39m]) \u001b[38;5;66;03m# Print the playlist's name\u001b[39;00m\n\u001b[32m 2\u001b[39m \u001b[38;5;28mprint\u001b[39m(playlist[\u001b[33m'\u001b[39m\u001b[33mdescription\u001b[39m\u001b[33m'\u001b[39m]) \u001b[38;5;66;03m# Print the playlist's description\u001b[39;00m\n", + "\u001b[31mNameError\u001b[39m: name 'playlist' is not defined" + ] + } + ], + "source": [ + "print(playlist['name']) # Print the playlist's name\n", + "print(playlist['description']) # Print the playlist's description" + ] + }, + { + "cell_type": "markdown", + "id": "13bc8631-69f0-4b98-9cc9-5baecbaea9ba", + "metadata": {}, + "source": [ + "### Getting Tracks from a Playlist\n", + "If you want to get the tracks from a specific playlist, you can use the playlist_tracks method." + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "69c78f8d-7e6a-4d15-bcbb-fc93edb82433", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items with Params: {'limit': 50, 'offset': 0, 'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items?limit=50&offset=0&additional_types=track:\n Resource not found, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 404 Client Error: Not Found for url: https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items?limit=50&offset=0&additional_types=track", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[55]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m tracks = \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43mplaylist_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mplaylist_id\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 2\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m track \u001b[38;5;129;01min\u001b[39;00m tracks[\u001b[33m'\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m'\u001b[39m]:\n\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(track[\u001b[33m'\u001b[39m\u001b[33mtrack\u001b[39m\u001b[33m'\u001b[39m][\u001b[33m'\u001b[39m\u001b[33mname\u001b[39m\u001b[33m'\u001b[39m]) \u001b[38;5;66;03m# Print each track's name\u001b[39;00m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:718\u001b[39m, in \u001b[36mSpotify.playlist_tracks\u001b[39m\u001b[34m(self, playlist_id, fields, limit, offset, market, additional_types)\u001b[39m\n\u001b[32m 698\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Get full details of the tracks of a playlist.\u001b[39;00m\n\u001b[32m 699\u001b[39m \n\u001b[32m 700\u001b[39m \u001b[33;03m .. deprecated::\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 711\u001b[39m \u001b[33;03m valid types are: track and episode\u001b[39;00m\n\u001b[32m 712\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 713\u001b[39m warnings.warn(\n\u001b[32m 714\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou should use `playlist_items(playlist_id, ...,\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 715\u001b[39m \u001b[33m\"\u001b[39m\u001b[33madditional_types=(\u001b[39m\u001b[33m'\u001b[39m\u001b[33mtrack\u001b[39m\u001b[33m'\u001b[39m\u001b[33m,))` instead\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 716\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 717\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m718\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mplaylist_items\u001b[49m\u001b[43m(\u001b[49m\u001b[43mplaylist_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moffset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 719\u001b[39m \u001b[43m \u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:742\u001b[39m, in \u001b[36mSpotify.playlist_items\u001b[39m\u001b[34m(self, playlist_id, fields, limit, offset, market, additional_types)\u001b[39m\n\u001b[32m 730\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Get full details of the tracks and episodes of a playlist.\u001b[39;00m\n\u001b[32m 731\u001b[39m \n\u001b[32m 732\u001b[39m \u001b[33;03m Parameters:\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 739\u001b[39m \u001b[33;03m valid types are: track and episode\u001b[39;00m\n\u001b[32m 740\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 741\u001b[39m plid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33mplaylist\u001b[39m\u001b[33m\"\u001b[39m, playlist_id)\n\u001b[32m--> \u001b[39m\u001b[32m742\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 743\u001b[39m \u001b[43m \u001b[49m\u001b[33;43mf\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mplaylists/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mplid\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m/items\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 744\u001b[39m \u001b[43m \u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 745\u001b[39m \u001b[43m \u001b[49m\u001b[43moffset\u001b[49m\u001b[43m=\u001b[49m\u001b[43moffset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 746\u001b[39m \u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfields\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 747\u001b[39m \u001b[43m \u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 748\u001b[39m \u001b[43m \u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m,\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 749\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items?limit=50&offset=0&additional_types=track:\n Resource not found, reason: None" + ] + } + ], + "source": [ + "tracks = sp.playlist_tracks(playlist_id)\n", + "for track in tracks['items']:\n", + " print(track['track']['name']) # Print each track's name" + ] + }, + { + "cell_type": "markdown", + "id": "2775714d-acc7-4555-96bd-2c541ab0855e", + "metadata": {}, + "source": [ + "### Getting Artists from a Playlist\n", + "\n", + "To extract all the artists from the tracks in a playlist, you'd typically follow these steps:\n", + "\n", + "1. Fetch the playlist's tracks.\n", + "2. Iterate through each track.\n", + "3. For each track, extract the associated artists." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "65c5e5c4-f186-42c6-b136-4ef02b0b01ff", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'tracks' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[57]\u001b[39m\u001b[32m, line 4\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# List to store unique artist names\u001b[39;00m\n\u001b[32m 2\u001b[39m artists_list = []\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m track_item \u001b[38;5;129;01min\u001b[39;00m \u001b[43mtracks\u001b[49m[\u001b[33m'\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m'\u001b[39m]:\n\u001b[32m 5\u001b[39m track = track_item[\u001b[33m'\u001b[39m\u001b[33mtrack\u001b[39m\u001b[33m'\u001b[39m]\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m artist \u001b[38;5;129;01min\u001b[39;00m track[\u001b[33m'\u001b[39m\u001b[33martists\u001b[39m\u001b[33m'\u001b[39m]:\n", + "\u001b[31mNameError\u001b[39m: name 'tracks' is not defined" + ] + } + ], + "source": [ + "# List to store unique artist names\n", + "artists_list = []\n", + "\n", + "for track_item in tracks['items']:\n", + " track = track_item['track']\n", + " for artist in track['artists']:\n", + " artist_name = artist['name']\n", + " if artist_name not in artists_list: # This ensures each artist is added only once\n", + " artists_list.append(artist_name)\n", + "\n", + "print(artists_list)" + ] + }, + { + "cell_type": "markdown", + "id": "7b52207e-a4f0-4f90-9f4e-3170d7f0f3fe", + "metadata": {}, + "source": [ + "## Exercise 2: Unraveling the World of Playlists\n", + "\n", + "\n", + "1. **Featured Exploration**: \n", + " - Fetch the list of Spotify's current featured playlists. \n", + " - Extract and display the names and IDs of the top 5 featured playlists.\n", + " \n", + "2. **Deep Dive**:\n", + " - Choose any one of the top 5 featured playlists (you can choose the one you personally find most interesting or simply pick one randomly).\n", + " - Fetch and display its name, description, and total track count.\n", + "\n", + "3. **Track-tastic**:\n", + " - Extract and display the names of the first 10 tracks in the chosen playlist.\n", + "\n", + "4. **Artistic Flair**:\n", + " - Create a dictionary where the keys are the names of the first 10 tracks, and the values are lists containing the names of the artists associated with each track.\n", + " - For example: `{\"TrackName1\": [\"Artist1\", \"Artist2\"], \"TrackName2\": [\"Artist3\"]}`\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ed92d961-9646-4375-a386-ccc320a958f5", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.14.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/lab-apis.ipynb b/lab-apis.ipynb index e923554..d5fa476 100644 --- a/lab-apis.ipynb +++ b/lab-apis.ipynb @@ -32,17 +32,6 @@ "Save your client ID and your client secret in your preferred way, and read it or load it into the following variables:" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "ea44c82a-5c07-4dbc-beb2-bba2601bb75e", - "metadata": {}, - "outputs": [], - "source": [ - "CLIENT_ID = \"\"\n", - "CLIENT_SECRET = \"\"" - ] - }, { "cell_type": "code", "execution_count": null, @@ -50,16 +39,30 @@ "metadata": {}, "outputs": [], "source": [ - "CLIENT_ID = \"4109b2d9f5014671863bb2df1d1fbdd3\"\n", - "CLIENT_SECRET = \"5cb719fae80c4191a9c0b288f51bfe50\"" + "#CLIENT_ID = \"4109b2d9f5014671863bb2df1d1fbdd3\"\n", + "#CLIENT_SECRET = \"5cb719fae80c4191a9c0b288f51bfe50\"" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "04e12954-fd70-4311-88a5-fb7e2c29799c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: spotipy in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (2.26.0)\n", + "Requirement already satisfied: redis>=3.5.3 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from spotipy) (7.4.0)\n", + "Requirement already satisfied: requests>=2.25.0 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from spotipy) (2.32.5)\n", + "Requirement already satisfied: urllib3>=1.26.0 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from spotipy) (2.6.3)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from requests>=2.25.0->spotipy) (3.4.5)\n", + "Requirement already satisfied: idna<4,>=2.5 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from requests>=2.25.0->spotipy) (3.11)\n", + "Requirement already satisfied: certifi>=2017.4.17 in C:\\Users\\estef\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages (from requests>=2.25.0->spotipy) (2026.2.25)\n" + ] + } + ], "source": [ "# If you havent done so, install the spotipy wrapper\n", "!pip install spotipy" @@ -75,17 +78,78 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, + "id": "ea44c82a-5c07-4dbc-beb2-bba2601bb75e", + "metadata": {}, + "outputs": [], + "source": [ + "CLIENT_ID = \"48cd2d99fdcd4c83a81f77991a3f0b20\"\n", + "CLIENT_SECRET = \"8fe7bcd10d9441eb833e64b6ec0a1267\"" + ] + }, + { + "cell_type": "code", + "execution_count": 3, "id": "03034bc6-9858-412a-83b7-18abdc345d7e", "metadata": {}, "outputs": [], "source": [ - "import spotipy\n", - "from spotipy.oauth2 import SpotifyClientCredentials\n", + "#import spotipy\n", + "#from spotipy.oauth2 import SpotifyClientCredentials\n", "\n", "#Initialize SpotiPy with user credentials\n", - "sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=CLIENT_ID,\n", - " client_secret=CLIENT_SECRET))\n" + "#sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=CLIENT_ID,client_secret=CLIENT_SECRET))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "0a7e7ee9-0c5b-4ca9-91f2-df45f7d68fa2", + "metadata": {}, + "outputs": [], + "source": [ + "import spotipy\n", + "from spotipy.oauth2 import SpotifyOAuth\n", + "\n", + "sp = spotipy.Spotify(auth_manager=SpotifyOAuth(\n", + " client_id=CLIENT_ID,\n", + " client_secret=CLIENT_SECRET,\n", + " redirect_uri=\"http://127.0.0.1:9090/callback\",\n", + " scope=\"user-top-read\"\n", + "))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "74355ee2-0200-4414-b10c-49252d079fe5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'display_name': 'Estefania Barrosa',\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/user/kon0cibdlep7kv3v50sh0ldt7'},\n", + " 'followers': {'href': None, 'total': 6},\n", + " 'href': 'https://api.spotify.com/v1/users/kon0cibdlep7kv3v50sh0ldt7',\n", + " 'id': 'kon0cibdlep7kv3v50sh0ldt7',\n", + " 'images': [{'height': 300,\n", + " 'url': 'https://i.scdn.co/image/ab6775700000ee858ef813e233964f52d41cff2d',\n", + " 'width': 300},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67757000003b828ef813e233964f52d41cff2d',\n", + " 'width': 64}],\n", + " 'type': 'user',\n", + " 'uri': 'spotify:user:kon0cibdlep7kv3v50sh0ldt7'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.current_user()" ] }, { @@ -106,95 +170,1159 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "id": "7772a1e0-9692-4d04-a590-76111a272d8d", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'tracks': {'href': 'https://api.spotify.com/v1/search?offset=0&limit=10&query=Lady%20Gaga&type=track',\n", + " 'limit': 10,\n", + " 'next': 'https://api.spotify.com/v1/search?offset=10&limit=10&query=Lady%20Gaga&type=track',\n", + " 'offset': 0,\n", + " 'previous': None,\n", + " 'total': 14,\n", + " 'items': [{'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'href': 'https://api.spotify.com/v1/albums/10FLjwfpbxLmW8c25Xyc2N',\n", + " 'id': '10FLjwfpbxLmW8c25Xyc2N',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b27382ea2e9e1858aa012c57cd45'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e0282ea2e9e1858aa012c57cd45'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000485182ea2e9e1858aa012c57cd45'}],\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'release_date': '2024-08-16',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 251667,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72409273'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2plbrEY59IikOBgBGLjaoe'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2plbrEY59IikOBgBGLjaoe',\n", + " 'id': '2plbrEY59IikOBgBGLjaoe',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2plbrEY59IikOBgBGLjaoe'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 294573,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70918596'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/0SiywuOBRcynK0uKGWdCnn'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/0SiywuOBRcynK0uKGWdCnn',\n", + " 'id': '0SiywuOBRcynK0uKGWdCnn',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Bad Romance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:0SiywuOBRcynK0uKGWdCnn'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 223398,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72412581'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2LHNTC9QZxsL3nWpt8iaSR'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Abracadabra',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2LHNTC9QZxsL3nWpt8iaSR'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m'},\n", + " 'href': 'https://api.spotify.com/v1/artists/6vWDO969PvNqNYHIOW5v0m',\n", + " 'id': '6vWDO969PvNqNYHIOW5v0m',\n", + " 'name': 'Beyoncé',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6vWDO969PvNqNYHIOW5v0m'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 220640,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905541'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/4TCL0qqKyqsMZml0G3M9IM'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/4TCL0qqKyqsMZml0G3M9IM',\n", + " 'id': '4TCL0qqKyqsMZml0G3M9IM',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Telephone',\n", + " 'track_number': 6,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:4TCL0qqKyqsMZml0G3M9IM'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 274213,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905526'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1HHeOs6zRdF8Ck58easiAY'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1HHeOs6zRdF8Ck58easiAY',\n", + " 'id': '1HHeOs6zRdF8Ck58easiAY',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Alejandro',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1HHeOs6zRdF8Ck58easiAY'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1qwlxZTNLe1jq3b0iidlue'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1qwlxZTNLe1jq3b0iidlue',\n", + " 'id': '1qwlxZTNLe1jq3b0iidlue',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e691217483df8798445c82e2'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e691217483df8798445c82e2'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e691217483df8798445c82e2'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame',\n", + " 'release_date': '2008-01-01',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 15,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1qwlxZTNLe1jq3b0iidlue'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 237200,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70824409'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1QV6tiMFM6fSOKOGLMHYYg'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'id': '1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Poker Face',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1QV6tiMFM6fSOKOGLMHYYg'},\n", + " {'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'id': '1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851d8a389abdf9cb2d03b85ff54'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'release_date': '2025-09-03',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 228518,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72407034'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/3NFs3XUduzBfvc5Bx1gmzh'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'id': '3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:3NFs3XUduzBfvc5Bx1gmzh'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'href': 'https://api.spotify.com/v1/albums/4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'id': '4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e2d156fdc691f57900134342'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e2d156fdc691f57900134342'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e2d156fdc691f57900134342'}],\n", + " 'is_playable': True,\n", + " 'name': 'A Star Is Born Soundtrack',\n", + " 'release_date': '2018-10-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 34,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 215733,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71813192'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2VxeLyX666F8uXCJ0dZF8B'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2VxeLyX666F8uXCJ0dZF8B',\n", + " 'id': '2VxeLyX666F8uXCJ0dZF8B',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Shallow',\n", + " 'track_number': 12,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2VxeLyX666F8uXCJ0dZF8B'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6LY3AerY6KNGOPsNPL63Kk',\n", + " 'id': '6LY3AerY6KNGOPsNPL63Kk',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273a5d31644260279be8d0c46c0'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02a5d31644260279be8d0c46c0'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851a5d31644260279be8d0c46c0'}],\n", + " 'is_playable': True,\n", + " 'name': 'Born This Way (International Special Edition Version)',\n", + " 'release_date': '2011-05-23',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 249066,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71104998'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/7F25roCtYi55JouckaayPC'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/7F25roCtYi55JouckaayPC',\n", + " 'id': '7F25roCtYi55JouckaayPC',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Judas',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:7F25roCtYi55JouckaayPC'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 251667,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72409273'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/7so0lgd0zP2Sbgs2d7a1SZ'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/7so0lgd0zP2Sbgs2d7a1SZ',\n", + " 'id': '7so0lgd0zP2Sbgs2d7a1SZ',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'track_number': 14,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:7so0lgd0zP2Sbgs2d7a1SZ'}]}}" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "results = sp.search(q='Lady Gaga', limit=50)\n", + "results = sp.search(q='Lady Gaga', limit=10)\n", "results" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "edc14c95-474b-4e2a-aea3-bdfd0a205546", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['tracks'])" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results.keys() # We can see that we only have tracks" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "ad8ef934-1dbb-4008-ac8e-f5c29823fe6a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['href', 'limit', 'next', 'offset', 'previous', 'total', 'items'])" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"].keys() # Let's check the values" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "004b7814-4dd5-408e-b7ba-1da87f9250cb", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/search?offset=0&limit=10&query=Lady%20Gaga&type=track'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"href\"] # Query we have searched " ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "7285cedd-fbe1-47cf-98d5-a7fdc3e5c8b8", "metadata": { "scrolled": true, "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[{'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 223398,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72412581'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2LHNTC9QZxsL3nWpt8iaSR'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Abracadabra',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2LHNTC9QZxsL3nWpt8iaSR'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/3edjzMAVB9RYRd4UcZBchx'},\n", + " 'href': 'https://api.spotify.com/v1/albums/3edjzMAVB9RYRd4UcZBchx',\n", + " 'id': '3edjzMAVB9RYRd4UcZBchx',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b5d4b4ed17ec86c4b3944af2'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b5d4b4ed17ec86c4b3944af2'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b5d4b4ed17ec86c4b3944af2'}],\n", + " 'is_playable': True,\n", + " 'name': 'A Star Is Born Soundtrack (Without Dialogue)',\n", + " 'release_date': '2018-10-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 19,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:3edjzMAVB9RYRd4UcZBchx'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 210200,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71813195'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2rbDhOo9Fh61Bbu23T2qCk'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2rbDhOo9Fh61Bbu23T2qCk',\n", + " 'id': '2rbDhOo9Fh61Bbu23T2qCk',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Always Remember Us This Way',\n", + " 'track_number': 9,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2rbDhOo9Fh61Bbu23T2qCk'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 294573,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70918596'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/0SiywuOBRcynK0uKGWdCnn'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/0SiywuOBRcynK0uKGWdCnn',\n", + " 'id': '0SiywuOBRcynK0uKGWdCnn',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Bad Romance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:0SiywuOBRcynK0uKGWdCnn'},\n", + " {'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'href': 'https://api.spotify.com/v1/albums/10FLjwfpbxLmW8c25Xyc2N',\n", + " 'id': '10FLjwfpbxLmW8c25Xyc2N',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b27382ea2e9e1858aa012c57cd45'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e0282ea2e9e1858aa012c57cd45'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000485182ea2e9e1858aa012c57cd45'}],\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'release_date': '2024-08-16',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:10FLjwfpbxLmW8c25Xyc2N'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C'},\n", + " 'href': 'https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C',\n", + " 'id': '0du5cEVh5yTK9QJze8zA0C',\n", + " 'name': 'Bruno Mars',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0du5cEVh5yTK9QJze8zA0C'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 251667,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72409273'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2plbrEY59IikOBgBGLjaoe'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2plbrEY59IikOBgBGLjaoe',\n", + " 'id': '2plbrEY59IikOBgBGLjaoe',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Die With A Smile',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2plbrEY59IikOBgBGLjaoe'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m'},\n", + " 'href': 'https://api.spotify.com/v1/artists/6vWDO969PvNqNYHIOW5v0m',\n", + " 'id': '6vWDO969PvNqNYHIOW5v0m',\n", + " 'name': 'Beyoncé',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6vWDO969PvNqNYHIOW5v0m'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 220640,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905541'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/4TCL0qqKyqsMZml0G3M9IM'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/4TCL0qqKyqsMZml0G3M9IM',\n", + " 'id': '4TCL0qqKyqsMZml0G3M9IM',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Telephone',\n", + " 'track_number': 6,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:4TCL0qqKyqsMZml0G3M9IM'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4',\n", + " 'id': '6rePArBMb5nLWEaY9aQqL4',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame Monster (Deluxe Edition)',\n", + " 'release_date': '2009-11-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6rePArBMb5nLWEaY9aQqL4'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 274213,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM70905526'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1HHeOs6zRdF8Ck58easiAY'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1HHeOs6zRdF8Ck58easiAY',\n", + " 'id': '1HHeOs6zRdF8Ck58easiAY',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Alejandro',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1HHeOs6zRdF8Ck58easiAY'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1qwlxZTNLe1jq3b0iidlue'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1qwlxZTNLe1jq3b0iidlue',\n", + " 'id': '1qwlxZTNLe1jq3b0iidlue',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e691217483df8798445c82e2'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e691217483df8798445c82e2'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e691217483df8798445c82e2'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Fame',\n", + " 'release_date': '2008-01-01',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 15,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1qwlxZTNLe1jq3b0iidlue'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 237200,\n", + " 'explicit': True,\n", + " 'external_ids': {'isrc': 'USUM70824409'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/1QV6tiMFM6fSOKOGLMHYYg'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'id': '1QV6tiMFM6fSOKOGLMHYYg',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Poker Face',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:1QV6tiMFM6fSOKOGLMHYYg'},\n", + " {'album': {'album_type': 'single',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'href': 'https://api.spotify.com/v1/albums/1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'id': '1KdrtZn2AmuQPHKIr3h4e6',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02d8a389abdf9cb2d03b85ff54'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851d8a389abdf9cb2d03b85ff54'}],\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'release_date': '2025-09-03',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 1,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:1KdrtZn2AmuQPHKIr3h4e6'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 228518,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72407034'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/3NFs3XUduzBfvc5Bx1gmzh'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'id': '3NFs3XUduzBfvc5Bx1gmzh',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'The Dead Dance',\n", + " 'track_number': 1,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:3NFs3XUduzBfvc5Bx1gmzh'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'href': 'https://api.spotify.com/v1/albums/4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'id': '4sLtOBOzn4s3GDUv3c5oJD',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e2d156fdc691f57900134342'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e2d156fdc691f57900134342'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e2d156fdc691f57900134342'}],\n", + " 'is_playable': True,\n", + " 'name': 'A Star Is Born Soundtrack',\n", + " 'release_date': '2018-10-05',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 34,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:4sLtOBOzn4s3GDUv3c5oJD'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4VIvfOurcf0vuLRxLkGnIG'},\n", + " 'href': 'https://api.spotify.com/v1/artists/4VIvfOurcf0vuLRxLkGnIG',\n", + " 'id': '4VIvfOurcf0vuLRxLkGnIG',\n", + " 'name': 'Bradley Cooper',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4VIvfOurcf0vuLRxLkGnIG'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 215733,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71813192'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2VxeLyX666F8uXCJ0dZF8B'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2VxeLyX666F8uXCJ0dZF8B',\n", + " 'id': '2VxeLyX666F8uXCJ0dZF8B',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Shallow',\n", + " 'track_number': 12,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2VxeLyX666F8uXCJ0dZF8B'},\n", + " {'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'href': 'https://api.spotify.com/v1/albums/6LY3AerY6KNGOPsNPL63Kk',\n", + " 'id': '6LY3AerY6KNGOPsNPL63Kk',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273a5d31644260279be8d0c46c0'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02a5d31644260279be8d0c46c0'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851a5d31644260279be8d0c46c0'}],\n", + " 'is_playable': True,\n", + " 'name': 'Born This Way (International Special Edition Version)',\n", + " 'release_date': '2011-05-23',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 23,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:6LY3AerY6KNGOPsNPL63Kk'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 249066,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM71104998'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/7F25roCtYi55JouckaayPC'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/7F25roCtYi55JouckaayPC',\n", + " 'id': '7F25roCtYi55JouckaayPC',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Judas',\n", + " 'track_number': 4,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:7F25roCtYi55JouckaayPC'}]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"items\"] #items (actual tracks)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "529fff56-47d3-4d78-8ff5-9530fe290d1d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"limit\"]#Limit we have chosen" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "92c64c57-3bd2-4d42-bbd1-84a040f1e02a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/search?offset=10&limit=10&query=Lady%20Gaga&type=track'" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "results[\"tracks\"][\"next\"] #link to the next page (next 50 tracks)" + "results[\"tracks\"][\"next\"] #link to the next page (next 10 tracks)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "f5ccdf79-5d9e-40de-adb9-2cc1e5b7c74a", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"offset\"] # Actual offset (starting point)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "356730c1-60a2-4ea8-bd2c-e0522bab8a4d", "metadata": {}, "outputs": [], @@ -204,10 +1332,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "7c44c8fd-63ea-45ba-94bd-5c5e8e1458b3", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"total\"] # Number of matches" ] @@ -222,33 +1361,115 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "6c3541a2-0fd2-41e0-9b27-60a7dc36c4cb", "metadata": { "scrolled": true, "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'id': '2MHUaRi9OCyTN02SoyRRBJ',\n", + " 'images': [{'height': 640,\n", + " 'width': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273b0860cf0a98e09663c82290c'},\n", + " {'height': 300,\n", + " 'width': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02b0860cf0a98e09663c82290c'},\n", + " {'height': 64,\n", + " 'width': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851b0860cf0a98e09663c82290c'}],\n", + " 'is_playable': True,\n", + " 'name': 'MAYHEM',\n", + " 'release_date': '2025-03-07',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 14,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2MHUaRi9OCyTN02SoyRRBJ'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 223398,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USUM72412581'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/2LHNTC9QZxsL3nWpt8iaSR'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'is_local': False,\n", + " 'is_playable': True,\n", + " 'name': 'Abracadabra',\n", + " 'track_number': 2,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:2LHNTC9QZxsL3nWpt8iaSR'}" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"items\"][0] # Explore the first song" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "f2c35eb2-3ea6-4329-9f29-7c062f466638", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['album', 'artists', 'disc_number', 'duration_ms', 'explicit', 'external_ids', 'external_urls', 'href', 'id', 'is_local', 'is_playable', 'name', 'track_number', 'type', 'uri'])" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"items\"][0].keys() # We will focus on album, artists, id, name, popularity, type and uri" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "889ca3c3-b0c8-4037-96fb-6add847f537f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[{'external_urls': {'spotify': 'https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms'},\n", + " 'href': 'https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms',\n", + " 'id': '1HY2Jd0NmPuamShAr6KMms',\n", + " 'name': 'Lady Gaga',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1HY2Jd0NmPuamShAr6KMms'}]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Track artists\n", "results[\"tracks\"][\"items\"][0][\"artists\"] " @@ -256,10 +1477,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "a9c6a0b2-cea7-48ff-8c51-179d15388aa2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Lady Gaga\n" + ] + } + ], "source": [ "# Track artists names\n", "for artist in results[\"tracks\"][\"items\"][0][\"artists\"]:\n", @@ -268,10 +1497,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "6a826e9c-d2e7-4537-a82c-3dc3a2b80b9f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'2LHNTC9QZxsL3nWpt8iaSR'" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Track ID\n", "results[\"tracks\"][\"items\"][0][\"id\"] " @@ -279,10 +1519,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "a5bd871b-6087-4680-819c-1a1d8ba879bc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Abracadabra'" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Track name\n", "results[\"tracks\"][\"items\"][0][\"name\"] " @@ -290,13 +1541,68 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "id": "812661f1-29db-452f-a719-cdfbe95ba9f6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'name': 'Abracadabra',\n", + " 'id': '2LHNTC9QZxsL3nWpt8iaSR',\n", + " 'popularity': None,\n", + " 'duration_ms': 223398}" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Popularity index\n", - "results[\"tracks\"][\"items\"][0][\"popularity\"] " + "track = results[\"tracks\"][\"items\"][0]\n", + "\n", + "track_id = track[\"id\"]\n", + "full_track = sp.track(track_id)\n", + "\n", + "track_info = {\n", + " \"name\": track.get(\"name\"),\n", + " \"id\": track_id,\n", + " \"popularity\": full_track.get(\"popularity\"),\n", + " \"duration_ms\": track.get(\"duration_ms\")\n", + "}\n", + "\n", + "track_info" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "64eb9980-ea6b-4a41-899e-f9ee4f694de9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Abracadabra None\n", + "Always Remember Us This Way None\n", + "Bad Romance None\n", + "Die With A Smile None\n", + "Telephone None\n", + "Alejandro None\n", + "Poker Face None\n", + "The Dead Dance None\n", + "Shallow None\n", + "Judas None\n" + ] + } + ], + "source": [ + "for item in results[\"tracks\"][\"items\"]:\n", + " full = sp.track(item[\"id\"])\n", + " print(full.get(\"name\"), full.get(\"popularity\"))" ] }, { @@ -315,10 +1621,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "id": "8bcdccfc-dde9-4f4b-8af5-3caa335b89b5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'spotify:track:2plbrEY59IikOBgBGLjaoe'" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "results[\"tracks\"][\"items\"][0][\"uri\"]" ] @@ -382,12 +1699,123 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "id": "29694252-f217-454d-8881-681b2b6eeb1e", "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "artists=[\"Ed Sheeran\", \"Alex Warren\", \"Elena Rose\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "f929430e-e9c2-47a9-8462-b88485418a71", + "metadata": {}, + "outputs": [], + "source": [ + "def get_top_tracks(artist_name):\n", + " result = sp.search(q=artist_name, type='artist', limit=1)\n", + "\n", + " artists_found = result[\"artists\"][\"items\"]\n", + "\n", + " if not artists_found:\n", + " return []\n", + "\n", + " artist_id = artists_found[0][\"id\"]\n", + "\n", + " top_tracks = sp.artist_top_tracks(artist_id, country='US')\n", + "\n", + " return [track[\"name\"] for track in top_tracks[\"tracks\"][:5]]" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "51ccd2b7-4c9c-427a-9fca-c1d3a06a7117", + "metadata": {}, + "outputs": [], + "source": [ + "# Note:\n", + "# Spotify removed the endpoint used to fetch an artist's official top tracks\n", + "# (GET /artists/{id}/top-tracks) in February 2026.\n", + "# To continue the exercise, i approximate the result by searching tracks for the artist\n", + "# and keeping the first 5 matches." + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "29e5a046-a98c-4b82-9e9f-733ef70295ee", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks with Params: {'country': 'US'} returned 403 due to Forbidden\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[51]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mget_top_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mEd Sheeran\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[49]\u001b[39m\u001b[32m, line 11\u001b[39m, in \u001b[36mget_top_tracks\u001b[39m\u001b[34m(artist_name)\u001b[39m\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m []\n\u001b[32m 9\u001b[39m artist_id = artists_found[\u001b[32m0\u001b[39m][\u001b[33m\"\u001b[39m\u001b[33mid\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m---> \u001b[39m\u001b[32m11\u001b[39m top_tracks = \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43martist_top_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[43martist_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mUS\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m [track[\u001b[33m\"\u001b[39m\u001b[33mname\u001b[39m\u001b[33m\"\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m track \u001b[38;5;129;01min\u001b[39;00m top_tracks[\u001b[33m\"\u001b[39m\u001b[33mtracks\u001b[39m\u001b[33m\"\u001b[39m][:\u001b[32m5\u001b[39m]]\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:454\u001b[39m, in \u001b[36mSpotify.artist_top_tracks\u001b[39m\u001b[34m(self, artist_id, country)\u001b[39m\n\u001b[32m 448\u001b[39m warnings.warn(\n\u001b[32m 449\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou\u001b[39m\u001b[33m'\u001b[39m\u001b[33mre using `artist_top_tracks(...)`, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 450\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mwhich is marked as deprecated by Spotify.\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 451\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 452\u001b[39m )\n\u001b[32m 453\u001b[39m trid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33martist\u001b[39m\u001b[33m\"\u001b[39m, artist_id)\n\u001b[32m--> \u001b[39m\u001b[32m454\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43martists/\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrid\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/top-tracks\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None" + ] + } + ], + "source": [ + "get_top_tracks(\"Ed Sheeran\")" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "3faefafe-8c2a-4beb-b0e6-8d545a3c391d", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks with Params: {'country': 'US'} returned 403 due to Forbidden\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[52]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43martist_top_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[43martist_id\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:454\u001b[39m, in \u001b[36mSpotify.artist_top_tracks\u001b[39m\u001b[34m(self, artist_id, country)\u001b[39m\n\u001b[32m 448\u001b[39m warnings.warn(\n\u001b[32m 449\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou\u001b[39m\u001b[33m'\u001b[39m\u001b[33mre using `artist_top_tracks(...)`, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 450\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mwhich is marked as deprecated by Spotify.\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 451\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 452\u001b[39m )\n\u001b[32m 453\u001b[39m trid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33martist\u001b[39m\u001b[33m\"\u001b[39m, artist_id)\n\u001b[32m--> \u001b[39m\u001b[32m454\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43martists/\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrid\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/top-tracks\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 403, code: -1 - https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02/top-tracks?country=US:\n Forbidden, reason: None" + ] + } + ], + "source": [ + "sp.artist_top_tracks(artist_id)" ] }, { @@ -404,10 +1832,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 53, "id": "25fb0cf8-c13a-41b0-b8f8-7e0700fd1e41", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/browse/featured-playlists with Params: {'locale': None, 'country': None, 'timestamp': None, 'limit': 20, 'offset': 0} returned 403 due to Forbidden\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 403, code: -1 - https://api.spotify.com/v1/browse/featured-playlists?limit=20&offset=0:\n Forbidden, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/browse/featured-playlists?limit=20&offset=0", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[53]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfeatured_playlists\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# We get a playlist id of a playlist we like\u001b[39;00m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:1721\u001b[39m, in \u001b[36mSpotify.featured_playlists\u001b[39m\u001b[34m(self, locale, country, timestamp, limit, offset)\u001b[39m\n\u001b[32m 1692\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Get a list of Spotify featured playlists\u001b[39;00m\n\u001b[32m 1693\u001b[39m \n\u001b[32m 1694\u001b[39m \u001b[33;03m .. deprecated::\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 1714\u001b[39m \u001b[33;03m items.\u001b[39;00m\n\u001b[32m 1715\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 1716\u001b[39m warnings.warn(\n\u001b[32m 1717\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou\u001b[39m\u001b[33m'\u001b[39m\u001b[33mre using `featured_playlists(...)`, \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 1718\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mwhich is marked as deprecated by Spotify.\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 1719\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 1720\u001b[39m )\n\u001b[32m-> \u001b[39m\u001b[32m1721\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1722\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mbrowse/featured-playlists\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 1723\u001b[39m \u001b[43m \u001b[49m\u001b[43mlocale\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlocale\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1724\u001b[39m \u001b[43m \u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcountry\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1725\u001b[39m \u001b[43m \u001b[49m\u001b[43mtimestamp\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimestamp\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1726\u001b[39m \u001b[43m \u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1727\u001b[39m \u001b[43m \u001b[49m\u001b[43moffset\u001b[49m\u001b[43m=\u001b[49m\u001b[43moffset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1728\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 403, code: -1 - https://api.spotify.com/v1/browse/featured-playlists?limit=20&offset=0:\n Forbidden, reason: None" + ] + } + ], "source": [ "sp.featured_playlists() # We get a playlist id of a playlist we like" ] @@ -431,10 +1886,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "id": "46d35121-9256-4cf4-81f5-118b87f7af32", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ with Params: {'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ?additional_types=track:\n Resource not found, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 404 Client Error: Not Found for url: https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ?additional_types=track", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[54]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m playlist_id = \u001b[33m\"\u001b[39m\u001b[33m37i9dQZF1DXd9zR7tdziuQ\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m playlist = \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43mplaylist\u001b[49m\u001b[43m(\u001b[49m\u001b[43mplaylist_id\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:682\u001b[39m, in \u001b[36mSpotify.playlist\u001b[39m\u001b[34m(self, playlist_id, fields, market, additional_types)\u001b[39m\n\u001b[32m 671\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Gets playlist by id.\u001b[39;00m\n\u001b[32m 672\u001b[39m \n\u001b[32m 673\u001b[39m \u001b[33;03m Parameters:\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 679\u001b[39m \u001b[33;03m valid types are: track and episode\u001b[39;00m\n\u001b[32m 680\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 681\u001b[39m plid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33mplaylist\u001b[39m\u001b[33m\"\u001b[39m, playlist_id)\n\u001b[32m--> \u001b[39m\u001b[32m682\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 683\u001b[39m \u001b[43m \u001b[49m\u001b[33;43mf\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mplaylists/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mplid\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 684\u001b[39m \u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfields\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 685\u001b[39m \u001b[43m \u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 686\u001b[39m \u001b[43m \u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m,\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 687\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ?additional_types=track:\n Resource not found, reason: None" + ] + } + ], "source": [ "playlist_id = \"37i9dQZF1DXd9zR7tdziuQ\"\n", "playlist = sp.playlist(playlist_id)" @@ -442,10 +1924,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 56, "id": "5260f67f-6024-4fee-8449-30904f03bf76", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'playlist' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[56]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[43mplaylist\u001b[49m[\u001b[33m'\u001b[39m\u001b[33mname\u001b[39m\u001b[33m'\u001b[39m]) \u001b[38;5;66;03m# Print the playlist's name\u001b[39;00m\n\u001b[32m 2\u001b[39m \u001b[38;5;28mprint\u001b[39m(playlist[\u001b[33m'\u001b[39m\u001b[33mdescription\u001b[39m\u001b[33m'\u001b[39m]) \u001b[38;5;66;03m# Print the playlist's description\u001b[39;00m\n", + "\u001b[31mNameError\u001b[39m: name 'playlist' is not defined" + ] + } + ], "source": [ "print(playlist['name']) # Print the playlist's name\n", "print(playlist['description']) # Print the playlist's description" @@ -462,10 +1956,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "id": "69c78f8d-7e6a-4d15-bcbb-fc93edb82433", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items with Params: {'limit': 50, 'offset': 0, 'fields': None, 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found\n" + ] + }, + { + "ename": "SpotifyException", + "evalue": "http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items?limit=50&offset=0&additional_types=track:\n Resource not found, reason: None", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mHTTPError\u001b[39m Traceback (most recent call last)", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:271\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 266\u001b[39m response = \u001b[38;5;28mself\u001b[39m._session.request(\n\u001b[32m 267\u001b[39m method, url, headers=headers, proxies=\u001b[38;5;28mself\u001b[39m.proxies,\n\u001b[32m 268\u001b[39m timeout=\u001b[38;5;28mself\u001b[39m.requests_timeout, **args\n\u001b[32m 269\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m271\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 272\u001b[39m results = response.json()\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\requests\\models.py:1026\u001b[39m, in \u001b[36mResponse.raise_for_status\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1025\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response=\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[31mHTTPError\u001b[39m: 404 Client Error: Not Found for url: https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items?limit=50&offset=0&additional_types=track", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[31mSpotifyException\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[55]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m tracks = \u001b[43msp\u001b[49m\u001b[43m.\u001b[49m\u001b[43mplaylist_tracks\u001b[49m\u001b[43m(\u001b[49m\u001b[43mplaylist_id\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 2\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m track \u001b[38;5;129;01min\u001b[39;00m tracks[\u001b[33m'\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m'\u001b[39m]:\n\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(track[\u001b[33m'\u001b[39m\u001b[33mtrack\u001b[39m\u001b[33m'\u001b[39m][\u001b[33m'\u001b[39m\u001b[33mname\u001b[39m\u001b[33m'\u001b[39m]) \u001b[38;5;66;03m# Print each track's name\u001b[39;00m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:718\u001b[39m, in \u001b[36mSpotify.playlist_tracks\u001b[39m\u001b[34m(self, playlist_id, fields, limit, offset, market, additional_types)\u001b[39m\n\u001b[32m 698\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Get full details of the tracks of a playlist.\u001b[39;00m\n\u001b[32m 699\u001b[39m \n\u001b[32m 700\u001b[39m \u001b[33;03m .. deprecated::\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 711\u001b[39m \u001b[33;03m valid types are: track and episode\u001b[39;00m\n\u001b[32m 712\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 713\u001b[39m warnings.warn(\n\u001b[32m 714\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mYou should use `playlist_items(playlist_id, ...,\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 715\u001b[39m \u001b[33m\"\u001b[39m\u001b[33madditional_types=(\u001b[39m\u001b[33m'\u001b[39m\u001b[33mtrack\u001b[39m\u001b[33m'\u001b[39m\u001b[33m,))` instead\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 716\u001b[39m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m,\n\u001b[32m 717\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m718\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mplaylist_items\u001b[49m\u001b[43m(\u001b[49m\u001b[43mplaylist_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moffset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 719\u001b[39m \u001b[43m \u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:742\u001b[39m, in \u001b[36mSpotify.playlist_items\u001b[39m\u001b[34m(self, playlist_id, fields, limit, offset, market, additional_types)\u001b[39m\n\u001b[32m 730\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\" Get full details of the tracks and episodes of a playlist.\u001b[39;00m\n\u001b[32m 731\u001b[39m \n\u001b[32m 732\u001b[39m \u001b[33;03m Parameters:\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 739\u001b[39m \u001b[33;03m valid types are: track and episode\u001b[39;00m\n\u001b[32m 740\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 741\u001b[39m plid = \u001b[38;5;28mself\u001b[39m._get_id(\u001b[33m\"\u001b[39m\u001b[33mplaylist\u001b[39m\u001b[33m\"\u001b[39m, playlist_id)\n\u001b[32m--> \u001b[39m\u001b[32m742\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 743\u001b[39m \u001b[43m \u001b[49m\u001b[33;43mf\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mplaylists/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mplid\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m/items\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 744\u001b[39m \u001b[43m \u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlimit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 745\u001b[39m \u001b[43m \u001b[49m\u001b[43moffset\u001b[49m\u001b[43m=\u001b[49m\u001b[43moffset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 746\u001b[39m \u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfields\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 747\u001b[39m \u001b[43m \u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmarket\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 748\u001b[39m \u001b[43m \u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m,\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43madditional_types\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 749\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:321\u001b[39m, in \u001b[36mSpotify._get\u001b[39m\u001b[34m(self, url, args, payload, **kwargs)\u001b[39m\n\u001b[32m 318\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m args:\n\u001b[32m 319\u001b[39m kwargs.update(args)\n\u001b[32m--> \u001b[39m\u001b[32m321\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_internal_call\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGET\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpayload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~\\AppData\\Local\\Programs\\Python\\Python314\\Lib\\site-packages\\spotipy\\client.py:291\u001b[39m, in \u001b[36mSpotify._internal_call\u001b[39m\u001b[34m(self, method, url, payload, params)\u001b[39m\n\u001b[32m 286\u001b[39m reason = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 288\u001b[39m logger.error(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mHTTP Error for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m with Params: \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 289\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs.get(\u001b[33m'\u001b[39m\u001b[33mparams\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m returned \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m due to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m291\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m SpotifyException(\n\u001b[32m 292\u001b[39m response.status_code,\n\u001b[32m 293\u001b[39m -\u001b[32m1\u001b[39m,\n\u001b[32m 294\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.url\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmsg\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m 295\u001b[39m reason=reason,\n\u001b[32m 296\u001b[39m headers=response.headers,\n\u001b[32m 297\u001b[39m )\n\u001b[32m 298\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m requests.exceptions.RetryError \u001b[38;5;28;01mas\u001b[39;00m retry_error:\n\u001b[32m 299\u001b[39m request = retry_error.request\n", + "\u001b[31mSpotifyException\u001b[39m: http status: 404, code: -1 - https://api.spotify.com/v1/playlists/37i9dQZF1DXd9zR7tdziuQ/items?limit=50&offset=0&additional_types=track:\n Resource not found, reason: None" + ] + } + ], "source": [ "tracks = sp.playlist_tracks(playlist_id)\n", "for track in tracks['items']:\n", @@ -488,10 +2010,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "id": "65c5e5c4-f186-42c6-b136-4ef02b0b01ff", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'tracks' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[57]\u001b[39m\u001b[32m, line 4\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# List to store unique artist names\u001b[39;00m\n\u001b[32m 2\u001b[39m artists_list = []\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m track_item \u001b[38;5;129;01min\u001b[39;00m \u001b[43mtracks\u001b[49m[\u001b[33m'\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m'\u001b[39m]:\n\u001b[32m 5\u001b[39m track = track_item[\u001b[33m'\u001b[39m\u001b[33mtrack\u001b[39m\u001b[33m'\u001b[39m]\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m artist \u001b[38;5;129;01min\u001b[39;00m track[\u001b[33m'\u001b[39m\u001b[33martists\u001b[39m\u001b[33m'\u001b[39m]:\n", + "\u001b[31mNameError\u001b[39m: name 'tracks' is not defined" + ] + } + ], "source": [ "# List to store unique artist names\n", "artists_list = []\n", @@ -537,9 +2071,7 @@ "id": "ed92d961-9646-4375-a386-ccc320a958f5", "metadata": {}, "outputs": [], - "source": [ - "# Your answer here" - ] + "source": [] } ], "metadata": { @@ -558,7 +2090,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.3" } }, "nbformat": 4,