<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Заливка файлов на filemail.com]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=17680</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17680&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Заливка файлов на filemail.com».]]></description>
		<lastBuildDate>Mon, 13 Mar 2023 08:45:03 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: Заливка файлов на filemail.com]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=157150#p157150</link>
			<description><![CDATA[<p>filemail.com - быстрый файлообменник позволяющий заливать до 50 гб за одну сессию.<br />В бесплатном режиме можно заливать не чаще 2 раз в сутки, поэтому скрипт сильно не тестировал.<br /></p><div class="codebox"><pre><code>from := &quot;from@gmail.com&quot;
to := &quot;to@gmail.com&quot;
subject := &quot;test&quot;
message := &quot;test message&quot;
file := &quot;D:\SHOGUN_S001_S001_T002.rar&quot;



ComObjError(false)
setbatchlines -1
Gui,  -border -caption +hwndhGui
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 := &quot;sourcedetails=plupload(html5)+`%40+https`%3A`%2F`%2Fwww.filemail.com`%2F&amp;to`%5B`%5D=&quot; to &quot;&amp;from=&quot; from &quot;&amp;subject=&quot; subject &quot;&amp;message=&quot; message &quot;&amp;days=7&amp;confirmation=true&quot;

HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
loop
{
   HTTP.Open(&quot;POST&quot;, &quot;https://www.filemail.com/api/transfer/initialize&quot;, true)
   HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;)
   HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP.SetRequestHeader(&quot;Source&quot;, &quot;Web&quot;)
   HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
   HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
   HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
   HTTP.Send(data)
   HTTP.WaitForResponse()
   if (HTTP.Status = 200) or (HTTP.Status = 500)
      break
   sleep 50
}
ResponseText := HTTP.ResponseText
If InStr(ResponseText, &quot;FreeLimitReached&quot;)
{
   msgbox free limit reached
   ExitApp
}
RegexMatch(ResponseText, &quot;s)&quot;&quot;transferid&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;.+?&quot;&quot;transferkey&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;.+?&quot;&quot;transferurl&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;&quot;, match)
transferid := match1, transferkey := match2, transferurl := match3

f := FileOpen(file, &quot;r&quot;)
FileSize := f.length
chunksize := size := 5242880
chunks := Ceil(FileSize/chunksize)
LastChunkSize := Mod(FileSize, chunksize)
loop % chunks
{
   chunk := A_Index -1 
   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)
   loop
   {
      link := transferurl &quot;?transferid=&quot; transferid &quot;&amp;transferkey=&quot; transferkey &quot;&amp;runtime=html5&amp;chunksize=&quot; chunksize &quot;&amp;thefilename=&quot; FileName &quot;&amp;totalsize=&quot; FileSize &quot;&amp;chunks=&quot; chunks &quot;&amp;chunk=&quot; chunk &quot;&amp;retry=&quot; A_Index-1
      HTTP.Open(&quot;POST&quot;, link, true)
      HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/octet-stream&quot;)
      HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
      HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
      HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
      HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
      HTTP.Send(safeArr)
      HTTP.WaitForResponse()
      if (HTTP.Status = 200)
         break
      sleep 50
   }
   count+=100/chunks
   percents := Format(&quot;{1:0.2f}&quot;, count)
}
safeArr := &quot;&quot;
f.Close()

data := &quot;transferid=&quot; transferid &quot;&amp;transferkey=&quot; transferkey &quot;&amp;failed=false&quot;
loop
{
   HTTP.Open(&quot;POST&quot;, &quot;https://www.filemail.com/api/transfer/complete&quot;, true)
   HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;)
   HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP.SetRequestHeader(&quot;Source&quot;, &quot;Web&quot;)
   HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
   HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
   HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
   HTTP.Send(data)
   HTTP.WaitForResponse()
   if (HTTP.Status = 200)
      break
   sleep 50
}
ResponseText := HTTP.ResponseText
SetTimer, uploadPercent, off
if RegexMatch(ResponseText, &quot;s)&quot;&quot;downloadurl&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;&quot;, match)
   msgbox % clipboard := match1
else
   msgbox % ResponseText
ExitApp



uploadPercent:
if StrLen(title) &gt; 5
   title := &quot;&quot;
else
   title .= &quot;.&quot;
WinSetTitle, ahk_id %hGui%,, % percents &quot;%&quot; title
return



UriEncode(Uri)
{
   VarSetCapacity(Var, StrPut(Uri, &quot;UTF-8&quot;), 0)
   StrPut(Uri, &amp;Var, &quot;UTF-8&quot;)
   f := A_FormatInteger
   SetFormat, IntegerFast, H
   While Code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)
      If (Code &gt;= 0x30 &amp;&amp; Code &lt;= 0x39 ; 0-9
         || Code &gt;= 0x41 &amp;&amp; Code &lt;= 0x5A ; A-Z
         || Code &gt;= 0x61 &amp;&amp; Code &lt;= 0x7A) ; a-z
         Res .= Chr(Code)
      Else
         Res .= &quot;%&quot; . SubStr(Code + 0x100, -1)
   SetFormat, IntegerFast, %f%
   Return, Res
}</code></pre></div><p>Вариант с несколькими потоками - менее надежный:<br /></p><div class="codebox"><pre><code>from := &quot;from@gmail.com&quot;
to := &quot;to@gmail.com&quot;
subject := &quot;test&quot;
message := &quot;test message&quot;
file := &quot;C:\koski.mts&quot;
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 := &quot;sourcedetails=plupload(html5)+`%40+https`%3A`%2F`%2Fwww.filemail.com`%2F&amp;to`%5B`%5D=&quot; to &quot;&amp;from=&quot; from &quot;&amp;subject=&quot; subject &quot;&amp;message=&quot; message &quot;&amp;days=7&amp;confirmation=true&quot;

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

f := FileOpen(file, &quot;r&quot;)
FileSize := f.length
chunksize := size := 5242880
chunks := Ceil(FileSize/chunksize)
LastChunkSize := Mod(FileSize, chunksize)
loop % chunks
{ 
   n++
   while (n &gt; 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 &quot;?transferid=&quot; transferid &quot;&amp;transferkey=&quot; transferkey &quot;&amp;runtime=html5&amp;chunksize=&quot; chunksize &quot;&amp;thefilename=&quot; FileName &quot;&amp;totalsize=&quot; FileSize &quot;&amp;chunks=&quot; chunks &quot;&amp;chunk=&quot; A_Index-1 &quot;&amp;retry=0&quot;
   HTTP%A_Index% := ComObjCreate(&quot;Msxml2.XMLHTTP&quot;)
   HTTP%A_Index%.Open(&quot;POST&quot;, link, true)
   HTTP%A_Index%.OnReadyStateChange := Func(&quot;Ready&quot;).Bind(A_Index)
   HTTP%A_Index%.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/octet-stream&quot;)
   HTTP%A_Index%.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP%A_Index%.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
   HTTP%A_Index%.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
   HTTP%A_Index%.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
   HTTP%A_Index%.Send(body%A_Index%)
   sleep 100
}
f.Close()

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




uploadPercent:
if StrLen(title) &gt; 5
   title := &quot;&quot;
else
   title .= &quot;.&quot;
WinSetTitle, ahk_id %hGui2%,, % percents &quot;%&quot; title
return

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

UriEncode(Uri)
{
   VarSetCapacity(Var, StrPut(Uri, &quot;UTF-8&quot;), 0)
   StrPut(Uri, &amp;Var, &quot;UTF-8&quot;)
   f := A_FormatInteger
   SetFormat, IntegerFast, H
   While Code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)
      If (Code &gt;= 0x30 &amp;&amp; Code &lt;= 0x39 ; 0-9
         || Code &gt;= 0x41 &amp;&amp; Code &lt;= 0x5A ; A-Z
         || Code &gt;= 0x61 &amp;&amp; Code &lt;= 0x7A) ; a-z
         Res .= Chr(Code)
      Else
         Res .= &quot;%&quot; . SubStr(Code + 0x100, -1)
   SetFormat, IntegerFast, %f%
   Return, Res
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=13727">Тема для обсуждения</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 13 Mar 2023 08:45:03 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=157150#p157150</guid>
		</item>
	</channel>
</rss>
