Skip to content

Commit

Permalink
get currently playing song
Browse files Browse the repository at this point in the history
  • Loading branch information
rangsimanketkaew committed Oct 23, 2022
1 parent 0c38421 commit dd3b7b7
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions notebooks/skiptify_get_currently_song.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"import spotipy\n",
"\n",
"from sklearn.metrics import pairwise_distances\n",
"from my_token import *"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"scope = 'user-read-currently-playing'\n",
"# scope = 'user-modify-playback-state'\n",
"# scope = 'user-read-recently-played'\n",
"\n",
"# To connect succesfully you need to provide your own Spotify Credentials\n",
"# You can do this signing up in https://developer.spotify.com/ and creating a new app.\n",
"token = spotipy.util.prompt_for_user_token(\n",
" USERNAME, scope, client_id=SPOTIPY_CLIENT_ID, client_secret=SPOTIPY_CLIENT_SECRET, redirect_uri=SPOTIPY_REDIRECT_URI)\n",
"\n",
"sp = spotipy.Spotify(auth=token)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'3c8iiZGfEammKJuWTErE5x'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# method currently playing return an actual song on Spotify\n",
"current_song = sp.currently_playing()\n",
"current_song['item']['id']"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.13 ('base')",
"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.9.13"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "c6e4e9f98eb68ad3b7c296f83d20e6de614cb42e90992a65aa266555a3137d0d"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit dd3b7b7

Please sign in to comment.