UPDATE=20071204 /* DATE.....................2007-12-03 garry .........................Download YOUTUBE and RECORD to MP3 MP3DirectCut 2.03 .......http://www.mpesch3.de/ and also mpglib.dll and lame_enc.dll (F12) for record flv.. to MP3 http://www-users.york.ac.uk/~raa110/audacity/lame.html http://www.autohotkey.net/~garry/WGETSTREAMMP3DIRECTCUT.zip How to use.............. start script, start youtube , copy youtube-video-link with rightclick or CTRL+C download starts automatically to c:\_YOUTUBE , automatically rename can play video and/ or record it to xy.mp3 >> needs mp3directcut.exe/mpglib.dll/lame_enc.dll (see links above) records to the same name then video ;http://www.autohotkey.com/forum/topic14882.html */ ;---------------------------------------------------------------------- #NoEnv setworkingdir, %a_scriptdir% NAMELV =funHU_YTB_AUDIO_RECORD02 autotrim,off clipboard= ;-- where to save downloaded videos and recorded MP3 ------- R3V=C:\_YOUTUBE ;<<<<<< save here ifnotexist,%R3V% FileCreateDir,%R3V% RU4=%R3V%\_RECORDING_MP3 ifnotexist,%RU4% FileCreateDir,%RU4% ;----------------------------------------------------- ;--- MP3directcut needed if you want record xy.flv to xy.mp3 ------ MyPLAYER =%A_ProgramFiles%\K-Lite Codec Pack\Media Player Classic\mplayerc.exe DIRECTCUT =%A_scriptDir%\MP3DIRECTCUT\mp3directcut.exe ;record xy.ram to xy.mp3 and cut mp3 files ;------------------------------------------------------ ;F1=http://www.funpic.hu/en.picview.php?id=32137 ;for test ;F1=http://www.youtube.com/watch?v=iCKMzrPy4t4 F1= F2= F3=ytbe.txt F4=urlkeep.txt MAXSIZE=50000 ;delete file below this size transform,S,chr,32 WA=%A_screenwidth% HA=%A_screenheight% SW :=(WA*95)/100 ;width guishow width SH :=(HA*90)/100 ;height TDY :=(SH*96)/100 ;Y position Textfield below when mplayerc starts Gui,1:Font, S10 CDefault, FixedSys Gui,1:Add, Text, x5 y25 w60 h20 ,URL-1 Gui,1:Add, Text, x5 y50 w60 h20 ,NAME Gui,1:Add, Text, x5 y75 w60 h20 ,URL-2 Gui,1:Add, Text, x5 y100 w60 h20 ,PROCESS Gui,1:Add, Edit, x65 y25 w530 h20 vF1,%F1% Gui,1:Add, Edit, x65 y50 w530 h20 vF2 readonly,%F2% Gui,1:Add, Edit, x65 y75 w530 h20 readonly, Gui,1:Add,Progress,x65 y100 w530 h20 vPRBAR cFF7200 Gui,1:Add,Text, x65 y100 w530 +0x200 +Center +BackgroundTrans vText22, Gui,1:Add, Button, x10 y130 w90 h25 gYOUTUBE ,YOUTUBE Gui,1:Add, Button, x110 y130 w90 h25 gFUNHU ,FUNPIC ;Gui,1:Add, Button, x310 y130 w90 h25 gCLEAR ,CLEAR Gui,1:Add, Button, x500 y130 w90 h25 gBREAK ,BREAK Gui,1:Add,Button ,x10 y470 w90 h25 gVIDEO ,VIDEO Gui,1:Add,Button ,x110 y470 w90 h25 gMUSIC ,MUSIC Gui,1:Add,Button ,x210 y470 w90 h25 gURLS ,URLS Gui,1:Add,Button ,x310 y470 w90 h25 gFOLDER ,FOLDER Gui,1:add,Text, cRED x420 y470 vTEXT1,RECORD (RightClick) Gui,1:Add,Edit, x90 y520 w500 h25 readonly, Gui,1:Add,Edit, x90 y550 w500 h25 readonly, Gui,1:Add,Edit, x90 y580 w500 h25 readonly, Gui,1:Add,Button, x2 y520 w80 h25 gDELETE ,DELETE Gui,1:Add,Button ,x2 y550 w80 h25 gDNL1 ,DNL1 > T1 :=570 T2 :=0 T3 :=0 T4 :=0 LSW:=T1+T2+T3+20 GSW:=LSW+30 Gui,1:Font, S12 CDefault, Verdana Gui,1:Add, ListView, x10 y170 grid r14 w%LSW% +hscroll nosort altsubmit vA1 gA2,Name|URL1|URL2|DATE Gui,1:Font, CDefault, FixedSys LV_ModifyCol(1,T1) LV_ModifyCol(2,T2) LV_ModifyCol(3,T3) LV_ModifyCol(4,T4) GuiControl,1:Focus,F1 Gui,1:Show, x0 y0 h620 w%GSW%,VIDEO DOWNLOAD and RECORD MP3 %UPDATE% gosub,video gosub,DDDD settimer,DDDD,1000 ;means goto start return ;------------------ END MENU -------------------------------------- ;------------------ LISTVIEW -------------------------------------- A2: Gui,1: Submit, NoHide Gui,1:ListView,A1 RN:=LV_GetNext("C") ;2 selected checked RF:=LV_GetNext("F") ;2 selected focused GC:=LV_GetCount() ;4 total if A_GuiEvent=Normal { if (RN="" OR RN=0) return C1= C2= C3= C4= LV_GetText(C1,A_EventInfo,1) LV_GetText(C2,A_EventInfo,2) LV_GetText(C3,A_EventInfo,3) LV_GetText(C4,A_EventInfo,4) GuiControl,1:Text,Edit4,%C1% if URLS=1 { GuiControl,1:Text,Edit5,%C2% GuiControl,1:Text,Edit6,%C3% return } if MUSIC=1 { run,%RU4%\%C1% return } goto,black } if A_GuiEvent = RightClick { if VIDEO=1 { LV_GetText(C1,A_EventInfo,1) SplitPath,C1,name, dir, ext, name_no_ext, drive if ext=flv goto,record } return } return ;----------- END LISTVIEW -------------------------------------- DELETE: ;----delete URLS textfile 1 selected line ------- if URLS=1 { if (RF="" OR RF=0) return LV_GetText(C1,RF,1) MsgBox, 4, ,Want you really delete from this list %C1% ? IfMsgBox,No Return Else { LV_Delete(RF) RN=0 filedelete,%F4% Loop % LV_GetCount() { BX1= BX2= BX3= BX4= LV_GetText(BX1,A_INDEX,1) LV_GetText(BX2,A_INDEX,2) LV_GetText(BX3,A_INDEX,3) LV_GetText(BX3,A_INDEX,3) fileappend,%BX1%;%BX2%;%BX3%;%BX4%`r`n,%F4% } } gosub,filllist1 return } return ;-------------- END DELETE --------------------------------------- ;--------------- READ URLS-FILE ---------------------------------------- URLS: VIDEO=0 MUSIC=0 URLS =1 GuiControl,1:Disable,URLS GuiControl,1:Enable ,VIDEO GuiControl,1:Enable ,MUSIC GuiControl,1:Enable,DELETE GuiControl,1:Enable,DNL1 > GuiControl,1:Text,TEXT1,%nothing% GuiControl,1:Text,Edit4, GuiControl,1:Text,Edit5, GuiControl,1:Text,Edit6, filllist1: LV_Delete() loop,read,%F4% { LR=%A_loopreadline% if LR= continue C1= C2= C3= C4= stringsplit,C,LR,`; LV_Add("",C1,C2,C3,C4) C1= C2= C3= C4= } return ;--------------- END READ URLS ------------------------------------------ ;--------------- READ FOLDERS-CONTENT ------------------------------------ VIDEO: VIDEO=1 MUSIC=0 URLS =0 R3XX=%R3V% GuiControl,1:Disable,VIDEO GuiControl,1:Disable,DELETE GuiControl,1:Disable,DNL1 > GuiControl,1:Enable,MUSIC GuiControl,1:Enable,URLS GuiControl,1:Text,TEXT1,RECORD (RightClick) goto,CONT03 MUSIC: VIDEO=0 MUSIC=1 URLS =0 R3XX=%RU4% GuiControl,1:Disable,MUSIC GuiControl,1:Disable,DELETE GuiControl,1:Disable,DNL1 > GuiControl,1:Enable ,VIDEO GuiControl,1:Enable,URLS GuiControl,1:Text,TEXT1,%nothing% CONT03: GuiControl,1:Text,Edit4, GuiControl,1:Text,Edit5, GuiControl,1:Text,Edit6, LV_Delete() I:=0 FSIZE:=0 Loop %R3XX%\*.* { LR=%A_LoopFileLongPath% SplitPath,LR,name, dir, ext, name_no_ext, drive I++ Filegettime,TM1,%LR%,C LV_Add("",A_loopfilename,TM1) } LV_ModifyCol(2,"integer") LV_ModifyCol(2, "Sort") LV_Modify(LV_GetCount(), "Vis") ;scrollt nach unten return ;--------------- END READ FOLDERS-CONTENT ------------------------------------ FOLDER: run,%R3V% return TEST: run,control desk.cpl,,3 return BREAK: reload return CLEAR: GuiControl,1:Focus,F1 GuiControl,1:Text,Edit1, GuiControl,1:Text,Edit2, GuiControl,1:Text,Edit3, GuiControl,1:,Text22, GuiControl,1:+cC8D0D4,PRBAR return FUNHU: run,http://www.funpic.hu/en.gallery.php?id=-2&s=dd&p=1 return YOUTUBE: run,http://www.youtube.com return ;======================= RECORD MP3directcut ======================================= RECORD: gui,1:submit,nohide ifnotexist,%directcut% { msgbox,262144,,Download MP3DirectCut and save in subfolder ...MP3DIRECTCUT\mp3directcut.exe`r`nDownload also mpglib.dll and lame_enc.dll (see settings F12)`r`n`r`nhttp://www.mpesch3.de/`r`nhttp://www-users.york.ac.uk/~raa110/audacity/lame.html return } if (RF="" OR RF=0) { msgbox,262144,,Select a row return } ifexist,%R3XX%\%C1% { SplitPath,C1, name, dir, ext, name_no_ext, drive if ext=mp3 { msgbox, Don't record an mp3 file return } run,%R3XX%\%C1% sleep,100 run,%DirectCut% %RU4%\%name_no_ext%.mp3 /rec ;folder not the same name then video run,sndvol32 return } return ;====================== END RECORD MP3DIRECTCUT =============================== ;=========================================================================== DDDD: Gui,1:submit,nohide URL1=%clipboard% if URL1 contains watch?v= goto,start2 if URL1 contains funpic goto,start2 return ;----------------------------------- START: gui,1:submit,nohide ;---------------------------------------- DNL1: Gui,1:submit,nohide if C2= return clipboard= URL1=%C2% START2: GuiControl,1:Text,Edit1,%URL1% clipboard= settimer,DDDD,off skip2: gui,1:submit,nohide if URL1= { msgbox,URL is missing return } ;============================================================================ ;===================== FUNPIC =============================================== if URL1 contains funpic { ;-- search for URL --------------------------------- StringGetPos,VAR1,URL1,id= VAR1:=(VAR1+4) stringmid,NEW,URL1,VAR1,5 stringleft,N1,NEW,2 ;------- search for title ------------------- ;
Description: A little acting ;)

Splashimage,,b w600 h30 CWred m9 b fs10 zh0,DOWNLOAD Search for URL2 >>> %URL1% urldownloadtofile,%URL1%,%F3% ;Splashimage, off Loop,Read,%F3% { LR=%A_LoopReadLine% ifinstring,LR,Description { StringGetPos,P1,LR,Description StringGetPos,P2,LR, P1:=(P1+22) P2:=(P2+1) P3:=(P2-P1) stringmid,DESCR,LR,P1,P3 NAME=%DESCR% break } } gosub,REMOVECHR URL2=http://www.funpic.hu/files/pics/000%N1%/000%NEW%.flv ;new download adress URL-2 sleep,2000 Splashimage, off goto,AA } ;=============== END FUNPIC ======================================= ;-------------- YOUTUBE NAME SEARCH ------------------------------------ if URL1 contains youtube { ;http://www.youtube.com/watch?v=J7noYuasI3k ;http://www.youtube.com/get_video?video_id=J7noYuasI3k&t=OEgsToPDskIIxLKb0nOjWRbyOGxTrhC5 ;var fullscreenUrl = '/watch_fullscreen?video_id=J7noYuasI3k&l=127&t=OEgsToPDskIIxLKb0nOjWRbyOGxTrhC5&sk=MYb6O0VPCVC_NLFr57SeNQC&fs=1&title=Vira_velho Carla_Pires'; Splashimage,,b w600 h30 CWred m9 b fs10 zh0,DOWNLOAD Search for name and URL2 >>> %URL1% UrlDownloadToFile,%URL1%,%F3% ;<<<<<<< ;Splashimage, off VANAF1=watch_fullscreen?video_id= UNTIL1=&sk= VANAF2=&title= UNTIL2='; V=0 Loop,Read,%F3% { LR=%A_LoopReadLine% ifinstring,LR,watch_fullscreen?video_id= { StringGetPos,VAR1,LR,%VANAF1% StringGetPos,VAR2,LR,%UNTIL1% VAR1:=(VAR1+27) VAR2:=(VAR2+1) VAR3:=(VAR2-VAR1) VAR4=http://www.youtube.com/get_video?video_id= stringmid,ADRESS,LR,VAR1,VAR3 URL2=%VAR4%%ADRESS% ;<<<< new adress URL2 StringGetPos,VAR11,LR,%VANAF2% StringGetPos,VAR12,LR,%UNTIL2% VAR11:=(VAR11+8) VAR12:=(VAR12+1) VAR13:=(VAR12-VAR11) stringmid,TITLE,LR,VAR11,VAR13 stringreplace,TITLE,TITLE,quot,%S%,all name=%TITLE% break } } gosub,REMOVECHR ;--- F2 is the newname --- } sleep,2000 Splashimage, off goto,AA ;============================================================================= ;------------------------------------ AA: stringmid,ANOW1,A_NOW,1,12 Fileappend,%F2%`;%URL1%`;%URL2%`;%ANOW1%`r`n,%F4% ;save name URL1 URL2 date SKIP4: SIZE3:=HttpQueryInfo(URL2,5) ;<<< check size from new URL2 adress GuiControl,1:+RANGE0-%SIZE3%,PRBAR ;CHANGE processbar GuiControl,1:Text,Edit3,%URL2% ; URL-2 GuiControl,1:Text,Edit2,%F2% ; name F2=%R3V%\%F2% ;--------------------- settimer,AAS4,250 URLDownloadToFile,%URL2%,%F2% ;downloads to %R3V% <<<<<<<<<<<<<<<<<<<<<< settimer,AAS4,OFF ;new DDDD test Splashimage,,b w600 h30 CWlime m9 b fs10 zh0,DOWNLOAD >>> %filename% FINISHED sleep,3000 Splashimage, off settimer,DDDD,1000 ;wait for new adress ;------------------ Filegetsize,size5,%F2% if size5<%MAXSIZE% { Filedelete,%F2% GuiControl,1:,Text22,DELETED return } GuiControl,1:,PRBAR, %SIZE3% GuiControl,1:,Text22,FINISHED 100 `% SIZE=%SIZE3% run,%F2% ;run xy.flv with default player like VLC/FLV-/GOMPLAYER gosub,video return ;================= GOSUBS ================================== AAS4: Filegetsize,size1,%F2% RES1:=Round((100*SIZE1)/SIZE3) GuiControl,1:,PRBAR, %SIZE1% GuiControl,1:,Text22,%RES1% `% SIZE=%SIZE3% return ;---------- remove special characters ---------------------- REMOVECHR: new2= Loop,Parse,NAME { A:=(Asc(A_LoopField)) B:=chr(a) if (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% } stringmid,ANOW1,A_NOW,1,12 ;not readable chinese... if new2= { new2=_%ANOW1%.flv F2=%new2% return } new2=%new2%.flv F2=%new2% ifexist,%R3V%\%F2% F2=_%ANOW1%_%F2% F2:=uridecode(F2) ;TITAN 20070503 http://www.autohotkey.com/forum/topic18876.html ; Find uri encoded characters such as %20 (space) and replace with ascii character uriDecode(str) { pos = 1 Loop If pos := RegExMatch(str, "i)(?<=%)[\da-f]{2}", hex, pos++) StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All Else Break F2=%STR% Return,F2 } return ;----------------- END REMOVE SPECIAL CHARACTERS --------------------------------- ;############################### BLACK ################################### ;-------------------------------------------------------------------------------------------------- BLACK: SysGet m, MonitorWorkArea Gui,4:-Border Gui,4:Color,000000 ;BLACK Gui,4:Font,S12 cwhite, Verdana Gui,4:Add,Text,center y%TDY% w%SW% cWhite,%C1% Gui,4:Show,% "x" mLeft+5 " y" mTop+5 " w" mRight-mLeft-10 " h " mBottom-mTop-10, BLACK ifexist,%MyPlayer% { PA="%R3XX%\%C1%" /fixedsize 1000,750 sleep,1000 Run,%MyPLAYER% %PA%,,hide,pid3 Process,wait,mplayerc.exe PID2 = %ErrorLevel% Process,exist,mplayerc.exe ; { ; sleep,2000 ; send,^0 ; remove border from mplayerc when once positioned ; } return } run,%R3XX%\%C1% return ;------------------------------------------------------------------------------------------------- ;############################### END BLACK ################################### ;################## ESCAPE ################################################# ~ESC:: gui,1:submit,nohide Gui,4:destroy process,close,%PID3% return ;=========================================================================== ;============================================================== guiclose: exitapp ;============================================================== ;-------------------------- FUNCTION GETSIZE before download ------------------------- ;http://www.autohotkey.com/forum/topic10510.html ; Olfen PhiLho ;SIZE:=HttpQueryInfo(URL, 5) ;msgbox,262144,MESSAGE,SIZE = %SIZE% Byte /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HttpQueryInfo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; QueryInfoFlag: HTTP_QUERY_RAW_HEADERS = 21 Receives all the headers returned by the server. Each header is terminated by "\0". An additional "\0" terminates the list of headers. HTTP_QUERY_CONTENT_LENGTH = 5 Retrieves the size of the resource, in bytes. HTTP_QUERY_CONTENT_TYPE = 1 Receives the content type of the resource (such as text/html). Find more at: http://msdn.microsoft.com/library/en-us/wininet/wininet/query_info_flags.asp Proxy Settings: INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration INTERNET_OPEN_TYPE_DIRECT 1 // direct to net INTERNET_OPEN_TYPE_PROXY 3 // via named proxy INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS */ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HttpQueryInfo(URL, QueryInfoFlag=21, Proxy="", ProxyBypass="") { hModule := DllCall("LoadLibrary", "str", "wininet.dll") If (Proxy != "") AccessType=3 Else AccessType=1 io_hInternet := DllCall("wininet\InternetOpenA" , "str", "" ;lpszAgent , "uint", AccessType , "str", Proxy , "str", ProxyBypass , "uint", 0) ;dwFlags If (ErrorLevel != 0 or io_hInternet = 0) { DllCall("FreeLibrary", "uint", hModule) return, -1 } iou_hInternet := DllCall("wininet\InternetOpenUrlA" , "uint", io_hInternet , "str", url , "str", "" ;lpszHeaders , "uint", 0 ;dwHeadersLength , "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item , "uint", 0) ;dwContext If (ErrorLevel != 0 or iou_hInternet = 0) { DllCall("FreeLibrary", "uint", hModule) return, -1 } VarSetCapacity(buffer, 1024, 0) VarSetCapacity(buffer_len, 4, 0) Loop, 5 { hqi := DllCall("wininet\HttpQueryInfoA" , "uint", iou_hInternet , "uint", QueryInfoFlag ;dwInfoLevel , "uint", &buffer , "uint", &buffer_len , "uint", 0) ;lpdwIndex If (hqi = 1) { hqi=success break } } IfNotEqual, hqi, success, SetEnv, res, timeout If (hqi = "success") { p := &buffer Loop { l := DllCall("lstrlen", "UInt", p) VarSetCapacity(tmp_var, l+1, 0) DllCall("lstrcpy", "Str", tmp_var, "UInt", p) p += l + 1 res := res . "`n" . tmp_var If (*p = 0) Break } StringTrimLeft, res, res, 1 } DllCall("wininet\InternetCloseHandle", "uint", iou_hInternet) DllCall("wininet\InternetCloseHandle", "uint", io_hInternet) DllCall("FreeLibrary", "uint", hModule) return, res } ;------------------------------------------------------------------