Closed riverscuomo closed 3 months ago
Hello,
If I understand correctly this is a first step for creating a web app interface for spotkin. I would be happy to possibly contribute. How would Spotify authentication be done? Is each user supposed to clone and build their own server and client with their own dev keys? Should spotkin become a Spotify app? Or is there another direction for the project you were envisioning?
Thanks, scotch101tape
@Scotch101Tape I've almost started this web app many times over the last 5 years. Still on the fence. I hesitate, in part, because I'm not sure how useful it will be for the general public. I've used this script almost every day for years. About 75% of my music listening has been through my Spotkin playlist. But maybe I have unusual needs as a listener. I like to listen to a ton of music I haven't heard before, and I've heard a lot. So basically, Spotify's recommendations are pretty useless to me, such as the Beatles the Beach Boys or heaven forbid, Weezer. I also like to listen to a lot of OLD music I haven't heard before, which counters the interests of the music industry trying to push their latest wares. And I like to listen to a wide range of genres. All this at the same time as not wanting to spend time fiddling around with Spotify's app. I want all of it in one playlist, generated fresh every day. Hence, Spotkin.
My latest idea was to start by deploying a server out of the existing code here, maybe on Heroku. Then we could experiment with different front ends. I'm imagining a free web app that would save the user's settings and ping the server when it's time to regenerate their playlist. Hopefully we could avoid having to save user accounts in a database, because that's where things start to get expensive. Maybe save their settings in browser storage?
I deployed a terrible version of this app a while back and I was disappointed that users didn't use it like I did -- they were just adding their favorite artists and listening to the same old songs -- rather than adding a wide range of dynamic playlists, which is where Spotkin really shines.
Yes, making Spotkin a Spotify app sounds like a good idea.
Also, creating a spreadsheet for the user's settings seems like a decent simple solution #13
ok this endpoint works now
I guess we need to create a different spotify client for each user that makes one of these POST requests.
Hey how's it going - this idea sounds really interesting to me. I would be interested in contributing where I can. As someone who has tried a bunch of different services, I spend a lot of time thinking about the perfect music streaming platform, or at the very least how to possibly leverage existing ones' APIs for my own personal use/benefit.
On the python side, I don't have experience with Flask in particular, but I do with FastAPI as well as Django. Frontend wise my experience is with Typescript/JS frameworks mostly, not familiar with Flutter (but interested)
I guess we need to create a different spotify client for each user that makes one of these POST requests.
^ If I'm understanding correctly, i think your web app would be the sole "spotify client" as far as the spotify API is concerned. So each of your users wouldn't need a spotify client.
But yes, the idea would be to authorize users to use your app. In a really general sense, you could redirect your users to Spotify and make then confirm authorization. It looks like Spotipy
has an option to do this: https://spotipy.readthedocs.io/en/2.24.0/index.html#spotipy.oauth2.SpotifyOAuth.get_authorize_url
(similar to when you want to log into a web app with google, you get redirected to sign in to google and confirm letting that web app access your google account).
Once confirming to Spotify, the user would get redirected back to the Spotkin app with confirmed auth, usually in the form of an access/bearer token. The user would then use their access token to make request to the spotify API.
Anyways, hopefully there's something helpful in there. Not an expert with spotify's API so it could end up being different than as I've described.
@alex-dulac Thanks! this is exactly right:
But yes, the idea would be to authorize users to use your app. In a really general sense, you could redirect your users to Spotify and make then confirm authorization. It looks like Spotipy has an option to do this: https://spotipy.readthedocs.io/en/2.24.0/index.html#spotipy.oauth2.SpotifyOAuth.get_authorize_url (similar to when you want to log into a web app with google, you get redirected to sign in to google and confirm letting that web app access your google account). Once confirming to Spotify, the user would get redirected back to the Spotkin app with confirmed auth, usually in the form of an access/bearer token. The user would then use their access token to make request to the spotify API.
I'd love any other help you can offer. Feel free to mess around and I'll get back to you soon with some more ideas.
most of the server logic is already in place for the command line script we have here. I imagine that it's agnostic to the question of which framework we use. I think the server architecture that wraps around the existing logic will be very simple. (I already made one endpoint to update the user playlists according to their settings). I chose Flask because I know it and because it's simple to set up but Fast Api or Django could work too.
I'm able to run the Flask server locally and hit it with Postman. It updates my playlists according to the payload I put into Postman.
Seems like there could be multiple clients in different frameworks. I like Flutter because I know it and because you don't have to mess with HTML and CSS but I'm interested in the frameworks you mentioned too.
Cool, your notes make sense to me! I'd say use whatever frameworks you'd like. Flask and Flutter sounds great.
Just another thought (if you haven't thought it already) - you could create a dummy Spotify account and/or dummy playlists to play around with the server and web app if you want. That way, you can keep using your python script to update your own playlist for daily use without interruption.
Ok, I have a basic server deployed on Heroku to process the jobs. And a flutter web client that gets the spotify user auth and then pings the server with a sample jobs request. It successfully updates the sample spotify playlist. https://github.com/riverscuomo/spotkin_flutter
Next up would be
server
most of the server logic is already in place for the command line script we have here. I imagine that it's agnostic to the question of which framework we use. I think the server architecture that wraps around the existing logic will be very simple. (I already made one endpoint to update the user playlists according to their settings). I chose Flask because I know it and because it's simple to set up but Fast Api or Django could work too.
I'm able to run the Flask server locally and hit it with Postman. It updates my playlists according to the payload I put into Postman.
Another import endpoint will be for the user to update their settings.(now that I think about it, I'd like to try to get away with storing user settings in the client's local storage)web app client
Seems like there could be multiple clients in different frameworks. I like Flutter because I know it and because you don't have to mess with HTML and CSS but I'm interested in the frameworks you mentioned too.