example to download youtube as mp4
see >
https://youtube-dl.org/ for MP4 / and also ffmpeg for MP3
Code: Select all
/*
MODIFIED =20190526
CREATED =20190526
download Youtube MP4
https://youtube-dl.org/
*/
#warn
#persistent
#singleinstance,force
;#IfWinActive YouTube
setworkingdir,%a_scriptdir%
settitlematchmode,2
clipboard=
fdpro:=a_scriptdir . "\YT_programs"
fdmp4:="D:\M_MEDIA\M_VIDEO"
;fdmp4:="D:\M_MEDIA\M_FILME\Hitchcock_Hour_MP4"
ifnotexist,%fdpro%
filecreatedir,%fdpro%
ifnotexist,%fdmp4%
filecreatedir,%fdmp4%
;- ffmpeg needed for only MP3-file
;- in same directory then youtube-dl.exe
;- without ffmpeg is always MP4 / with ffmpeg can be MP4 with better quality or also xy.webm or xy.mkv
youtubedl:=fdpro . "\youtube-dl.exe"
ifexist,%youtubedl%
{
loop,%youtubedl%
SP1:=A_loopFileShortPath
RunWait, %comspec% /k %sp1% -U ;- Update youtube-dl.exe
}
else
run,https://youtube-dl.org/latest/youtube-dl.exe
return
;--------------
esc::exitapp
;--------------
OnClipboardChange:
{
id:=""
L:=""
If (A_EventInfo=1)
{
if (winactive("YouTube"))
{
if (instr(clipboard, "https://www.youtube.com"))
{
Loop,parse,clipboard, `n, `r
{
x= %a_loopfield%
if x=
continue
Loop, Parse,x,`/`=`&`?%a_space%`#`:
{
id:= A_LoopField
stringlen,L,id
if (L=11)
break
}
}
}
}
if (L=11)
{
clipboard=
url=https://www.youtube.com/watch?v=%id%
; without ffmpeg is always MP4 / with ffmpeg can be MP4 with better quality or als webm or mkv
ifexist,%youtubedl%
{
;RunWait, %comspec% /k %sp1% %url% -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
;- create xy.vtt file if subtitle exist with original language
RunWait, %comspec% /k %sp1% %url% --verbose --youtube-skip-dash-manifest --write-auto-sub --sub-lang de -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
;RunWait, %comspec% /k %sp1% %url% --verbose --youtube-skip-dash-manifest --write-auto-sub --all-subs -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
;RunWait, %comspec% /k %sp1% %url% --verbose --youtube-skip-dash-manifest --write-auto-sub -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
;RunWait, %comspec% /k %sp1% %url% --youtube-skip-dash-manifest --restrict-filenames -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s"
}
url=
id=
;run,%fdmp4%
}
}
return
}
;--------------
example to download youtube as mp3 / ffmpeg needed for MP3-file
Code: Select all
/*
MODIFIED =20190526
CREATED =20190526
download Youtube MP3
https://youtube-dl.org/
*/
#warn
#persistent
#singleinstance,force
;#IfWinActive YouTube
setworkingdir,%a_scriptdir%
settitlematchmode,2
clipboard=
fdpro:=a_scriptdir . "\YT_programs"
fdmp3:="D:\M_MEDIA\M_MUSIC"
ifnotexist,%fdpro%
filecreatedir,%fdpro%
ifnotexist,%fdmp3%
filecreatedir,%fdmp3%
youtubedl:=fdpro . "\youtube-dl.exe"
ifexist,%youtubedl%
{
loop,%youtubedl%
SP1:=A_loopFileShortPath
RunWait, %comspec% /k %sp1% -U ;- Update youtube-dl.exe
}
else
run,https://youtube-dl.org/latest/youtube-dl.exe
return
;--------------
esc::exitapp
;--------------
OnClipboardChange:
{
id:=""
L:=""
If (A_EventInfo=1)
{
;if (winactive("YouTube"))
{
if (instr(clipboard, "https://www.youtube.com") or (instr(clipboard,"https://invidio.us") ) )
{
Loop,parse,clipboard, `n, `r
{
x= %a_loopfield%
if x=
continue
Loop, Parse,x,`/`=`&`?%a_space%`#`:
{
id:= A_LoopField
stringlen,L,id
if (L=11)
break
}
}
}
}
if (L=11)
{
clipboard=
url=https://www.youtube.com/watch?v=%id%
ifexist,%youtubedl%
{
;RunWait, %comspec% /k %sp1% %url% -x --audio-format mp3 --audio-quality 192k --youtube-skip-dash-manifest --restrict-filenames -o "%fdmp3%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s" ;- needs ffmpeg.exe
RunWait, %comspec% /k %sp1% %url% -x --audio-format mp3 --audio-quality 192k --youtube-skip-dash-manifest -o "%fdmp3%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s" ;- needs ffmpeg.exe
}
url=
id=
run,%fdmp3%
}
}
return
}
;--------------
/*
https://youtube-dl.org/
ffmpeg for AUDIO :
https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip
https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip
https://ffmpeg.zeranoe.com/builds/win32/static/
http://ffmpeg.org/download.html#build-windows
-f, --format FORMAT Video format code, see the "FORMAT
SELECTION" for all the info
--all-formats Download all available video formats
--prefer-free-formats Prefer free video formats unless a specific
one is requested
-F, --list-formats List all available formats of requested
videos
--youtube-skip-dash-manifest Do not download the DASH manifests and
related data on YouTube videos
--merge-output-format FORMAT If a merge is required (e.g.
bestvideo+bestaudio), output to given
container format. One of mkv, mp4, ogg,
webm, flv. Ignored if no merge is required
if instr(address, "youtube")
;~ runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" -f 18 --write-auto-sub --sub-lang fr -- %address% > temp.txt,, Hide, pid
;~ runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" -f 18 --write-auto-sub --sub-lang en -- %address% > temp.txt,, Hide, pid
runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" --write-auto-sub --sub-lang en -- %address% > temp.txt,, Hide, pid
else
runWait, %comspec% /k youtube-dl -o `"`%(title)s-`%(id)s.`%(ext)s`" --all-subs -- %address% > temp.txt,, Hide, pid
*/
;=================================== END script MP3 - Download ==============