Last active
March 11, 2023 01:04
-
-
Save C0nw0nk/d4c022a6799134a548bbd40ab1989bc5 to your computer and use it in GitHub Desktop.
youtube-dl for windows to download into MP3 format music videos audio from youtube HQ HD Audio no need to download anything i made the script do it all just give it a url
This file contains 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 characters
@echo off & setLocal EnableDelayedExpansion | |
:: Copyright Conor McKnight | |
:: https://github.com/C0nw0nk/ | |
:: https://www.facebook.com/C0nw0nk | |
:: Automatically sets up youtube-dl.exe ffmpeg.exe and aria2c.exe | |
:: all you need is the batch script it will download the latest versions from their github pages | |
:: simple fast efficient easy to move and manage | |
:: Script Settings | |
echo Input URL or Playlist URL: | |
set /p input= | |
set download_path=D:\Music | |
set download_url=--yes-playlist "%input%" | |
set audio_quality=320K | |
set audio_format=mp3 | |
:: End Edit DO NOT TOUCH ANYTHING BELOW THIS POINT UNLESS YOU KNOW WHAT YOUR DOING! | |
set root_path="%~dp0" | |
goto :next_download | |
:start_exe | |
youtube-dl.exe --external-downloader aria2c --ignore-errors --format bestaudio --extract-audio -x --audio-format %audio_format% --audio-quality %audio_quality% --output "%download_path%\%%(playlist)s\%%(title)s.%%(ext)s" %download_url% | |
goto :end_script | |
goto :next_download | |
:start_download | |
set downloadurl=%downloadurl: =% | |
FOR /f %%i IN ("%downloadurl:"=%") DO set filename="%%~ni"& set fileextension="%%~xi" | |
set downloadpath="%root_path:"=%%filename%%fileextension%" | |
( | |
echo Dim oXMLHTTP | |
echo Dim oStream | |
echo Set fso = CreateObject^("Scripting.FileSystemObject"^) | |
echo If Not fso.FileExists^("%downloadpath:"=%"^) Then | |
echo Set oXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP.6.0"^) | |
echo oXMLHTTP.Open "GET", "%downloadurl:"=%", False | |
echo oXMLHTTP.SetRequestHeader "User-Agent", "Mozilla/5.0 ^(Windows NT 10.0; Win64; rv:51.0^) Gecko/20100101 Firefox/51.0" | |
echo oXMLHTTP.SetRequestHeader "Referer", "https://www.google.co.uk/" | |
echo oXMLHTTP.SetRequestHeader "DNT", "1" | |
echo oXMLHTTP.Send | |
echo If oXMLHTTP.Status = 200 Then | |
echo Set oStream = CreateObject^("ADODB.Stream"^) | |
echo oStream.Open | |
echo oStream.Type = 1 | |
echo oStream.Write oXMLHTTP.responseBody | |
echo oStream.SaveToFile "%downloadpath:"=%" | |
echo oStream.Close | |
echo End If | |
echo End If | |
echo ZipFile="%downloadpath:"=%" | |
echo ExtractTo="%root_path:"=%" | |
echo ext = LCase^(fso.GetExtensionName^(ZipFile^)^) | |
echo If NOT fso.FolderExists^(ExtractTo^) Then | |
echo fso.CreateFolder^(ExtractTo^) | |
echo End If | |
echo Set app = CreateObject^("Shell.Application"^) | |
echo Sub ExtractByExtension^(fldr, ext, dst^) | |
echo For Each f In fldr.Items | |
echo If f.Type = "File folder" Then | |
echo ExtractByExtension f.GetFolder, ext, dst | |
echo End If | |
echo If instr^(f.Path, "\%file_name_to_extract%"^) ^> 0 Then | |
echo If fso.FileExists^(dst ^& f.Name ^& "." ^& LCase^(fso.GetExtensionName^(f.Path^)^) ^) Then | |
echo Else | |
echo call app.NameSpace^(dst^).CopyHere^(f.Path^, 4^+16^) | |
echo End If | |
echo End If | |
echo Next | |
echo End Sub | |
echo If instr^(ZipFile, "zip"^) ^> 0 Then | |
echo ExtractByExtension app.NameSpace^(ZipFile^), "exe", ExtractTo | |
echo End If | |
if %delete_download% == 1 echo fso.DeleteFile ZipFile | |
echo Set fso = Nothing | |
echo Set objShell = Nothing | |
)>"%root_path:"=%%~n0.vbs" | |
cscript //nologo "%root_path:"=%%~n0.vbs" | |
del "%root_path:"=%%~n0.vbs" | |
:next_download | |
if not defined aria2c_exe ( | |
if %PROCESSOR_ARCHITECTURE%==x86 ( | |
set downloadurl=https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-32bit-build1.zip | |
) else ( | |
set downloadurl=https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-64bit-build1.zip | |
) | |
set file_name_to_extract=aria2c.exe | |
set delete_download=1 | |
set aria2c_exe=true | |
goto :start_download | |
) | |
if not defined youtubedl_exe ( | |
set downloadurl=https://github.com/ytdl-org/youtube-dl/releases/latest/download/youtube-dl.exe | |
set delete_download=0 | |
set youtubedl_exe=true | |
goto :start_download | |
) | |
if not defined ffmpeg_exe ( | |
set downloadurl=https://github.com/C0nw0nk/youtube-dl-concurrent/raw/main/ffmpeg.exe | |
set delete_download=0 | |
set ffmpeg_exe=true | |
goto :start_download | |
) | |
goto :start_exe | |
:end_script | |
echo Complete. | |
pause | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did all the hard work so literaly you only have to run this script it will grab ffmpeg if you do not have it aria2c if you dont have it and youtube-dl if you do not have it enjoy
Just give it a url to download from as a example i provided youtube but here is a full list of supported websites https://ytdl-org.github.io/youtube-dl/supportedsites.html