Skip to content

Commit

Permalink
fix: minor md changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Dec 21, 2023
1 parent 5365b3d commit fba0d53
Showing 1 changed file with 9 additions and 297 deletions.
306 changes: 9 additions & 297 deletions Spotify/Spotify_Get_User_Top_Items.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "595c14e7-69e4-4108-96aa-f6c2550080c9",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-14T06:15:13.190514Z",
"iopub.status.busy": "2023-12-14T06:15:13.190241Z",
"iopub.status.idle": "2023-12-14T06:15:16.971383Z",
"shell.execute_reply": "2023-12-14T06:15:16.970642Z",
"shell.execute_reply.started": "2023-12-14T06:15:13.190438Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"try:\n",
Expand Down Expand Up @@ -116,17 +108,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "a85464c9-9731-4227-9597-ab45681a1452",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-14T06:15:16.972955Z",
"iopub.status.busy": "2023-12-14T06:15:16.972742Z",
"iopub.status.idle": "2023-12-14T06:15:16.975769Z",
"shell.execute_reply": "2023-12-14T06:15:16.975168Z",
"shell.execute_reply.started": "2023-12-14T06:15:16.972932Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"client_id = \"YOUR_SPOTIFY_CLIENT_ID\"\n",
Expand All @@ -150,31 +134,17 @@
"id": "c974d949-274e-420f-be08-83f827f543e7",
"metadata": {},
"source": [
"### Get user top items"
]
},
{
"cell_type": "markdown",
"id": "f318fcd0-7d10-49ac-995f-5d086d45f1e5",
"metadata": {},
"source": [
"### Get user top items\n",
"* Retrieve current logged in user's top items both tracks and artists.\n",
"* Authenticates the user by redirecting the user to the uri and user must then authorize and copy the code in the URL and paste in the input.\n",
"* Once user is authenticated, `fetch_top_items` can not print the top items."
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "6a9e38d6-92a4-4891-8b5c-0a7135d9704a",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-14T06:15:16.977507Z",
"iopub.status.busy": "2023-12-14T06:15:16.977090Z",
"iopub.status.idle": "2023-12-14T06:15:17.091070Z",
"shell.execute_reply": "2023-12-14T06:15:17.090455Z",
"shell.execute_reply.started": "2023-12-14T06:15:16.977477Z"
},
"tags": []
},
"outputs": [],
Expand Down Expand Up @@ -248,277 +218,19 @@
"id": "d0585798-7543-485d-af14-b5c520620871",
"metadata": {},
"source": [
"### Display result"
]
},
{
"cell_type": "markdown",
"id": "4cd8c911-3df8-4147-833c-3867704a1d4d",
"metadata": {},
"source": [
"### Display result\n",
"* Calls the `authenticate_spotify` function to authenticate user then stores the client in the `spotify_client` variable.\n",
"* If `spotify_client` is available, then pass the client into `fetch_top_items` function and print out relevant information."
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "b5c9703e-cc72-48a2-9856-1f846c036cdc",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-14T06:15:17.092395Z",
"iopub.status.busy": "2023-12-14T06:15:17.092022Z",
"iopub.status.idle": "2023-12-14T06:15:19.762570Z",
"shell.execute_reply": "2023-12-14T06:15:19.761936Z",
"shell.execute_reply.started": "2023-12-14T06:15:17.092364Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Please visit this URL to authorize the application: https://accounts.spotify.com/authorize?client_id=c112067061f74b66ba1bbf813eacbc08&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8889%2Fcallback&scope=user-library-read+user-top-read\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter the authorization code from the URL: AQBEgKsNu7MYYOwYwo4ZOjtSsZTd97ytBVfLpJbGG1tmpvQJFMgnHKGrzFEFb-E7gUoWIR6txZrYxCZQYXr5WFCPpBPgRfW_xt7f0ebW3AmYx5iouy6wPmY2zd_Rmesy9Pv4Pacm4aznCDcxntom4OUt8SppP0hmToGDg_4B-ZL_CtO9bp2bS6-kpnS1JtLsh71wIZWGZ51riYVFQxexK0LuHu8\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully authenticated\n",
"\n",
"Top tracks:\n",
"1. FE!N (feat. Playboi Carti) by Travis Scott, Track ID: 42VsgItocQwOQC3XWZ8JNA\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"<ipython-input-3-d10b283b300c>:15: DeprecationWarning: You're using 'as_dict = True'.get_access_token will return the token string directly in future versions. Please adjust your code accordingly, or use get_cached_token instead.\n",
" token_info = sp.auth_manager.get_access_token(authorization_code)\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab67616d0000b273881d8d8378cd01099babcd44\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"2. Long Time - Intro by Playboi Carti, Track ID: 4IO2X2YoXoUMv0M2rwomLC\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab67616d0000b273a1e867d40e7bb29ced5c0194\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"3. Flex by Playboi Carti, Track ID: 2xyBvir9n474qfsOkxXMgx\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab67616d0000b273e31a279d267f3b3d8912e6f1\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"4. R.I.P. by Playboi Carti, Track ID: 3L0IKstjUgDFVQAbQIRZRv\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab67616d0000b273a1e867d40e7bb29ced5c0194\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"5. Streetcar by Daniel Caesar, Track ID: 7Cu2COdH93MnuireuKNiS3\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab67616d0000b273a117ac19ee51aebdf05fe88c\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\n",
"Top artists:\n",
"1. Playboi Carti, Artist ID: 699OTQXzgjhIYAHMy9RyPD\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab6761610000e5eb504ff11d788162fbf8078654\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"2. Daniel Caesar, Artist ID: 20wkVLutqVOYrc0kxFs7rA\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab6761610000e5ebe5bc630548fb3517cf90edb8\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"3. Dominic Fike, Artist ID: 6USv9qhCn6zfxlBQIYJ9qs\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab6761610000e5ebbe491d3676793a1697c61254\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"4. Trippie Redd, Artist ID: 6Xgp2XMz1fhVYe7i6yNAax\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab6761610000e5ebf2db81b3312a1f167fc54096\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"5. Travis Scott, Artist ID: 0Y5tJX1MQlPlqiwlOH1tJY\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://i.scdn.co/image/ab6761610000e5eb19c2790744c792d05570bb71\" width=\"200\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n"
]
}
],
"outputs": [],
"source": [
"spotify_client = authenticate_spotify(client_id, client_secret, redirect_uri)\n",
"if spotify_client:\n",
Expand Down

0 comments on commit fba0d53

Please sign in to comment.