DownloadMgr=%PROGRAMFILES%\FlashGet\flashget.exe
F1 =YouTube.TXT
URL1=%1%
UrlDownloadToFile,%URL1%,%F1%
transform,ten,chr,10
transform,tre,chr,13
CF=%TRE%%TEN%
Fileread,AA,%F1%
stringreplace,AA,AA,%TEN%,%CF%,all
filedelete,%F1%
Fileappend,%AA%`r`n,%F1%
CONTEN=var fullscreenUrl =
VANAF2=&title=
UNTIL2=';
MP4=0
SEARCHFOR=">watch in high quality</a>
Loop,Read,%F1%
{
LR=%A_LoopReadLine%
if LR contains %SEARCHFOR%
{
MP4=1
break
}
}
HSS=
HSS2=
SEARCHFOR=video_id=,l=,sk=,t=,hl=,plid=
Loop,Read,%F1%
{
LR=%A_LoopReadLine%
ifinstring,LR,%CONTEN%
{
Loop, Parse,LR ,`&,`
{
H%A_Index% := A_LoopField
if H%A_Index% contains %searchfor%
T%A_Index%:=A_LoopField
if T%A_Index%<>
HSS=%HSS%%A_LoopField%&
if A_loopfield contains title=
TITLE=%A_LoopField%
H%A_Index%=
T%A_index%=
}
stringreplace,TITLE,TITLE,title=,%nothing%,all
stringreplace,TITLE,TITLE,`',%nothing%,all
stringreplace,TITLE,TITLE,`;,%nothing%,all
; ---- replace at least portuguese letters --
stringreplace,TITLE,TITLE,quot,%S%,all
stringreplace,TITLE,TITLE,",%S%,all
stringreplace,TITLE,TITLE,&,%S%,all
;stringreplace,TITLE,TITLE,-,%S%,all
stringreplace,TITLE,TITLE,ç,c,all
stringreplace,TITLE,TITLE,é,e,all
stringreplace,TITLE,TITLE,è,e,all
stringreplace,TITLE,TITLE,ñ,n,all
stringreplace,TITLE,TITLE,ã,a,all
stringreplace,TITLE,TITLE,ç,c,all ;ç
stringreplace,TITLE,TITLE,ã,a,all ;ã
stringreplace,TITLE,TITLE,ö,oe,all ;ö
stringreplace,TITLE,TITLE,é,e,all ;é
stringreplace,TITLE,TITLE,Ã,a,all ;ÃÂ
break
}
}
stringlen,L5,HSS
END5:=(L5-1)
stringmid,HSS2,HSS,1,END5
URL2=[URL]http://www.youtube.com/get_video?%HSS2%[/URL]
if MP4=1
URL2=%URL2%&fmt=18
gosub,removechr
SplitPath,F2, name7, dir7, ext7, name_no_ext7, drive7
Run, "%DownloadMgr%" "%URL2%"
WinWait, Add new download, , 5
IfWinNotActive, Add new download, , WinActivate, Add new download,
WinWaitActive, Add new download,
SendInput, {TAB 7}%F2%{Enter}
exitapp
REMOVECHR:
autotrim,off
new2=
Loop,Parse,TITLE
{
A:=(Asc(A_LoopField))
B:=chr(a)
if (B="_" OR B=" " OR B="-") ;allow _space autotrim,off
Goto,SKIP8
if ((a<48 or a>57) AND A<65 OR A>90 AND A<97 OR A>122)
continue
SKIP8:
new2=%new2%%b%
}
autotrim,on
stringmid,ANOW1,A_NOW,1,12 ;if not readable chinese...
anow1=%anow1%
new2=%new2%
if new2=
{
if MP4=1
new3=_%ANOW1%.mp4
else
new3=_%ANOW1%.flv
F2=%new3%
return
}
if MP4=1
new3=%new2%.mp4
else
new3=%new2%.flv
F2=%new3%
ifexist,%REC%%F2%
F2=_%ANOW1%_%F2%
return