1 (изменено: Malcev, 2018-05-22 04:58:32)

Тема: AHK: Заливка файлов на filemail.com

filemail.com - быстрый файлообменник позволяющий заливать до 50 гб за одну сессию.
В бесплатном режиме можно заливать не чаще 2 раз в сутки, поэтому скрипт сильно не тестировал.

from := "from@gmail.com"
to := "to@gmail.com"
subject := "test"
message := "test message"
file := "C:\koski.mts"
MaxThreads := 4  ; количество потоков такое же как в IE



setbatchlines -1
Gui,  -border -caption +hwndhGui2
Gui, Show, w0 h0
percents := 0
SetTimer, uploadPercent, 300

SplitPath, file, FileName
FileName := URIEncode(FileName), from := URIEncode(from), to := URIEncode(to), subject := URIEncode(subject), message := URIEncode(message)
data := "sourcedetails=plupload(html5)+`%40+https`%3A`%2F`%2Fwww.filemail.com`%2F&to`%5B`%5D=" to "&from=" from "&subject=" subject "&message=" message "&days=7&confirmation=true"

HTTP := ComObjCreate("Msxml2.XMLHTTP")
HTTP.Open("POST", "https://www.filemail.com/api/transfer/initialize", true)
HTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)")
HTTP.SetRequestHeader("Pragma", "no-cache")
HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
HTTP.Send(data)
While HTTP.ReadyState != 4
   sleep 100
ResponseText := HTTP.ResponseText
If InStr(ResponseText, "FreeLimitReached")
{
   msgbox free limit reached
   ExitApp
}
RegexMatch(ResponseText, "s)""transferid"": ""(.+?)"".+?""transferkey"": ""(.+?)"".+?""transferurl"": ""(.+?)""", match)
transferid := match1, transferkey := match2, transferurl := match3

f := FileOpen(file, "r")
FileSize := f.length
chunksize := size := 5242880
chunks := Ceil(FileSize/chunksize)
LastChunkSize := Mod(FileSize, chunksize)
loop % chunks
{ 
   n++
   while (n > MaxThreads)
      sleep 100
   If (A_Index = chunks) and (LastChunkSize != 0)
      size := LastChunkSize
   safeArr := ComObjArray(0x11, size) ; Create SAFEARRAY = VT_ARRAY|VT_UI1
   pvData := NumGet(ComObjValue(safeArr) + 12 + (A_PtrSize==8 ? 4 : 0)) ; get pvData memeber
   f.RawRead(pvData + 0, size)
   body%A_Index% := safeArr

   link := transferurl "?transferid=" transferid "&transferkey=" transferkey "&runtime=html5&chunksize=" chunksize "&thefilename=" FileName "&totalsize=" FileSize "&chunks=" chunks "&chunk=" A_Index-1 "&retry=0"
   HTTP%A_Index% := ComObjCreate("Msxml2.XMLHTTP")
   HTTP%A_Index%.Open("POST", link, true)
   HTTP%A_Index%.OnReadyStateChange := Func("Ready").Bind(A_Index)
   HTTP%A_Index%.SetRequestHeader("Content-Type", "application/octet-stream")
   HTTP%A_Index%.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)")
   HTTP%A_Index%.SetRequestHeader("Pragma", "no-cache")
   HTTP%A_Index%.SetRequestHeader("Cache-Control", "no-cache, no-store")
   HTTP%A_Index%.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
   HTTP%A_Index%.Send(body%A_Index%)
   sleep 100
}
f.Close()

while (n != 0)
   sleep 100
data := "transferid=" transferid "&transferkey=" transferkey "&failed=false"
HTTP.Open("POST", "https://www.filemail.com/api/transfer/complete", true)
HTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)")
HTTP.SetRequestHeader("Pragma", "no-cache")
HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
HTTP.Send(data)
While HTTP.ReadyState != 4
   sleep 100
ResponseText := HTTP.ResponseText
SetTimer, uploadPercent, off
if RegexMatch(ResponseText, "s)""downloadurl"": ""(.+?)""", match)
   msgbox % clipboard := match1
else
   msgbox % ResponseText
ExitApp




uploadPercent:
if StrLen(title) > 5
   title := ""
else
   title .= "."
WinSetTitle, ahk_id %hGui2%,, % percents "%" title
return

Ready(Index)
{
   Global
   if (HTTP%Index%.ReadyState != 4)
      return
   else
   {
      n--
      count+=100/chunks
      percents := Format("{1:0.2f}", count)
      HTTP%Index% := body%Index% := ""
      return
   }
}

UriEncode(Uri)
{
   VarSetCapacity(Var, StrPut(Uri, "UTF-8"), 0)
   StrPut(Uri, &Var, "UTF-8")
   f := A_FormatInteger
   SetFormat, IntegerFast, H
   While Code := NumGet(Var, A_Index - 1, "UChar")
      If (Code >= 0x30 && Code <= 0x39 ; 0-9
         || Code >= 0x41 && Code <= 0x5A ; A-Z
         || Code >= 0x61 && Code <= 0x7A) ; a-z
         Res .= Chr(Code)
      Else
         Res .= "%" . SubStr(Code + 0x100, -1)
   SetFormat, IntegerFast, %f%
   Return, Res
}
+ DD

2

Re: AHK: Заливка файлов на filemail.com

Не нашел инфы о том, как долго потом могут храниться эти залитые файлы?

3

Re: AHK: Заливка файлов на filemail.com

7 дней.