Created
July 1, 2024 07:28
-
-
Save sshopov/8f1de3f7fc53ad0f6eb03aea86e5cb3d to your computer and use it in GitHub Desktop.
Revisions
-
sshopov created this gist
Jul 1, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import youtube_dl from pydub import AudioSegment # Define the YouTube video URL url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" url = "https://www.youtube.com/watch?v=21nt2kbj5Kk" #Goalie Pre Game Visualization # Download the video using youtube_dl ydl_opts = { 'format': 'bestaudio/best', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([url]) # Load the downloaded video video = AudioSegment.from_file("{}.mp3".format(url.split("=")[-1]), format="mp3") # Save the video as an MP3 file video.export("song.mp3", format="mp3")