BBs19 Posted January 3, 2015 Share Posted January 3, 2015 (edited) Hey guys, i am currently trying to automate the process of adding magnet links to my alldebrid.com account. So i checked the post request but i am struggling to understand where these random numbers in the post request come from. Request Headers: Host[upload.alldebrid.com] User-Agent[Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0] Accept[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8] Accept-Language[de,en-US;q=0.7,en;q=0.3] Accept-Encoding[gzip, deflate] Referer[https://www.alldebrid.com/torrent/] Cookie[__cfduid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; lang=en] Connection[keep-alive] The post data looks like this when using firefox: -----------------------------104342093532686 Content-Disposition: form-data; name="uid" xxxxxxxxxxxxxxxxxxxxxxxxxx -----------------------------104342093532686 Content-Disposition: form-data; name="domain" https://www.alldebrid.com/torrent/ -----------------------------104342093532686 Content-Disposition: form-data; name="magnet" magnet:magnetlink...... -----------------------------104342093532686 Content-Disposition: form-data; name="uploadedfile"; filename="" Content-Type: application/octet-stream -----------------------------104342093532686 Content-Disposition: form-data; name="submit" Convert this torrent -----------------------------104342093532686-- That number "104342093532686" changes on every submit. I tried changing the random number but i always get a response with "bad header". Does anyone have any idea how the random string or number is generated ? EDIT: I figured it out now, was a little tricky to get it working but it works now. Somehow the headers had to be in right order and i had to use the header "Content-Type: multipart/form-data" for the server to accept it. In case someone ever needs it: expandcollapse popupFunc _AlldebridAddTorrent($MagnetURL) Local $AlldebridCookie = _INetGetSource("https://www.alldebrid.com/api.php?action=info_user&login=" & $AlldebridPremiumUser & "&pw=" & $AlldebridPremiumPass) If @error Then Return SetError(1);Connection error $AlldebridCookie = _StringBetween($AlldebridCookie, "<cookie>", "</cookie>") If @error Then Return SetError(2);Login failed Else $AlldebridCookie = $AlldebridCookie[0] EndIf Local $Boundary = _TimeToTicks(@HOUR, @MIN, @SEC) Local $PostData = '------WebKitFormBoundary' & $Boundary & @CRLF & _ 'Content-Disposition: form-data; name="uid"' & @CRLF & @CRLF & _ $AlldebridCookie & @CRLF & _ '------WebKitFormBoundary' & $Boundary & @CRLF & _ 'Content-Disposition: form-data; name="domain"' & @CRLF & @CRLF & _ 'https://www.alldebrid.com/torrent/' & @CRLF & _ '------WebKitFormBoundary' & $Boundary & @CRLF & _ 'Content-Disposition: form-data; name="magnet"' & @CRLF & @CRLF & _ $MagnetURL & @CRLF & _ '------WebKitFormBoundary' & $Boundary & @CRLF & _ 'Content-Disposition: form-data; name="uploadedfile"; filename=""' & @CRLF & _ 'Content-Type: application/octet-stream' & @CRLF & @CRLF & @CRLF & _ '------WebKitFormBoundary' & $Boundary & @CRLF & _ 'Content-Disposition: form-data; name="submit"' & @CRLF & @CRLF & _ 'Convert this torrent' & @CRLF & _ '------WebKitFormBoundary' & $Boundary & '--' Local $PostHeaders = 'Host: upload.alldebrid.com' & @CRLF & _ 'Connection: keep-alive' & @CRLF & _ 'Content-Lenght: ' & StringLen($PostData) & @CRLF & _ 'Cache-Control: max-age=0' & @CRLF & _ 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' & @CRLF & _ 'Origin: https://www.alldebrid.com' & @CRLF & _ 'User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2243.0 Safari/537.36' & @CRLF & _ 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary' & $Boundary & @CRLF & _ 'Referer: https://www.alldebrid.com/torrent/' & @CRLF & _ 'Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4' & @CRLF & _ 'Cookie: lang=en; uid=' & $AlldebridCookie & '; ssl=1' Local $hOpen = _WinHttpOpen('Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)') Local $hConnect = _WinHttpConnect($hOpen, 'upload.alldebrid.com') If @error Then Return SetError(1);Connection error Local $sdata = _WinHttpSimpleRequest($hConnect, 'post', '/uploadtorrent.php', Default, $PostData, $PostHeaders) If @error Then Return SetError(1);Connection error If StringInStr($sdata, "Convert this torrent") Then $TorrentFilename = _StringBetween($MagnetURL, "&dn=", "&tr") If Not @error Then $TorrentFilename = StringReplace($TorrentFilename[0], "+", " ") Return ($TorrentFilename) Else Return SetError(5);fail EndIf EndIf _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc ;==>_AlldebridAddTorrent Edited January 4, 2015 by BBs19 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now