Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;loginwall;;;
- get_site:= http://archive.org/download/somefiles/file.zip
- save= C:\temp\file.zip
- filecreatedir, C:\temp
- username_str= user@email.com
- password_str= archive.org_password
- splitpath,save,filename,savetmp
- filetmp= %savetmp%\tmp.tmp
- fileold= %savetmp%\old.del
- filedelete, %filetmp%
- filedelete, %fileold%
- ;;;5mb download chunk initialize;;;;
- bgn:= 0
- dnd:= 5000000
- arcfinz=
- post_site:="https://archive.org/account/login.php"
- post_data:="username=" username_str "&password=" password_str "&remember=CHECKED&referer=https://archive.org&action=login&submit=Log in"
- Loop,
- {
- if (arcfinz = 2)
- {
- break
- }
- WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- WebRequest.Open("POST", post_site)
- WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
- WebRequest.SetRequestHeader("Cookie", "test-cookie=1")
- WebRequest.Send(post_data)
- WebRequest.Open("HEAD",get_site)
- WebRequest.Send()
- arcfz= % WebRequest.GetResponseHeader("Content-Length")
- WebRequest.Open("GET",get_site)
- ;;; set the download chunk range ;;;;;
- WebRequest.SetRequestHeader("Range", "bytes=" bgn "-" dnd "")
- WebRequest.Send()
- WebRequest.WaitForResponse(5)
- ADODBObj := ComObjCreate( "ADODB.Stream" )
- ADODBObj.Type := 1
- ADODBObj.Open()
- ADODBObj.Position := 0
- ADODBObj.Write( WebRequest.ResponseBody )
- ADODBObj.SaveToFile(filetmp, True ? 2:1)
- ADODBObj.Close()
- ADODBObj:=""
- WebRequest:=""
- if FileExist(filetmp)
- {
- filegetsize,fmtmp,%filetmp%
- ;;;;; increment chunks ;;;;;
- bgn+=5000001
- dnd+=5000000
- if ((dnd > arcfz)&&(arcfinz = "")) ;;if projected download chunk exceeds the actual size, make the projected final download chunk the actual size
- {
- arcfinz= 1
- dnd:= arcfz
- }
- finv:= dnd - bgn
- }
- if FileExist(fileold)
- {
- RunWait,%comspec% cmd /c copy /b "%fileold%"+"%filetmp%" "%save%",,hide ;;concatenates tmp files
- filedelete, "%filetmp%"
- filedelete, "%fileold%"
- if (arcfinz = 2)
- {
- break
- }
- filemove,%save%,%fileold%,1
- }
- else
- {
- filemove, %filetmp%,%fileold%,1
- }
- filegetsize,oldtmp,%fileold%
- if (fmtmp < 20000)
- {
- if (arcfz <= oldtmp)
- {
- filemove,%fileold%,%save%,1
- break
- }
- msgbox,,,failed
- exitapp
- }
- if (arcfinz <> "")
- {
- arcfinz+=1
- }
- }
- msgbox,,,file downloaded
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement