Create Spotify Playlists Using Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2025
  • In this video, I show a simple Python application that leverages the Spotify Web API to generate Spotify playlists 🎧 🎧 using reference tracks from a user’s listening history.
    By watching the video you can get a feeling of the Spotify Web API, learn about content-based recommendation, and get an idea of how the Spotify’s recommendation algorithm (probably!) works.
    Source Code:
    github.com/mus...
    Join The Sound Of AI Slack community:
    valeriovelardo...
    Interested in hiring me as a consultant/freelancer?
    valeriovelardo...
    Follow Valerio on Facebook:
    / thesoundofai
    Connect with Valerio on Linkedin:
    / valeriovelardo
    Follow Valerio on Twitter:
    / musikalkemist

ความคิดเห็น • 73

  • @Melpat91
    @Melpat91 4 ปีที่แล้ว +4

    Extremely helpful, Valerio! Thank you! I've been working on a Playlist Project for the past month, and been stuck. This was very comprehensive and practical.

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  4 ปีที่แล้ว

      Glad I could help Melissa!

    • @Melpat91
      @Melpat91 4 ปีที่แล้ว

      @@ValerioVelardoTheSoundofAI Thanks for your response! Question: What approach would you use to add UI to this Valerio? I just spent three hours attempting to do so, and so far I’ve added a Spotify authorization page. But I’m not having much luck after that. Any suggestions?

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  4 ปีที่แล้ว +1

      @@Melpat91 I would suggest looking into Kivy, a cross-platform UI library for Python (kivy.org/#home). It's probably the most intuitive UI library out there ;)

    • @Melpat91
      @Melpat91 4 ปีที่แล้ว +1

      @@ValerioVelardoTheSoundofAI Will do! Thanks again!

  • @cacatua2604
    @cacatua2604 4 ปีที่แล้ว +3

    Thank you very much! I'm brazillian and looking forward to making a wpp text become a spotify playlist so that is simpler to choose the best ones to play in my celebration of marriage!! :) let's build it up

  • @K3nn3th
    @K3nn3th 2 ปีที่แล้ว

    THANK YOU SO MUCH, I've been trying to make a program that would give me recommended songs that I liked from spotify's Discover Weekly and it worked perfectly!!

    • @waffle6579
      @waffle6579 2 ปีที่แล้ว

      hey can i ask u some questions?

    • @waffle6579
      @waffle6579 2 ปีที่แล้ว

      are u using window system?

  • @kkevinluke
    @kkevinluke 3 ปีที่แล้ว

    Thanks Valerio, this helped me understand the API call. I've been trying so many ways.

  • @iluvsyphonfilter
    @iluvsyphonfilter 4 ปีที่แล้ว +1

    You explain concepts very well, keep up the good work!

  • @-LTUIiiin
    @-LTUIiiin 4 ปีที่แล้ว

    Thank you so much!!!!!!!!!! I was working on a similar application but kept running into authorization issues. Turns out I was using the wrong flow. I had almost gave up on it for a couple of days... thanks to you I can now get back on track!

  • @stahmedpendragonguinevere2711
    @stahmedpendragonguinevere2711 4 ปีที่แล้ว +1

    Brilliant video thank you! This is awesome, learning Python combined with one of my most use apps!

  • @emko2403
    @emko2403 3 ปีที่แล้ว

    Thank you so much for this video!! It is exactly what I needed for a spotify script I'm trying to implement!!

  • @adolfogilio
    @adolfogilio 7 หลายเดือนก่อน

    How do you get the users token in the new Spotify for developers i cant find it

  • @kennytieshisshoes
    @kennytieshisshoes 4 ปีที่แล้ว

    This is great and a huge help. I am trying to make playlist based on genre so that I can more easily share my music.

  • @talkravarusic8489
    @talkravarusic8489 2 ปีที่แล้ว

    You are great man 👏🏻

  • @gihonglee6167
    @gihonglee6167 2 ปีที่แล้ว

    Fantastic Video. Thank you so much!

  • @freeziellama841
    @freeziellama841 3 ปีที่แล้ว

    Hi super great video just wondering how to access the endpoint to get my user id?

  • @marisolrivera5369
    @marisolrivera5369 2 ปีที่แล้ว

    Thank you so much for this!

  • @gugaweigert
    @gugaweigert ปีที่แล้ว

    Nice video! Thanks for all the explanation!
    One question: Do you think is it possible to create a playlist generator using a nocode plataform like Bubble?
    Thanks!

    • @adolfogilio
      @adolfogilio 7 หลายเดือนก่อน

      how do u get the users token in the new spotify for developers web

  • @espowari
    @espowari 3 ปีที่แล้ว

    I have mp3's local to my hard drive. Is there a way to create a playlist from that?

  • @ktswrld7338
    @ktswrld7338 3 ปีที่แล้ว

    i have a question. Someone keeps false reporting my playlist that has a pretty good following on it... everytime they report spotify just takes my playlist name, photo and description off. Ive tried contacting them but they never reply the reports keep happening and there is nothing wrong with my playlist. me and some other curators are having the same problem and spotify ignores us... Do you think you could help me? I dont know what to do anymore I'm so stressed and upset..

  • @musicface93
    @musicface93 2 ปีที่แล้ว +1

    Hey, awesome video, and I really like the way this program works. I am a new dev and I am trying to get this to work on my machine but I am having difficulties. I activate the virtual environment, set the spotify auth token and userID, but when I run the createplaylist module, after I pass in the value for how many songs I'd like for it to visualize, I receive a keyError for 'items'. I sent you a request to connect on LinkedIn, but I'd like to talk to you more about this program!

    • @ezgikaradag4124
      @ezgikaradag4124 2 ปีที่แล้ว

      hi, can you fix the problem?

    • @thorbjornheise
      @thorbjornheise 2 ปีที่แล้ว

      @@ezgikaradag4124 I don't know what exactly is wrong, but it has to do with the environment variables: If you include a "print(response.json)" in the "last played tracks" function, it will give you error 401: invalid access token.
      I hard coded the credentials, it works fine. You have to edit the first few lines of the main function in the createplaylist.py:
      authorization_token = 'your_authorization_token'
      user_id = 'your_user_id'
      spotify_client = SpotifyClient(authorization_token, user_id)

  • @igberroteran
    @igberroteran 2 ปีที่แล้ว

    amazing, thank you!

  • @travellingaround1724
    @travellingaround1724 3 ปีที่แล้ว

    Awesome video.

  • @drjfilix3192
    @drjfilix3192 3 ปีที่แล้ว

    Hi Valerio, I want to ask you a question:
    I am trying to make a Spotify API that gives me a list of Disco / Funk songs that also tells me the BPM and its key from 1975 to 1989.
    I know there are sites that do this, but I cannot select the period that interests me.
    Is it a feasible request?

  • @GMTobiasRM
    @GMTobiasRM 4 ปีที่แล้ว +1

    Nice video, thank you! Are these audio features from spotify calculated with any type of encoder? I search a little bit how they calcule "danceability" and "energy" but do not find anything.

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  4 ปีที่แล้ว +1

      My guess is that they use a mix of Deep Learning (mainly CNN architectures) and traditional audio DSP for features like "tempo" and "key". But I may be wrong ;)

    • @GMTobiasRM
      @GMTobiasRM 4 ปีที่แล้ว

      @@ValerioVelardoTheSoundofAI Thank you!

  • @mainak.halder26
    @mainak.halder26 4 ปีที่แล้ว

    brother i have a list of urls of spotify tracks , can i use it to create a playlist

  • @maxshapovalov7010
    @maxshapovalov7010 3 ปีที่แล้ว

    Hey, do you know if the code is still functional?
    I am getting the following error:
    line 30, in get_last_played_tracks
    track in response_json["items"]]
    KeyError: 'items'
    I'm not too sure how to solve but I'm sure it's a pretty simple fix.
    Any help would be appreciated, thanks!

    • @tomaszrutowicz3650
      @tomaszrutowicz3650 3 ปีที่แล้ว

      Same error, did You fix it?

    • @leyviya
      @leyviya 3 ปีที่แล้ว

      same here... I think this key error thing is not fixable...

    • @leyviya
      @leyviya 3 ปีที่แล้ว

      I solved the problem. problem is the spotify token, it's valid for just 1 hour. just get a new token after an hour, then do exports from terminal / cmd again. it will work probably.

    • @SonNguyen-pj7nd
      @SonNguyen-pj7nd 2 ปีที่แล้ว

      @@leyviya i try it but it seem does not work with a new valid token. Any help please?

    • @SonNguyen-pj7nd
      @SonNguyen-pj7nd 2 ปีที่แล้ว

      for those who wanna get the job done just clone the author 's git and it works fine

  • @diogobastos9940
    @diogobastos9940 4 ปีที่แล้ว

    Amazing video and content ;) Your Python classes should definitely have object as their superclass, though (even though actually in Python 3 all classes are new style classes and I should just grow up with the times) lol =)

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  4 ปีที่แล้ว

      Thank you! In Python 3, as you mentioned, classes aren't required to inherit from "object".

  • @basil_znamenn
    @basil_znamenn 4 ปีที่แล้ว +1

    Nice video! Can you make video about audio denoising by tensorflow?

  • @caitlinhogan4640
    @caitlinhogan4640 3 ปีที่แล้ว

    Trying to give this a go but hit a roadblock, if someone can please help? I have the new playlist generating through the web api with up to 50 tracks, however, after running from cli with the updated auth token (recently played tracks from spotify) and user ID, it's only finding the same old 3 last_played_tracks, even though I input 15 tracks to visualize from and have since updated the listener history with 20+ new tracks. Suggestions on how to fix so the user can choose from a longer list than 3?

  • @sergiosancho5717
    @sergiosancho5717 2 ปีที่แล้ว

    I tried running it and it keeps happening this error, could someone help me out?
    ModuleNotFoundError: No module named 'spotipyclient'

  • @turbonbc
    @turbonbc 3 ปีที่แล้ว

    My question is if spotify is so smart why can't they make a setting to "sort by tempo" in playlists.

  • @ShortVine
    @ShortVine 4 ปีที่แล้ว

    Hi bro can you please make video on any kaggle audio project?

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  4 ปีที่แล้ว

      Do you have a particular Kaggle project in mind?

    • @ShortVine
      @ShortVine 4 ปีที่แล้ว

      ​@@ValerioVelardoTheSoundofAI 1- www.kaggle.com/c/freesound-audio-tagging
      2- www.kaggle.com/c/birdsong-recognition/data?select=train.csv

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  4 ปีที่แล้ว +1

      @@ShortVine thank you for sharing these.

  • @NextManu
    @NextManu 2 ปีที่แล้ว

    is python the greatest thing ever created ? it sure feels like it...

    • @ValerioVelardoTheSoundofAI
      @ValerioVelardoTheSoundofAI  2 ปีที่แล้ว

      Not sure if it's the best, but definitely a great tool in computer science!

    • @NextManu
      @NextManu 2 ปีที่แล้ว

      @@ValerioVelardoTheSoundofAI is there anything it cant do? I recently started learning python and am always surprised to see the things it can do.