[GH-ISSUE #226] Now playing example #115

Closed
opened 2026-02-27 23:20:54 +03:00 by kerem · 8 comments
Owner

Originally created by @Bluscream on GitHub (Oct 29, 2017).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/226

Could you provide a example py script how to obtain infos about the song currently played by the user?

Originally created by @Bluscream on GitHub (Oct 29, 2017). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/226 Could you provide a example py script how to obtain infos about the song currently played by the user?
kerem closed this issue 2026-02-27 23:20:55 +03:00
Author
Owner

@ritiek commented on GitHub (Oct 29, 2017):

Here is a quick one:

import spotipy
import spotipy.util as util
 
scope = 'user-read-currently-playing'
# scope = 'user-read-playback-state'
# works as well

token = util.prompt_for_user_token(username, scope, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri)

spotify = spotipy.Spotify(auth=token)
current_track = spotify.current_user_playing_track()

print(current_track)
<!-- gh-comment-id:340277599 --> @ritiek commented on GitHub (Oct 29, 2017): Here is a quick one: ```python import spotipy import spotipy.util as util scope = 'user-read-currently-playing' # scope = 'user-read-playback-state' # works as well token = util.prompt_for_user_token(username, scope, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri) spotify = spotipy.Spotify(auth=token) current_track = spotify.current_user_playing_track() print(current_track) ```
Author
Owner

@Bluscream commented on GitHub (Oct 29, 2017):

Does this use the local client? It should be compatible with the native windows/linux/mac app and the windows store version

If yes, whats the best way to ask the user for his auth info? and would spotify.current_user_playing_artist() give back a list of artists or just a comma seperated string?

<!-- gh-comment-id:340278637 --> @Bluscream commented on GitHub (Oct 29, 2017): Does this use the local client? It should be compatible with the native windows/linux/mac app and the windows store version If yes, whats the best way to ask the user for his auth info? and would `spotify.current_user_playing_artist()` give back a list of artists or just a comma seperated string?
Author
Owner

@joeborrello commented on GitHub (Dec 9, 2017):

I just tried running that same script with my own credentials added and I got an error returned: 'Spotify' object has no attribute 'current_user_playing_track'

Any ideas why that might be happening?

<!-- gh-comment-id:350510549 --> @joeborrello commented on GitHub (Dec 9, 2017): I just tried running that same script with my own credentials added and I got an error returned: 'Spotify' object has no attribute 'current_user_playing_track' Any ideas why that might be happening?
Author
Owner

@aszc-dev commented on GitHub (Jan 9, 2018):

It's probably because of issue https://github.com/plamere/spotipy/issues/211

<!-- gh-comment-id:356231916 --> @aszc-dev commented on GitHub (Jan 9, 2018): It's probably because of issue https://github.com/plamere/spotipy/issues/211
Author
Owner

@mitchellpalermo commented on GitHub (Mar 10, 2018):

This is still happening to me even with 2.4.4 installed. Funny enough when I compile in my text editor(Atom) it works fine. But when I run this from the terminal, it gives me that same error that @joeborrello got.

<!-- gh-comment-id:372010009 --> @mitchellpalermo commented on GitHub (Mar 10, 2018): This is still happening to me even with 2.4.4 installed. Funny enough when I compile in my text editor(Atom) it works fine. But when I run this from the terminal, it gives me that same error that @joeborrello got.
Author
Owner

@discotwitch commented on GitHub (May 15, 2018):

@mitchellpalermo if you run the code spotipy.VERSION does it return 2.0.1 or 2.4.4? Even when it pip says you've install 2.4.4, its actually 2.0.1 This is what fixed it for me

<!-- gh-comment-id:389080853 --> @discotwitch commented on GitHub (May 15, 2018): @mitchellpalermo if you run the code spotipy.VERSION does it return 2.0.1 or 2.4.4? Even when it pip says you've install 2.4.4, its actually 2.0.1 [This](https://stackoverflow.com/questions/47028093/attributeerror-spotify-object-has-no-attribute-current-user-saved-tracks) is what fixed it for me
Author
Owner

@Bluscream commented on GitHub (May 18, 2018):

I just got spotify from https://github.com/plamere/spotipy/archive/master.zip but

>>> import spotipy

>>> spotipy.VERSION

'2.0.1'
<!-- gh-comment-id:390200183 --> @Bluscream commented on GitHub (May 18, 2018): I just got spotify from https://github.com/plamere/spotipy/archive/master.zip but ``` >>> import spotipy
 >>> spotipy.VERSION
 '2.0.1' ```
Author
Owner

@stephanebruckert commented on GitHub (Jan 1, 2020):

Closing as everything looks answered or depends on another issue

<!-- gh-comment-id:570081138 --> @stephanebruckert commented on GitHub (Jan 1, 2020): Closing as everything looks answered or depends on another issue
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#115
No description provided.