thank you Titan , I don't understand regex here again a complicated script
thank you for the functions
I think flvplayer is standalone
now I can download
see links for player in the script
Code:
UPDATE=20070814
#NoEnv
SetBatchLines, 25ms
#SingleInstance force
#Persistent
setworkingdir, %a_scriptdir%
;http://www.autohotkey.net/~garry/Skan.jpg
;SMPLAYER =http://smplayer.sourceforge.net/en/index.php
;FLVPLAYER =http://keepvid.com/
;GOMPLAYER =http://www.gomplayer.com/codec/success.html?intCodec=10
F53=ytbe.txt
F55=_YOUTB.csv ;save links
AutoTrim Off
transform,S,chr,32
R3M=%A_scriptDir%\_VIDEO
ifnotexist,%R3M%
FileCreateDir,%R3M%
;example
CY1=http://www.youtube.com/watch?v=l-V-qlr0GTM ;Skan
;CY1=http://www.youtube.com/watch?v=iCKMzrPy4t4
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 vCY1,%CY1% ;edit1
Gui,1:Add, Edit, x65 y50 w530 h20 readonly, ;edit2
Gui,1:Add, Edit, x65 y75 w530 h20 readonly, ;edit3
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, x65 y130 w90 h25 gSTART,Start
Gui,1:Add, Button, x160 y130 w90 h25 gCLEAR,CLEAR
Gui,1:Add, Button, x500 y130 w90 h25 gBREAK,BREAK
Gui,1:Add, Button, x160 y160 w90 h25 gYOUTUBE,YOUTUBE
GuiControl,1:Focus,CY1
Gui,1:Show, x0 y0 h190 w600,VIDEO DOWNLOAD %UPDATE%
return
;------------------------------------------------------------------------
BREAK:
reload
return
CLEAR:
GuiControl,1:Focus,CY1
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
;######################### YOUTUBE ########################################
start:
Gui,1:submit,nohide
name=
adress=
CY2=
;http://www.youtube.com/watch?v=l-V-qlr0GTM ;Skan
;http://www.youtube.com/watch?v=iCKMzrPy4t4
;-------------- YOUTUBE NAME SEARCH ------------------------------------
UrlDownloadToFile,%CY1%,%F53%
B=var fs = window.open( "/watch_fullscreen?video_id= ;Anfang
CA=&fs= ;ende
V=0
Loop,Read,%F53%
{
LR=%A_LoopReadLine%
ifinstring,LR,<title>
{
name=
Loop Parse,LR,<> ,%A_Space%%A_Tab%
If (A_Index & 2)
Name=%A_LOOPFIELD%
}
IfInString,LR,%CA%
{
V++
StringGetPos,VAR1,LR,%B%
StringGetPos,VAR2,LR,%CA%
VAR1:=(VAR1+51)
VAR2:=(VAR2+1)
VAR3:=(VAR2-VAR1)
stringmid,ADRESS,LR,VAR1,VAR3
}
}
stringlen,len,name
dif:=(len-9)
stringmid,name,name,11,DIF
CY2=http://www.youtube.com/get_video?video_id=%ADRESS% ;new download adress URL-2
;---------- remove special characters ----------------------
new2=
Loop,Parse,NAME
{
A:=(Asc(A_LoopField))
B:=chr(a)
if (B="_" OR B=" ") ;allow _space autotrim,off
Goto,SKIP9
if ((a<48 or a>57) AND A<65 OR A>90 AND A<97 OR A>122)
continue
SKIP9:
new2=%new2%%b%
}
new2=%new2%.flv
;----- Find uri encoded characters such as %20 (space) and replace with ascii character ---
;----- TITAN 20070503 http://www.autohotkey.com/forum/topic18876.html ---------------------
NEW2:=uridecode4(NEW2)
uriDecode4(str)
{
pos = 1
Loop
If pos := RegExMatch(str, "i)(?<=%)[\da-f]{2}", hex, pos++)
StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
Else Break
NEW2=%STR%
Return,NEW2
}
;--------------------------------------------------------------------------------------------
stringreplace,new2,new2,%S%,_,all
GuiControl,1:Text,Edit2,%NEW2% ; name
GuiControl,1:Text,Edit3,%CY2% ; URL2
if new2=Broadcast_Yourself.flv
{
GuiControl,1:,Text22,REMOVED
return
}
F54=%R3M%\%NEW2%
SIZE3:=HttpQueryInfo(CY2,5)
GuiControl,1:+RANGE0-%SIZE3%,PRBAR ;CHANGE processbar
settimer,AAS4,250
URLDownloadToFile,%CY2%,%F54% ;downloads to desktop
settimer,AAS4,OFF
Filegetsize,size5,%F54%
if size5<50000
{
Filedelete,%F54%
GuiControl,1:,Text22,DELETED
return
}
GuiControl,1:+cFF7200,PRBAR
Fileappend,%NEW2%`;%CY1%`;%CY2%`;%F54%`;`r`n,%F55% ;save name and download-link URL-2
GuiControl,1:,PRBAR, %SIZE3%
GuiControl,1:,Text22,FINISHED 100 `% SIZE=%SIZE3%
run,%F54% ;run xy.flv with default player like VLC/FLV-/GOMPLAYER
GuiControl,1:Text,Edit1
GuiControl,1:Text,Edit2,
GuiControl,1:Text,Edit3,
GuiControl,1:,Text22,
FileRead,AA,%F55%
Sort,AA,u ;sort and remove double lines
Filedelete,%F55%
Fileappend,%AA%,%F55%
return
;================= GOSUBS ==================================
AAS4:
Filegetsize,size1,%F54%
RES1:=Round((100*SIZE1)/SIZE3)
GuiControl,1:,PRBAR, %SIZE1%
GuiControl,1:,Text22,%RES1% `% SIZE=%SIZE3%
return
;######################### END YOUTUBE ####################################
Guiclose:
exitapp
;############################### FUNCTION FOR YOUTUBE OLFEN #####################################
;================ BLOCK-A DETECT URL-2 TYPE(1) SIZE(5) HEADERS(21) =====================
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HttpQueryInfo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;http://www.autohotkey.com/forum/topic10510.html&highlight=dllcall+wininet+internetclosehandle
;SIZE:=HttpQueryInfo(URL, 5)
;msgbox,262144,MESSAGE,SIZE = %SIZE% Byte
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
}
;=================== END FUNCTION YOUTUBE ===========================================
