I've just started programming and this video is exactly what I needed to motivate myself while I'm learning Python. Great video! Keep up the good work. See you around
@@imdadcodes Of course I subscribed! Bell is on as well :D Yeah I started like two days ago and I was curious on what's possible with Python and then I searched the web and found your channel.
@@imdadcodes I simply searched for "Python and Spotify" on UA-cam because I was interested about it. I really wonder if it's possible to code something and this something is looking for music you maybe like and puts them into a playlist on Spotify. I mean like an AI which learns from your usage of spotify. I think Spotify has something like that in their application but it's not really working for me.
Hi man, at 9:45 of video, when you were trying to extract the artist and track info of the video, somehow I am not able to do that. It gave the KeyError: 'artist' or 'track' and when I traced back the video dict variable, there was no keys referring to either keyword "artist" or track! idk if there's another way to approach this problem! Really appreciate if you can help. Thanks!
Your video guides are really good. I'm trying to go in the opposite direction: getting a playlist from Spotify and converting it into a playlist in UA-cam. Is it possible to use the libraries and APIs in this video (specially the youtube tools) for that?
Thank you. I’m sure it’s possible. Google/UA-cam APIs can be a bit more of a faff so I imagine the authentication might be a bit trickier. But check out the documentation 👍
for some reason when i try to go on the source code link i get to the page but when i go to the bottom of the page and click here to get the full source code it doesnt work
@@User-re8nl yep. It does. It may have a time limit or usage limit. So you will have to create a new token and place it into your Spotify auth file. A little annoying to do each time but it doesn’t take too much time to do.
I followed along with this tutorial and made a few changes to the code to fit my needs and it ended up working so well! Thanks for this great tutorial!
Thanks for explaining the logic behind what and why you were coding it a certain way instead of just saying do this and do that, it made it easier to follow along. I had a bit of trouble with figuring out how to get the client_secret.json file but I eventually figured it out with a little help from stack overflow : ) Also, I had no idea what youtube-dl was before this and that it could be used to download youtube videos, so after watching this I actually ended up making another program using youtube-dl just to easily download youtube videos! You got yourself a new subscriber!
Thank you so much pracheeti for the very detailed feedback, it is honestly incredibly helpful ❤️ There's definitely a lot of points in there that I will actively think about in my next videos. That's also really really cool that you built upon that video and took it to another level, great stuff 💪 Thanks for the subscription, it means a lot 😀
Hey, i am getting this error. results = response_json['tracks']['items'] KeyError: 'tracks' i don't know what to do next, it would be great if anyone could help
@@imdadcodes {'error': {'status': 401, 'message': 'The access token expired'}} this is the error I am getting. it always shows access token expired even after I try running the program with a new token and also setting it in env variable. Also, subscribed :)
@@imdadcodes yeah i tried that, works partially. it asked my Spotify token and I provided. but after that it showed 297 lines of output which was squeezed, I expanded it, I could see songs of my playlist in that output screen, but this keyerror tracks still remains and no playlist is created in spotify
omg yes it works. thank you so much, you were of great help. also, is there any way that Spotify liked songs gets refreshed every time we like a new song on youtube without running the python program?
Amazing!! 🎉 It is possible for sure, but it's not the easiest thing to setup. You'd have to run it on a server (usually you pay fees) and have it continually check for any updates. It's not ideal, I wish I had a better answer but this seems like the best free way to do it 😀
Hi there Thanks for the idea for this project I was facing one issue as said below, This error pops up every time I try to run the youtube_client.py KeyError: 'artist' I have checked for any of the known errors but not able to figure them out Can someone help me out?
I've got the same error and it seems like youtube_dl does not give an information about the artist and track anymore. I tried to to this with title instead but some of the tracks for example with (official video) couldn't be found.
@@termi2828 I also ran into this bug and fixed it with a workaround using facebook's web scraper. Enjoy fellas # import youtube_dl import youtube_dl # set a custom agent to fix the bug (facebook's web crawler) youtube_dl.utils.std_headers['User-Agent'] = "facebookexternalhit/1.1 (+facebook.com/externalhit_uatext.php)" # youtube_dl will now work as normal to collect # the song name & artist name video = youtube_dl.UA-camDL({}).extract_info( youtube_url, download=False) song_name = video["track"] artist = video["artist"] )
Hi Imdad. I am trying to run my project but struggling with the OAuth. Upon clicking on the URL for authorization, i get the following error "The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type. You can create a Client ID for native application at" Any idea why?
When I get to "Enter your choice: " it doen't print out the names of playlists that I have before then. I tried to insert a number anyways and I get a "list index out of range" error. Does anyone know how to fix this?
i got this message after choosing playlist to automate Traceback (most recent call last): File "run.py", line 30, in run() File "run.py", line 22, in run spotify_song_id = spotify_client.search_song(song.artist, song.track) File "D:\projects\python\automate-spotify-python\spotify_client.py", line 21, in search_song results = response_json['tracks']['items'] KeyError: 'tracks' what i need to do?
Traceback (most recent call last): File "run.py", line 30, in run() File "run.py", line 15, in run chosen_playlist = playlists[choice] IndexError: list index out of range help me with this error
Hi! So I'm encountering two issues... 1. print(f"{index}: {playlist.title}") --- it's saying it's an invalid syntax... I'm not sure why. When I remove the "f", I don't see the error message. 2. I'm getting a module not found with my import requests, any ideas as to why I'm seeing this? I have request installed.
@@imdadcodes Hmm... I'm not entirely too sure what that is... but I'm using Py Charm. I've followed your tutorial exactly :) Sorry... I'm not yet fluent in Python
Awesome, thank you for the kind comment and for the subscription 😀 I’d love to know what you liked about the video (were there any specific bits or any comments about the format)? It’ll help me greatly when it comes to making future videos for you 🙌
Access tokens expire after one hour. This expiry time is set on Spotify's side and can't be changed by the client. You can refresh an access token if you're retrieving it using the Authorization Code flow. (The refresh token is practically valid forever, or until it has been manually revoked.) More info here: developer.spotify.com/documentation/general/guides/authorization-guide/
can you overview what needs to do in the client_secret.json file? I have the API key but am not sure what needs to go in the file and how to format it.
So essentially when you go to the UA-cam Data API and create a set of credentials, you'll get a .json file to download. That's the one you need to rename to client_secret.json and place in the credentials directory. Does that make sense?
@@imdadcodes We need a small video showing how to do this. There are a bunch of options and it isn't really straight forward, especially for api beginners.
@@tucc40095 i know this is forever late, but if you click on the UA-cam data api link he has in the description, click on guides, click on get Auth credentials under Authorize requests, and click the first link that says credentials page, you should be taken to a page with white and blue. Click on create credentials, it will bring you to set up an Oauth consent set up. Once you are done with that, goo back to create credentials and create one. You should be given an id and secret. There should be a button that says, download json file at the top. Download it and put it into the creds file in your project.
Nice vide bro! But I have an issue when extracting the track name and artist through the youtube_dl. On every video i search, ["artist] and ["track] are equal to null. I don't know why, maybe they removed that information from ALL the songs? it's quiet confusing to me. The rest it's working just fine. I did a few tweaks and make it to be semi-auto-authenticated and currently I'm thinking on expanding it
Hi I've run into the same issue, track and artist come back with no value. There are also a number of other fields that come back as none. This appears to be an issue with the youtube_dl library itself and the regular expressions being used in the source code. There is a similar open issue on the github page here: github.com/ytdl-org/youtube-dl/issues/26013 I'm going to learn more about regular expressions and try to solve this issue. If anyone has any pointers or would like to help please message me.
@@AldorCrap Fixed it. Here is an example of what to do # import youtube_dl import youtube_dl # set a custom agent to fix the bug (facebook's web crawler) youtube_dl.utils.std_headers['User-Agent'] = "facebookexternalhit/1.1 (+facebook.com/externalhit_uatext.php)" # youtube_dl will now work as normal to collect # the song name & artist name video = youtube_dl.UA-camDL({}).extract_info( youtube_url, download=False) song_name = video["track"] artist = video["artist"] )
So I have been getting this error even though I have added a redirect uri and downloaded the json file and added it to client_secrets.json: Error 400: redirect_uri_mismatch ,I am unable to get the authorization code. Please help me out !!
i tried for a week and i still get my spotify playlist to update. can you please help me because this is for my school project. i need to submit this asap so it would be a great if you could help me. thank you very much
Yup, I believe they have an OAuth offering. You’ll need to implement the refresh token handling potentially. Check out developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/
Hey man! Great content. I’m trying to retrieve Spotify data to a Machine Learning Project. While building my dataset, I keep receiving “HTTP Error for GET to () returned 404 due to error”. The track uri works, but I still cannot catch the error. Any tips? Am I requesting too much from the API?
Thanks! Can you confirm the endpoint you’re requesting, 404 means not found. Usually you get rate limited after a certain number of requests and you’ll get a 403, but not straight away.
@@imdadcodes I guess that's the case. I've tried using a try/except structure to deal with it but I'm not having success. Do you have any tips on it? Should I refresh my token or smoothing like it? Thanks for the prompt answer.
Couple things worth trying. Refresh token and try hit the endpoint, maybe either Curl from terminal or use Insomnia/Postman. Try other endpoints to see if it’s an issue with that one endpoint or if it’s affecting every endpoint, if the latter maybe an overall authorisation issue.
Hi, I got to the very end and when I click on the URL to authorize the application, I get an "Error 400: redirect_uri_mismatch" error. Is this due to missing authorized redirected URIs? If so, what URI should I add?
I actually got it resolved. My problem was I created an OAuth client ID with a Web Application Type. I had to use "Other" instead. Thanks for replying anyways. Your videos are great! Please keep them coming :)
Awesome, nice debugging 💪 Thanks for the kind comments and sure thing! I'm betting you've subscribed and tapped the bell icon already but worth checking out my latest video which adds random songs to Spotify 🙌 ua-cam.com/video/uXf7IRDIQS4/v-deo.html
I've customised my PyCharm quite heavily. I use the One Dark Scheme and Monaco Font. Hope that helps. I may do a UA-cam video on my settings in the future so be sure to subscribe 😀
Hello! I love the video and the project itself. I just have a problem that I don't yet understand the reason why, the terminal is showing me the next error: request = self.youtube_client.playlist().list( AttributeError: 'Resource' object has no attribute 'playlist' Probably its just a typo or something. I tried checking the gitHub repository for the project but I could not find any leads. I would appreciate the help.
@@imdadcodes Hi, thank you for replying : ) I have subscribed and hope you continue with the content. In terms of the code, I can confirm the credential name files and where they are stored, correspond to the main folder of the project. The run.py file has the appropriate references to them as well. I verified your gitHub project , in case I may have spellings issues or something. But nothing so far : /
@@imdadcodes Sure. Here are the links: run.py: pastebin.com/03UxxBFa youtube_client.py: pastebin.com/puzzhmiQ If you need to check the rest of it, let me know. Thank you very much for the help!
very informative and well explained,but while using the youtube_dl library and applying the same code the response data for artist and track returned None,could you provide a reason......
Hey! Great work on doing this. And it barely even works for me. Problem here: The last thing that happens is: Attempting to add 1. I just got one Song on the playlist, just to try it but in spotify no song will be added to the liked songs playlist... Any ideas?
Hmm, it sounds like not all songs are being added. It might be worth adding some print statements or breakpoints in your code to inspect and check whether it actually adds the songs?
Hmm, I think best bet is breakpoints to hopefully to try and pinpoint exactly at which bit in the code it’s not doing what it’s meant to do. Wish I could help more 😔
I recommend reading the steps here first to understand how to set up it: developers.google.com/youtube/v3/quickstart/python But here's a video on how you can set it up: ua-cam.com/video/3jZ5vnv-LZc/v-deo.html
Hey when I run the 'run.py' file, im able to get as far to the authorization code, once I enter that in and make a selection. I get this error in youtube_client.py: Unable to download webpage: (caused by URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))) I don't know what I'm doing wrong
Hello sir, Actually I am working on a little similar project to create a system that recognise face expression and create a playlist accordingly. As I need help regarding that and there is no such video on UA-cam. It would be helpful for me and many others who wants to work on such things if you make a video for the same.
Hi Imdad, I am running the program and getting the error Authorization Error 400 missing required parameter : redirect uri and i have no idea how to fix that
look on the SpotifyAPI doc. You need an URI in the query for the auth. But first, on the dashboard you have to go to your App and then go to edit settings and add the URI to the whitelist.
@@MsGabrielBoss I got the error when I clicked the URL generated on running python run.py also it would be helpful if you could tell me how can we set the Spotify auth token as an environmental variable.
hi! i keep getting this error. i tried so many things and i still don't get the answer Authorization Error Error 400: invalid_request Missing required parameter: scope
How to create a simple discord bot and connect Spotify functions to it? I was looking for and trying to create my own discord bot to use my Spotify songs in discord. Could you try that out and create a video for that? I'd love to see that video.
Hi Alimus, that’s a good idea. Probably won’t be the quickest to get tougher though as it would need some server deployment etc. I’ll be doing more Spotify API tutorials this year though so I’ll definitely keep it in mind! Do let me know if you start building something too 😛
Hi, I'm getting this error: ERROR: Unable to download webpage: (caused by URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)'))) Trying to download the video from UA-cam. video = youtube_dl.UA-camDL({'quiet': True}).extract_info( youtube_url, download=False # The error is raised from this line ) I have tried to add the option: 'no_check_certificate': True But it doesn't work, any ideas?
Awesome video, subscribed! @ 21:55 - The Spotify auth token expires every 60 minutes right? Is there any way to generate it from Python itself so that in case it expres, i catch it in a "try... catch" block & request a new auth token?
Do you have this line in `youtube_client.py`: github.com/imdadahad/automate-spotify-python/blob/6d515ab180a45812b0b78c66840029b55d9b8b5a/youtube_client.py#L44
Heya, can you try pulling down my code from the Github repo and see if that works. If not, then can you explain step by step exactly how you're obtaining the credentials from the UA-cam Data API?
@@imdadcodes thnxxx for replying, here are the step Google cloud platform->credential-> getting API KEY ->Create credential -> OAuth client Id -> App type ( Desktop App) then I downloaded the json file
okay so i just spent literal hours following every step you made, and it just doesn't work? i also don't get the download the credentials part? everything in your tutorial is easy to follow and understand, but that part is just? maybe its because I am not an experienced coder but still :(
Hi bro, I've been getting this error after running the run.py file despite having the access token and credentials.json there. Traceback (most recent call last): File "c:\Users\wobur\OneDrive\Desktop\Projects\automate-youtube-to-spotify un.py", line 29, in run() File "c:\Users\wobur\OneDrive\Desktop\Projects\automate-youtube-to-spotify un.py", line 7, in run youtube_client = UA-camClient('./creds/client_secret.json') File "c:\Users\wobur\OneDrive\Desktop\Projects\automate-youtube-to-spotify\youtube_client.py", line 32, in __init__ credentials = flow.run_local_server() File "C:\Users\wobur\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\google_auth_oauthlib\flow.py", line 432, in run_local_server local_server = wsgiref.simple_server.make_server( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\wsgiref\simple_server.py", line 154, in make_server server = server_class((host, port), handler_class) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 452, in __init__ self.server_bind() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\wsgiref\simple_server.py", line 50, in server_bind HTTPServer.server_bind(self) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\server.py", line 137, in server_bind socketserver.TCPServer.server_bind(self) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 466, in server_bind self.socket.bind(self.server_address) PermissionError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions If you have any idea why this happens? Please let me know. I have been stuck for so long.
Hey, i am getting this error. results = response_json['tracks']['items'] KeyError: 'tracks' i don't know what to do next, it would be great if anyone could hel
Hey, usually this happens when you haven't got the Spotify environment variable set correctly. Can you run `echo $SPOTIFY_TOKEN` in the terminal and let me know what that prints out?
Imdad Ahad I was debugging the code and everytime the response from add songs to Spotify was false, the code got the song Id but cannot add it to spotify for some reason
I've just started programming and this video is exactly what I needed to motivate myself while I'm learning Python. Great video! Keep up the good work. See you around
@@imdadcodes Of course I subscribed! Bell is on as well :D Yeah I started like two days ago and I was curious on what's possible with Python and then I searched the web and found your channel.
@@imdadcodes I simply searched for "Python and Spotify" on UA-cam because I was interested about it. I really wonder if it's possible to code something and this something is looking for music you maybe like and puts them into a playlist on Spotify. I mean like an AI which learns from your usage of spotify. I think Spotify has something like that in their application but it's not really working for me.
Have u learned python?
Hi man,
at 9:45 of video, when you were trying to extract the artist and track info of the video, somehow I am not able to do that. It gave the KeyError: 'artist' or 'track' and when I traced back the video dict variable, there was no keys referring to either keyword "artist" or track! idk if there's another way to approach this problem! Really appreciate if you can help. Thanks!
Your video guides are really good. I'm trying to go in the opposite direction: getting a playlist from Spotify and converting it into a playlist in UA-cam. Is it possible to use the libraries and APIs in this video (specially the youtube tools) for that?
Thank you. I’m sure it’s possible. Google/UA-cam APIs can be a bit more of a faff so I imagine the authentication might be a bit trickier. But check out the documentation 👍
hey Imdad. amazing video youve put out. I just wanted to ask you how do i download youtube credentials file??
thanks in advance
These videos are gold keep it up!
Thanks, let me know if you have any requests. I usually note them down 👍
hi Imdad, i followed this video line by line and at last I got this error
in getArtistandTrackFromVideo
artist = video['artist']
KeyError: 'artist
for some reason when i try to go on the source code link i get to the page but when i go to the bottom of the page and click here to get the full source code it doesnt work
I am also facing the same issue.
where to get the spotify token? im confused please help
Have the same question. Have you found it?
developer.spotify.com/console/put-current-user-saved-tracks/
@@cstone7092 thanks ma dude
@@cstone7092 Doesn't this expire every hour?
@@User-re8nl yep. It does. It may have a time limit or usage limit. So you will have to create a new token and place it into your Spotify auth file. A little annoying to do each time but it doesn’t take too much time to do.
I followed along with this tutorial and made a few changes to the code to fit my needs and it ended up working so well! Thanks for this great tutorial!
That's amazing, very glad to hear! What were your favourite bits of the video? Would love to know what I should keep in mind for future videos 😀
Thanks for explaining the logic behind what and why you were coding it a certain way instead of just saying do this and do that, it made it easier to follow along. I had a bit of trouble with figuring out how to get the client_secret.json file but I eventually figured it out with a little help from stack overflow : ) Also, I had no idea what youtube-dl was before this and that it could be used to download youtube videos, so after watching this I actually ended up making another program using youtube-dl just to easily download youtube videos!
You got yourself a new subscriber!
Thank you so much pracheeti for the very detailed feedback, it is honestly incredibly helpful ❤️ There's definitely a lot of points in there that I will actively think about in my next videos. That's also really really cool that you built upon that video and took it to another level, great stuff 💪 Thanks for the subscription, it means a lot 😀
Hey, i am getting this error. results = response_json['tracks']['items']
KeyError: 'tracks' i don't know what to do next, it would be great if anyone could help
@@imdadcodes {'error': {'status': 401, 'message': 'The access token expired'}} this is the error I am getting. it always shows access token expired even after I try running the program with a new token and also setting it in env variable. Also, subscribed :)
@@imdadcodes yeah i tried that, works partially. it asked my Spotify token and I provided. but after that it showed 297 lines of output which was squeezed, I expanded it, I could see songs of my playlist in that output screen, but this keyerror tracks still remains and no playlist is created in spotify
omg yes it works. thank you so much, you were of great help. also, is there any way that Spotify liked songs gets refreshed every time we like a new song on youtube without running the python program?
Amazing!! 🎉
It is possible for sure, but it's not the easiest thing to setup. You'd have to run it on a server (usually you pay fees) and have it continually check for any updates. It's not ideal, I wish I had a better answer but this seems like the best free way to do it 😀
Imdad Ahad alright, thankyou so much for your help!
Hi there
Thanks for the idea for this project
I was facing one issue as said below,
This error pops up every time I try to run the youtube_client.py
KeyError: 'artist'
I have checked for any of the known errors but not able to figure them out
Can someone help me out?
I've got the same error and it seems like youtube_dl does not give an information about the artist and track anymore. I tried to to this with title instead but some of the tracks for example with (official video) couldn't be found.
artist and track both are none, am using 2020.07.28 please help
@@termi2828 thank you i have seen the issue am also doing the same
@@termi2828
I also ran into this bug and fixed it with a workaround using facebook's web scraper. Enjoy fellas
# import youtube_dl
import youtube_dl
# set a custom agent to fix the bug (facebook's web crawler)
youtube_dl.utils.std_headers['User-Agent'] = "facebookexternalhit/1.1 (+facebook.com/externalhit_uatext.php)"
# youtube_dl will now work as normal to collect
# the song name & artist name
video = youtube_dl.UA-camDL({}).extract_info(
youtube_url, download=False)
song_name = video["track"]
artist = video["artist"]
)
@@playdoughfunrs thanks I just found this solution on reddit, it works great
Hi Imdad. I am trying to run my project but struggling with the OAuth.
Upon clicking on the URL for authorization, i get the following error "The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type. You can create a Client ID for native application at"
Any idea why?
hey could you tell me how to store my UA-cam creds in the folder? I'm confused and would greatly appreciate the help
When I get to "Enter your choice: " it doen't print out the names of playlists that I have before then. I tried to insert a number anyways and I get a "list index out of range" error. Does anyone know how to fix this?
i got this message after choosing playlist to automate
Traceback (most recent call last):
File "run.py", line 30, in
run()
File "run.py", line 22, in run
spotify_song_id = spotify_client.search_song(song.artist, song.track)
File "D:\projects\python\automate-spotify-python\spotify_client.py", line 21, in search_song
results = response_json['tracks']['items']
KeyError: 'tracks'
what i need to do?
Can you wrap it with a try catch and so you can print out the error. Usually this means you’re credentials aren’t correct or being parsed correctly.
@@imdadcodes where and what i need to write? i don't know much about python..
Probably worth watching a few UA-cam videos on exception handling on Python. I don't have any videos on that as of yet.
hey Imdad , 17:06 pls tell me how to download the UA-cam Credentials file and also how to place it in the directory . anyone pls kindly help asap
Source code link doesn't work now.
Traceback (most recent call last):
File "run.py", line 30, in
run()
File "run.py", line 15, in run
chosen_playlist = playlists[choice]
IndexError: list index out of range
help me with this error
Which playlists were printed and which one did you select?
@@imdadcodes bro there are no choices when I execute the code
@@imdadcodesresults = response_json['tracks']['items']
KeyError: 'tracks'
I came up with this error and I already set the Auth token .
@coder Lag What happens when you run this in the terminal: `echo $SPOTIFY_AUTH_TOKEN`
@@imdadcodes this gives me my spotify auth token
Hi!
So I'm encountering two issues...
1. print(f"{index}: {playlist.title}") --- it's saying it's an invalid syntax... I'm not sure why. When I remove the "f", I don't see the error message.
2. I'm getting a module not found with my import requests, any ideas as to why I'm seeing this? I have request installed.
I think you’re using an older version of python which doesn’t support the formatted string feature. Can you confirm what version of Python you have?
@@imdadcodes Hi!! Thank you for responding :) I have version 3.8.3
Are you using a virtual environment?
@@imdadcodes Hmm... I'm not entirely too sure what that is... but I'm using Py Charm. I've followed your tutorial exactly :) Sorry... I'm not yet fluent in Python
Really great video i love these types of projects, proper interesting and great for a beginner. Liked and subscribed i hope you make more! :) Thanks
Awesome, thank you for the kind comment and for the subscription 😀 I’d love to know what you liked about the video (were there any specific bits or any comments about the format)? It’ll help me greatly when it comes to making future videos for you 🙌
Recently started learning Python and watching this really made me think, "will I ever reach this level knowledge in programming "?!
what is meant to be in the credential folder and how do we access/ sign into youtube
Have you managed to solve the problem?
Imdad Ahad thank you, I was able to do so by using googles api
@@anjolatope-babalola2338 Awesome, glad to hear you got it working 💪
Neat and easy to walk through! GJ! What's the music title in the video? Pretty chill
Thanks! I took it from here: ua-cam.com/video/9ofV2kjQdRU/v-deo.html&ab_channel=Airtight
now how do you refresh the access token? because that does expire after about an hour or so
Access tokens expire after one hour. This expiry time is set on Spotify's side and can't be changed by the client.
You can refresh an access token if you're retrieving it using the Authorization Code flow. (The refresh token is practically valid forever, or until it has been manually revoked.) More info here: developer.spotify.com/documentation/general/guides/authorization-guide/
@@imdadcodes thanks man
can you overview what needs to do in the client_secret.json file? I have the API key but am not sure what needs to go in the file and how to format it.
So essentially when you go to the UA-cam Data API and create a set of credentials, you'll get a .json file to download. That's the one you need to rename to client_secret.json and place in the credentials directory. Does that make sense?
@@imdadcodes We need a small video showing how to do this. There are a bunch of options and it isn't really straight forward, especially for api beginners.
@@tucc40095 i know this is forever late, but if you click on the UA-cam data api link he has in the description, click on guides, click on get Auth credentials under Authorize requests, and click the first link that says credentials page, you should be taken to a page with white and blue. Click on create credentials, it will bring you to set up an Oauth consent set up. Once you are done with that, goo back to create credentials and create one. You should be given an id and secret. There should be a button that says, download json file at the top. Download it and put it into the creds file in your project.
Nice vide bro! But I have an issue when extracting the track name and artist through the youtube_dl. On every video i search, ["artist] and ["track] are equal to null. I don't know why, maybe they removed that information from ALL the songs? it's quiet confusing to me. The rest it's working just fine. I did a few tweaks and make it to be semi-auto-authenticated and currently I'm thinking on expanding it
Are you using the latest version of youtube_dl? Check by running `pip install youtube_dl` and that will list the available versions.
@@imdadcodes I just checked and it says "Requirement already satisfied: youtube_dl in PATH" but still It's not working :(
Hi I've run into the same issue, track and artist come back with no value. There are also a number of other fields that come back as none. This appears to be an issue with the youtube_dl library itself and the regular expressions being used in the source code.
There is a similar open issue on the github page here: github.com/ytdl-org/youtube-dl/issues/26013
I'm going to learn more about regular expressions and try to solve this issue. If anyone has any pointers or would like to help please message me.
@@termi2828 If you find a solution woukd be great if you comment it here so I an fix it aswell
@@AldorCrap Fixed it. Here is an example of what to do
# import youtube_dl
import youtube_dl
# set a custom agent to fix the bug (facebook's web crawler)
youtube_dl.utils.std_headers['User-Agent'] = "facebookexternalhit/1.1 (+facebook.com/externalhit_uatext.php)"
# youtube_dl will now work as normal to collect
# the song name & artist name
video = youtube_dl.UA-camDL({}).extract_info(
youtube_url, download=False)
song_name = video["track"]
artist = video["artist"]
)
So I have been getting this error even though I have added a redirect uri and downloaded the json file and added it to client_secrets.json: Error 400: redirect_uri_mismatch ,I am unable to get the authorization code. Please help me out !!
i tried for a week and i still get my spotify playlist to update. can you please help me because this is for my school project. i need to submit this asap so it would be a great if you could help me. thank you very much
Hi, please check my comment on your other comment 🙂
Very nice video, I will try it
Fantastic!
I am NewBie with Python and I am stuck with the export function at the terminal: Pycharm does not recongnize the command. Can you please help me out ?
What error are you getting. Can you paste it here? By the way I also have beginner python videos coming so do subscribe and tap the bell icon 😀
So you have to get a new spotify auth token every time you want to run the program? Is there a way to get permanent authorization?
Yup, I believe they have an OAuth offering. You’ll need to implement the refresh token handling potentially. Check out developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/
Hey man! Great content. I’m trying to retrieve Spotify data to a Machine Learning Project. While building my dataset, I keep receiving “HTTP Error for GET to () returned 404 due to error”. The track uri works, but I still cannot catch the error. Any tips? Am I requesting too much from the API?
Thanks! Can you confirm the endpoint you’re requesting, 404 means not found. Usually you get rate limited after a certain number of requests and you’ll get a 403, but not straight away.
@@imdadcodes I guess that's the case. I've tried using a try/except structure to deal with it but I'm not having success. Do you have any tips on it? Should I refresh my token or smoothing like it? Thanks for the prompt answer.
Couple things worth trying. Refresh token and try hit the endpoint, maybe either Curl from terminal or use Insomnia/Postman. Try other endpoints to see if it’s an issue with that one endpoint or if it’s affecting every endpoint, if the latter maybe an overall authorisation issue.
Imdad Ahad Thank you very much. I’m working on that ;)
what code editor is this? it looks really clean, if you've added any extensions to it pls let me know!
it’s pycharm
Hi, I got to the very end and when I click on the URL to authorize the application, I get an "Error 400: redirect_uri_mismatch" error. Is this due to missing authorized redirected URIs? If so, what URI should I add?
Not sure if my comment went through. Could you confirm how you went about creating the credentials?
I actually got it resolved. My problem was I created an OAuth client ID with a Web Application Type. I had to use "Other" instead. Thanks for replying anyways. Your videos are great! Please keep them coming :)
Awesome, nice debugging 💪
Thanks for the kind comments and sure thing! I'm betting you've subscribed and tapped the bell icon already but worth checking out my latest video which adds random songs to Spotify 🙌
ua-cam.com/video/uXf7IRDIQS4/v-deo.html
i am having the same problem
great video!!
Glad you liked it!
Hey what Pycharm Theme and Font do u use for your IDE Appearance?
I've customised my PyCharm quite heavily. I use the One Dark Scheme and Monaco Font. Hope that helps. I may do a UA-cam video on my settings in the future so be sure to subscribe 😀
Hello! I love the video and the project itself. I just have a problem that I don't yet understand the reason why, the terminal is showing me the next error: request = self.youtube_client.playlist().list(
AttributeError: 'Resource' object has no attribute 'playlist'
Probably its just a typo or something. I tried checking the gitHub repository for the project but I could not find any leads. I would appreciate the help.
@@imdadcodes Hi, thank you for replying : ) I have subscribed and hope you continue with the content.
In terms of the code, I can confirm the credential name files and where they are stored, correspond to the main folder of the project. The run.py file has the appropriate references to them as well. I verified your gitHub project , in case I may have spellings issues or something. But nothing so far : /
@@imdadcodes Sure. Here are the links:
run.py: pastebin.com/03UxxBFa
youtube_client.py: pastebin.com/puzzhmiQ
If you need to check the rest of it, let me know. Thank you very much for the help!
@@imdadcodes Sure, absolutely. Here is my terminal after "pip freeze":
pastebin.com/nfWQtNk5
@@imdadcodes You were right, it was a small typo, the code is running correctly now!! I appreciate the help, keep that great content coming! : D
Hi Imdad,
I wanna start learning programming, which language should I start with? Is Python a good choice?
Hi Qassem,
That's great to hear, I'd highly recommend you give this video a watch: ua-cam.com/video/xKT7kHluZUk/v-deo.html
Hope that helps!
ur the best. thank u!
can you tell me please what vs code theme do you use? its very cool
He's using PyCharm not vscode
@@termi2828 looool, first time i didnt believe you, now i looked closer
very informative and well explained,but while using the youtube_dl library and applying the same code the response data for artist and track returned None,could you provide a reason......
Hey! Great work on doing this. And it barely even works for me. Problem here: The last thing that happens is: Attempting to add 1. I just got one Song on the playlist, just to try it but in spotify no song will be added to the liked songs playlist... Any ideas?
Hmm, it sounds like not all songs are being added. It might be worth adding some print statements or breakpoints in your code to inspect and check whether it actually adds the songs?
@@imdadcodes Already did this and apparently it goes through all the code but just doesnt add the songs to the playlist. :C
Hmm, I think best bet is breakpoints to hopefully to try and pinpoint exactly at which bit in the code it’s not doing what it’s meant to do. Wish I could help more 😔
i am getting Error 400: redirect_uri_mismatch,
any suggestions?
Can someone please post instructions on the client_secret.json file. Just plain specific instructions. Even better, a simple video would be great.
I recommend reading the steps here first to understand how to set up it: developers.google.com/youtube/v3/quickstart/python
But here's a video on how you can set it up: ua-cam.com/video/3jZ5vnv-LZc/v-deo.html
Hey when I run the 'run.py' file, im able to get as far to the authorization code, once I enter that in and make a selection. I get this error in youtube_client.py:
Unable to download webpage: (caused by URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
I don't know what I'm doing wrong
Hi Akriti, really sorry I saw this quite late. Did you manage to solve your issue?
hi i am unable to run the code with the terminal may I ask how did you manage to run your code?
Hi, what error are you getting?
@@imdadcodes hi thank you so much for replying i got an error where they said my export token isn't an external or internal command i am using a pc
Try ‘setx SPOTIFY_AUTH_TOKEN=token’. Think that’s how you set an environment variable on windows. Let me know if that works?
21.49 where can i open the terminal?
You can find it in your Applications folder if you're using a Mac.
Hello sir,
Actually I am working on a little similar project to create a system that recognise face expression and create a playlist accordingly.
As I need help regarding that and there is no such video on UA-cam. It would be helpful for me and many others who wants to work on such things if you make a video for the same.
Great idea, I'll jot it down!
@@imdadcodes Thank you for replying sir, waiting for your video.
Hi Imdad, I am running the program and getting the error Authorization Error 400 missing required parameter : redirect uri and i have no idea how to fix that
look on the SpotifyAPI doc. You need an URI in the query for the auth. But first, on the dashboard you have to go to your App and then go to edit settings and add the URI to the whitelist.
@@MsGabrielBoss I got the error when I clicked the URL generated on running python run.py also it would be helpful if you could tell me how can we set the Spotify auth token as an environmental variable.
Hi Ambar, are you getting this error from the Spotify API?
Hey Imdad, there is no link at 47s for the API video, just a heads up
Ah sweet Andrew! Thanks for the heads up, just added it in 🙌
I am having problems getting the redirect URI
which program you use to code ?
Pycharm for Python, sublime for most other things
@@imdadcodes thank you :D
Could you do a tutorial on getting a song to play on Spotify with Spotify?
Can you explain this a bit more?
@@imdadcodes I meant spotipy. I've been trying to get a song to play on a device, but I'm not really sure how to.
hi! i keep getting this error. i tried so many things and i still don't get the answer
Authorization Error
Error 400: invalid_request
Missing required parameter: scope
same here
What scope did you select when you generated the Spotify token. It needs to have access that allows you to modify your spotify library.
found my problem,the link in the pycharm terminal did not include the scopes added, just had to manually copy paste and was all good
How to create a simple discord bot and connect Spotify functions to it?
I was looking for and trying to create my own discord bot to use my Spotify songs in discord.
Could you try that out and create a video for that?
I'd love to see that video.
Hi Alimus, that’s a good idea. Probably won’t be the quickest to get tougher though as it would need some server deployment etc. I’ll be doing more Spotify API tutorials this year though so I’ll definitely keep it in mind! Do let me know if you start building something too 😛
@@imdadcodes I will. I am going through the discord app documents, to make a simple bot. watching tutorials online... i'll need some time too!
@@alimussifar Good stuff Alimus, let me know how it goes 🙏
Follow this process to extract any Spotify Playlist to csv using Python : ua-cam.com/video/xRbRCmedZo0/v-deo.html
i am getting this error called "video format not found" after selecting the playlist . Help
Sorry, did you manage to solve the issue?
@@imdadcodes nope :(
F all my playlist says attempting to add 0 even with the github code
update: same thing with the github code fml
what type of client id are we to chose
Hi, did you manage to solve your problem?
Imdad Ahad yeah I did
Imdad Ahad yes I did
Hi, I'm getting this error:
ERROR: Unable to download webpage: (caused by URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)')))
Trying to download the video from UA-cam.
video = youtube_dl.UA-camDL({'quiet': True}).extract_info(
youtube_url, download=False # The error is raised from this line
)
I have tried to add the option:
'no_check_certificate': True
But it doesn't work, any ideas?
Fixed following this thread stackoverflow.com/questions/50236117/scraping-ssl-certificate-verify-failed-error-for-http-en-wikipedia-org#
Awesome video, subscribed! @ 21:55 - The Spotify auth token expires every 60 minutes right? Is there any way to generate it from Python itself so that in case it expres, i catch it in a "try... catch" block & request a new auth token?
i am unable to find the pace to get token...where to find it?
cmon dude tell us how you installed that beautiful UI theme
Haha, it’s called Monokai Pro
What is the name of this editör
PyCharm
@@imdadcodes 2020?
Yup, well PyCharm Community Edition
@@imdadcodes Thenk bro 💛
How to download the UA-cam credential files?
Sorry, did you manage to solve the issue?
@@imdadcodes no I was not able to
There's only one choice is coming when I Execute the code
0 : Favourite
Do you have this line in `youtube_client.py`: github.com/imdadahad/automate-spotify-python/blob/6d515ab180a45812b0b78c66840029b55d9b8b5a/youtube_client.py#L44
@@imdadcodes yes bro
same problem here !!!!!
Heya, can you try pulling down my code from the Github repo and see if that works. If not, then can you explain step by step exactly how you're obtaining the credentials from the UA-cam Data API?
@@imdadcodes thnxxx for replying, here are the step
Google cloud platform->credential-> getting API KEY ->Create credential -> OAuth client Id -> App type ( Desktop App) then I downloaded the json file
hi, I cannot open the source code link
Sorry, I just went through a website upgrade recently. I've just updated the link 👍
unable to run the program
MORE PYTHON VIDEOS: MORE SPOTIFY API TUTORIALS: ua-cam.com/video/2if5xSaZJlg/v-deo.html
HI imdad , the Spotify link is the same as the youtube one in the description
@@simondalmaso5437 Thanks just fixed it
👍
okay so i just spent literal hours following every step you made, and it just doesn't work? i also don't get the download the credentials part? everything in your tutorial is easy to follow and understand, but that part is just? maybe its because I am not an experienced coder but still :(
source code bro
Hello, I followed all the steps very good this program, but it only works for the first 5 videos in the list by execution
Could you help me bro
Hey boss pls what's your discord
Hi bro, I've been getting this error after running the run.py file despite having the access token and credentials.json there.
Traceback (most recent call last):
File "c:\Users\wobur\OneDrive\Desktop\Projects\automate-youtube-to-spotify
un.py", line 29, in
run()
File "c:\Users\wobur\OneDrive\Desktop\Projects\automate-youtube-to-spotify
un.py", line 7, in run
youtube_client = UA-camClient('./creds/client_secret.json')
File "c:\Users\wobur\OneDrive\Desktop\Projects\automate-youtube-to-spotify\youtube_client.py", line 32, in __init__
credentials = flow.run_local_server()
File "C:\Users\wobur\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\google_auth_oauthlib\flow.py", line 432, in run_local_server
local_server = wsgiref.simple_server.make_server(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\wsgiref\simple_server.py", line 154, in make_server
server = server_class((host, port), handler_class)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 452, in __init__
self.server_bind()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\wsgiref\simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
PermissionError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
If you have any idea why this happens? Please let me know. I have been stuck for so long.
See if any of these help:
stackoverflow.com/questions/10461257/an-attempt-was-made-to-access-a-socket-in-a-way-forbidden-by-its-access-permissi
@@imdadcodes Thank you
Hey, i am getting this error. results = response_json['tracks']['items']
KeyError: 'tracks' i don't know what to do next, it would be great if anyone could hel
Hey, usually this happens when you haven't got the Spotify environment variable set correctly. Can you run `echo $SPOTIFY_TOKEN` in the terminal and let me know what that prints out?
Imdad Ahad it just returns Spotify token
Imdad Ahad I no longer get an error but my code stops running at attempting to add (number of songs )
Imdad Ahad I was debugging the code and everytime the response from add songs to Spotify was false, the code got the song Id but cannot add it to spotify for some reason
Hey boss pls what's your discord
Sorry, I don't have Discord.
OK I got a job for u boss but I don't know if you will be interested