-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement: show spotify code of current radio track #61
Comments
Hello, Yes, I find tk.inter a bit confusing as well, essentially you'll want to declare a new label and anchor it to the top right (or NE) as follows in display_controller.py: self.label_spotify_code = tk.Label( For ease of reference I would insert this in the same place where all the other tk.inter frames and labels are assigned... The x= and y= values will indent the graphic a little from the edge. This label is attached to album_frame so it should show whenever album art is displayed. The final thing you need to do is to populate the label with your Spotify Code graphic, adding the following towards the end of display_controller.py where the similar code to populate the album art should do it: self.label_spotify_code.configure(image=link to spotify code or variable which contains the graphic), this is the bit I'm struggling with but you mention that you are able to construct the hyperlink so hopefully that will work. I hope this points in enough of the right direction to get your idea working. |
Hello, Great to hear you've been successful, label placement is definitely tricky in tkinter. I've been trying to get this working as well, and have managed to implement code that allows the user to select whether they want to display the Spotify Code or not through a setting in the sonos_settings.py file. What I can't do is the Spotipy artist and song name search to return the Spotify URI for songs... I've uploaded these changes to my upto date repository ashenshugarRET/music-screen-api for this program, perhaps if we can collaborate we can contribute the results back to the Hankhank10's parent project |
Sure, let's do it. 👍 The Spotify integration isn't that complicated with the Spotipy library. In sonos_settings.py I added two additional attributes which are needed for the spotify authentication. You have to create a new client in the Dashboard to obtain them:
I imported Spotipy in sonos_user_data.py at the top:
With these 3 additional functions I'm retrieving the Spotify metadata:
First of all, the code needs refactoring or cleanup, I know. The thing is that all german radio stations transmit both artist and title combined as title. So I have to parse both values from the title because you get the best search results from Spotify when asking for both artist and title separated. I also clean the title and remove things like "(Radio Edit) etc. The problem here is, that every radio station shows this information differently, for example So I need a lot of if/else statements to extract the information correctly. On my iPhone in Shorcuts, I'm using a dictionary where I store the radio station as key and an additional dictionary as value where I configure which separator each station is using and whether artist is on the first or second position after splitting. Long story short, in sonos_user_data.py I'm calling the function above in the refresh() function like this:
Please excuse my python skills. I'm "debugging" it with logging. 🙈 |
Thanks, I have an issue importing spotipy, everytime I insert 'import spotipy' into the top of sonos_user_data.py the program crashes on booting producing the following errors Traceback (most recent call last): It's clearly a local issue form me as you are successfully using Spotipy with your installation |
Did you install the lib successfully with
? |
Yes, I think I installed spotipy successfully, I used the exact instruction you mention. I can import it into standalone scripts and access and search Spotify successfully. The problem only appears when I try importing into sonos_user_data.py, go_sonos_highres.py or display_controller.py... I will investigate by installing from a fresh Raspberry Pi image, like you I don't have much time available this side of Christmas, so this will be a New Year Project UPDATE: Fixed it was a permissions issue as I had set go_sonos_highres.py to start as sudo which must have been causing conflicts. |
To provide an update, I now have the Spotify Code showing reliably when the spotipy search returns a result, when no result is returned no code is displayed. |
Hello, I've completed my implementation of showing Spotify Codes as well as using Spotify's album art, these should be getting merged into the main repository soon. I woujld imagine @hankhank10 will close this issue once that is done. Thanks |
Not really an issue, but I kindly ask if someone would help me to show an additional image (Spotify code) as overlay of the cover (see preview below).
Background:
I never wrote any python code before but managed to integrate Spotipy (in sonos_user_data.py). I'm using it to show cover art of the current track on (mostly german) radio stations. I'm reading both artist and track name from the radio text, query Spotify, get the cover url and set it as background image (image_uri). This already works pretty good.
As a bonus, since I already have the spotify metadata, I'd like to show the spotify code as well. It's kind of a qr code that can be scanned in the Spotify app to play the track. I already know how to get the code, I just have to put the spotify track uri at the end of this url to download the image with the code:
https://scannables.scdn.co/uri/plain/jpeg/368A7D/white/640/spotify:track:5wEoNauEpwOc2rlU0274oT
ToDo:
So all there's left to do is to display this image for example in the upper right of the cover art (as overlay). I'm struggling how to do that as I don't really understand this tk mechanism (and how to extend label_albumart_detail). Any help is really appreciated.
This is how it shuold look like:
The text was updated successfully, but these errors were encountered: