Help Needed: Exceeded YouTube API Quota While Transferring Spotify Playlist /u/Low_Scientist_5312 Python Education

I’m totally new to Python but using Chat GPT guidance – I downloaded Python and tried to transfer my Spotify Playlist to Youtube Music. I created Spotify Client ID and Secret – set up a Google Cloud Project and I ran the following script – python spotify_to_youtube.py which contains the following script.

The problem is my playlist contains 1.2k songs but I can only transfer around 60 songs and after that its an error which says I’ve exceeded Youtube API Quota. Are there any ways I can bypass this or resolve this situation. I’ve seen past post on something similar to this but as I said I downloded Python for the first time ever just to do this and I’m pretty dumb so if you can let me know how to proceed, I’d be really glad.

import spotipy from spotipy.oauth2 import SpotifyOAuth from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow import csv # Spotify Configuration SPOTIFY_CLIENT_ID = 'YOUR_SPOTIFY_CLIENT_ID' SPOTIFY_CLIENT_SECRET = 'YOUR_SPOTIFY_CLIENT_SECRET' SPOTIFY_REDIRECT_URI = 'http://localhost:8888/callback' # YouTube Configuration YOUTUBE_SCOPES = ["https://www.googleapis.com/auth/youtube.force-ssl"] def get_spotify_tracks(playlist_url): sp = spotipy.Spotify(auth_manager=SpotifyOAuth( client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET, redirect_uri=SPOTIFY_REDIRECT_URI, scope="playlist-read-private")) playlist_id = playlist_url.split("/")[-1].split("?")[0] results = sp.playlist_items(playlist_id) tracks = [] for item in results['items']: track = item['track'] tracks.append(f"{track['name']} - {track['artists'][0]['name']}") return tracks def create_youtube_playlist(service, title, description=""): request = service.playlists().insert( part="snippet,status", body={ "snippet": { "title": title, "description": description }, "status": { "privacyStatus": "private" } } ) response = request.execute() return response["id"] def add_songs_to_youtube(service, playlist_id, songs): for song in songs: request = service.search().list(part="snippet", q=song, maxResults=1) response = request.execute() if response["items"]: video_id = response["items"][0]["id"]["videoId"] service.playlistItems().insert( part="snippet", body={ "snippet": { "playlistId": playlist_id, "resourceId": { "kind": "youtube#video", "videoId": video_id } } } ).execute() def main(): # Step 1: Extract Spotify Songs playlist_url = input("Enter Spotify playlist URL: ") songs = get_spotify_tracks(playlist_url) print(f"Retrieved {len(songs)} songs from Spotify.") # Step 2: Authorize YouTube flow = InstalledAppFlow.from_client_secrets_file("client_secret.json", YOUTUBE_SCOPES) credentials = flow.run_console() youtube = build("youtube", "v3", credentials=credentials) # Step 3: Create YouTube Playlist and Add Songs playlist_title = input("Enter the title for your YouTube playlist: ") playlist_id = create_youtube_playlist(youtube, playlist_title) add_songs_to_youtube(youtube, playlist_id, songs) print(f"Playlist '{playlist_title}' created and populated on YouTube.") if __name__ == "__main__": main() 

submitted by /u/Low_Scientist_5312
[link] [comments]

​r/learnpython I’m totally new to Python but using Chat GPT guidance – I downloaded Python and tried to transfer my Spotify Playlist to Youtube Music. I created Spotify Client ID and Secret – set up a Google Cloud Project and I ran the following script – python spotify_to_youtube.py which contains the following script. The problem is my playlist contains 1.2k songs but I can only transfer around 60 songs and after that its an error which says I’ve exceeded Youtube API Quota. Are there any ways I can bypass this or resolve this situation. I’ve seen past post on something similar to this but as I said I downloded Python for the first time ever just to do this and I’m pretty dumb so if you can let me know how to proceed, I’d be really glad. import spotipy from spotipy.oauth2 import SpotifyOAuth from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow import csv # Spotify Configuration SPOTIFY_CLIENT_ID = ‘YOUR_SPOTIFY_CLIENT_ID’ SPOTIFY_CLIENT_SECRET = ‘YOUR_SPOTIFY_CLIENT_SECRET’ SPOTIFY_REDIRECT_URI = ‘http://localhost:8888/callback’ # YouTube Configuration YOUTUBE_SCOPES = [“https://www.googleapis.com/auth/youtube.force-ssl”] def get_spotify_tracks(playlist_url): sp = spotipy.Spotify(auth_manager=SpotifyOAuth( client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET, redirect_uri=SPOTIFY_REDIRECT_URI, scope=”playlist-read-private”)) playlist_id = playlist_url.split(“/”)[-1].split(“?”)[0] results = sp.playlist_items(playlist_id) tracks = [] for item in results[‘items’]: track = item[‘track’] tracks.append(f”{track[‘name’]} – {track[‘artists’][0][‘name’]}”) return tracks def create_youtube_playlist(service, title, description=””): request = service.playlists().insert( part=”snippet,status”, body={ “snippet”: { “title”: title, “description”: description }, “status”: { “privacyStatus”: “private” } } ) response = request.execute() return response[“id”] def add_songs_to_youtube(service, playlist_id, songs): for song in songs: request = service.search().list(part=”snippet”, q=song, maxResults=1) response = request.execute() if response[“items”]: video_id = response[“items”][0][“id”][“videoId”] service.playlistItems().insert( part=”snippet”, body={ “snippet”: { “playlistId”: playlist_id, “resourceId”: { “kind”: “youtube#video”, “videoId”: video_id } } } ).execute() def main(): # Step 1: Extract Spotify Songs playlist_url = input(“Enter Spotify playlist URL: “) songs = get_spotify_tracks(playlist_url) print(f”Retrieved {len(songs)} songs from Spotify.”) # Step 2: Authorize YouTube flow = InstalledAppFlow.from_client_secrets_file(“client_secret.json”, YOUTUBE_SCOPES) credentials = flow.run_console() youtube = build(“youtube”, “v3”, credentials=credentials) # Step 3: Create YouTube Playlist and Add Songs playlist_title = input(“Enter the title for your YouTube playlist: “) playlist_id = create_youtube_playlist(youtube, playlist_title) add_songs_to_youtube(youtube, playlist_id, songs) print(f”Playlist ‘{playlist_title}’ created and populated on YouTube.”) if __name__ == “__main__”: main() submitted by /u/Low_Scientist_5312 [link] [comments] 

I’m totally new to Python but using Chat GPT guidance – I downloaded Python and tried to transfer my Spotify Playlist to Youtube Music. I created Spotify Client ID and Secret – set up a Google Cloud Project and I ran the following script – python spotify_to_youtube.py which contains the following script.

The problem is my playlist contains 1.2k songs but I can only transfer around 60 songs and after that its an error which says I’ve exceeded Youtube API Quota. Are there any ways I can bypass this or resolve this situation. I’ve seen past post on something similar to this but as I said I downloded Python for the first time ever just to do this and I’m pretty dumb so if you can let me know how to proceed, I’d be really glad.

import spotipy from spotipy.oauth2 import SpotifyOAuth from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow import csv # Spotify Configuration SPOTIFY_CLIENT_ID = 'YOUR_SPOTIFY_CLIENT_ID' SPOTIFY_CLIENT_SECRET = 'YOUR_SPOTIFY_CLIENT_SECRET' SPOTIFY_REDIRECT_URI = 'http://localhost:8888/callback' # YouTube Configuration YOUTUBE_SCOPES = ["https://www.googleapis.com/auth/youtube.force-ssl"] def get_spotify_tracks(playlist_url): sp = spotipy.Spotify(auth_manager=SpotifyOAuth( client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET, redirect_uri=SPOTIFY_REDIRECT_URI, scope="playlist-read-private")) playlist_id = playlist_url.split("/")[-1].split("?")[0] results = sp.playlist_items(playlist_id) tracks = [] for item in results['items']: track = item['track'] tracks.append(f"{track['name']} - {track['artists'][0]['name']}") return tracks def create_youtube_playlist(service, title, description=""): request = service.playlists().insert( part="snippet,status", body={ "snippet": { "title": title, "description": description }, "status": { "privacyStatus": "private" } } ) response = request.execute() return response["id"] def add_songs_to_youtube(service, playlist_id, songs): for song in songs: request = service.search().list(part="snippet", q=song, maxResults=1) response = request.execute() if response["items"]: video_id = response["items"][0]["id"]["videoId"] service.playlistItems().insert( part="snippet", body={ "snippet": { "playlistId": playlist_id, "resourceId": { "kind": "youtube#video", "videoId": video_id } } } ).execute() def main(): # Step 1: Extract Spotify Songs playlist_url = input("Enter Spotify playlist URL: ") songs = get_spotify_tracks(playlist_url) print(f"Retrieved {len(songs)} songs from Spotify.") # Step 2: Authorize YouTube flow = InstalledAppFlow.from_client_secrets_file("client_secret.json", YOUTUBE_SCOPES) credentials = flow.run_console() youtube = build("youtube", "v3", credentials=credentials) # Step 3: Create YouTube Playlist and Add Songs playlist_title = input("Enter the title for your YouTube playlist: ") playlist_id = create_youtube_playlist(youtube, playlist_title) add_songs_to_youtube(youtube, playlist_id, songs) print(f"Playlist '{playlist_title}' created and populated on YouTube.") if __name__ == "__main__": main() 

submitted by /u/Low_Scientist_5312
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *