spymare Posted June 25, 2010 Share Posted June 25, 2010 Hi i am trying to download more than 1 file at the same time. I got it to so i don't have to define a filename when it's downloaded, but i need to download a big list of rapidshare links from links.txt, and not only 1 by 1, it should start them all, please help, i tryed making a new process for eath download, but that is not a good solution for me, i know it can be done with background downloading, but it have to get it's default filename. here's my script: $file = FileOpen("links.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) ;If @error = -1 Then ExitLoop $url = ($line) ;source $folder = @UserProfileDir & "\Downloads\" ;destination folder InetGet($url,$folder & StringTrimLeft($url,StringInStr($url,"/",Default,-1))) ;stringinstr finds the last "/". Stringtrimleft trims all but the filename wend Link to comment Share on other sites More sharing options...
JohnOne Posted June 25, 2010 Share Posted June 25, 2010 You should read the lines of your file into an array, then loop through it downloading the files with the InetGet background flag set to 1. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 is it possible you can modify my code to do that ? im not sure how to do it Link to comment Share on other sites More sharing options...
Tvern Posted June 25, 2010 Share Posted June 25, 2010 Take a look at this post for an example and also for a way to increase the connection limit. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 (edited) i also put this together, but still only downloads one file . there's no problem if i do it like this: Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1) but it have to read the links from a txt file and still be able to download more than 1 file at same time $file = FileOpen("links.ini", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) $name = StringMid($line,StringInStr($line,"/",0,-1)+1) Do Local $hDownload = InetGet($line,@ScriptDir&"\"&$name) Local $hDownload = InetGet($line,@ScriptDir&"\"&$name) Sleep(250) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ; Close the handle to release resourcs. wend tyvern, thanks a lot for you post Edited June 25, 2010 by spymare Link to comment Share on other sites More sharing options...
JohnOne Posted June 25, 2010 Share Posted June 25, 2010 Something along the lines of this #include <File.au3> Global $aLinkArray $file = "links.ini" _FileReadToArray($file, $aLinkArray) If IsArray($aLinkArray) Then For $i = 1 To $aLinkArray[0] InetGet($aLinkArray[$i], @ScriptDir & "\" & $aLinkArray[$i] & ".tmp", 0, 1) Next EndIf AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 hmm can't get it working Link to comment Share on other sites More sharing options...
JohnOne Posted June 25, 2010 Share Posted June 25, 2010 (edited) Well it wont work as it is, if your file is just links and only links per line, and its a text file it should, but if it is in standard ini format of course it wont. Maybe you should provide a little more info about what exactly you cant get working and provide a sample of your file. Edited June 25, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 (edited) links.txt contais: http://rapidshare.com/files/265585704/warez-bb.Sonic.The.Hedgehog.The.Fastest.Thing.In.TimeDVDRiP.part1.rar http://rapidshare.com/files/265585705/warez-bb.Sonic.The.Hedgehog.The.Fastest.Thing.In.TimeDVDRiP.part2.rar http://rapidshare.com/files/265585750/warez-bb.Sonic.The.Hedgehog.The.Fastest.Thing.In.TimeDVDRiP.part3.rar http://rapidshare.com/files/265585546/warez-bb.Sonic.The.Hedgehog.The.Fastest.Thing.In.TimeDVDRiP.part4.rar and im logged into premium, so it's like a nornam download link i tryed this, probably totally wrong?: #include <File.au3> $file = FileOpen("links.ini", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) ;If @error = -1 Then ExitLoop $url = ($line) ;source $folder = @homedrive & "\Downloads\" ;destination folder InetGet($url,$folder & StringTrimLeft($url,StringInStr($url,"/",Default,-1))) ;stringinstr finds the last "/". Stringtrimleft trims all but the filename wend Edited June 25, 2010 by spymare Link to comment Share on other sites More sharing options...
JohnOne Posted June 25, 2010 Share Posted June 25, 2010 (edited) It might be something to do with the file path, Im not sure your trimleft trims anything, well there is no count anyway, are you getting errors? try this #include <File.au3> Global $aLinkArray $file = "links.ini" $folder = @homedrive & "\Downloads\" _FileReadToArray($file, $aLinkArray) If IsArray($aLinkArray) Then For $i = 1 To $aLinkArray[0] $atemp = StringSplit($aLinkArray[$i],"/",2) $savefile = $atemp[UBound($atemp) -1] $savepath = $folder & $savepath InetGet($aLinkArray[$i], $savepath, 0, 1) Next EndIf I'm also not convinced you can download a rapidshare file in this manner. Edited June 25, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 (edited) hmm its not working :/: Global $aLinkArray $file = "links.ini" $folder = @homedrive & "\Downloads\" _FileReadToArray($file, $aLinkArray) If IsArray($aLinkArray) Then For $i = 1 To $aLinkArray[0] $atemp = StringSplit($aLinkArray[$i],"/",2) $savefile = $atemp[UBound($atemp) -1] $savepath = $folder InetGet($aLinkArray[$i], $savepath, 0, 1) Next EndIf Edited June 25, 2010 by spymare Link to comment Share on other sites More sharing options...
JohnOne Posted June 25, 2010 Share Posted June 25, 2010 This line $savepath = $folder & $savepath should have been $savepath = $folder & $savefile Are you still refusing to give any other info other than "It dosent work" ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 i tryed $savepath = $folder & $savefile but it says savefile not have been declared. it's not because i don't wanna give info, im very new to autoit, so it's a bit hard to get started Link to comment Share on other sites More sharing options...
JohnOne Posted June 25, 2010 Share Posted June 25, 2010 "but it says savefile not have been declared" now we are getting someplace, thats an error Add Global $savefile Global $savepath Underneath the existing Global AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 25, 2010 Author Share Posted June 25, 2010 (edited) like this: #include <File.au3> Global $aLinkArray Global $savefile Global $savepath $file = "links.txt" $folder = @homedrive & "\Downloads\" _FileReadToArray($file, $aLinkArray) If IsArray($aLinkArray) Then For $i = 1 To $aLinkArray[0] $atemp = StringSplit($aLinkArray[$i],"/",2) $savefile = $atemp[UBound($atemp) -1] $savepath = $folder & $savepath InetGet($aLinkArray[$i], $savepath, 0, 1) Next EndIf error: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\pc\Desktop\New folder\New AutoIt v3 Script.au3" >Exit code: 0 Time: 0.209 also it comes with : error allocating memory Edited June 25, 2010 by spymare Link to comment Share on other sites More sharing options...
JohnOne Posted June 26, 2010 Share Posted June 26, 2010 Hmmm Its might be exiting befor the downloads have completed (not sure) with the downloads being in the background perhaps a loop of some sort until they have finished, not certain how it works fully. the exit code is normall. The allocating memory error , Im going to guess its too many downloads at one time. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
spymare Posted June 26, 2010 Author Share Posted June 26, 2010 there's only 2 links in the txt files Link to comment Share on other sites More sharing options...
Tvern Posted June 26, 2010 Share Posted June 26, 2010 (edited) The allocating memory error , Im going to guess its too many downloads at one time. The example I linked attempts 100 (very small) downloads at the same time. I doubt that's the problem. Its might be exiting befor the downloads have completed (not sure) with the downloads being in the background That'd be my guess. Try this: #include <File.au3> Global $aLinkArray Global $file = "links.txt" Global $folder = @homedrive & "\Downloads\" _FileReadToArray($file, $aLinkArray) _DownloadMultiple($aLinkArray, $folder) ;put it in a function so you can easily run it multiple times Func _DownloadMultiple($aLinks,$sFolder) Local $nComplete, $sSavePath, $sSaveFile, $aTemp, $aActive[Ubound($aLinks)-1] ;This is your script If IsArray($aLinks) Then For $i = 1 To $aLinks[0] $aTemp = StringSplit($aLinks[$i],"/",2) $sSaveFile = $aTemp[UBound($aTemp) -1] $sSavePath = $sFolder & $sSavePath $aActive[$i-1] = InetGet($aLinks[$i], $sSavePath, 0, 1) Next EndIf ;I added this part that waits until all downloads are complete Do For $i = 0 To $aLinks[0]-1 If InetGetInfo($aActive[$i],2) Then $aActive[$i] = False $nComplete += 1 EndIf Next Until $nComplete = $aLinks[0] EndFunc Edited June 28, 2010 by Tvern Link to comment Share on other sites More sharing options...
spymare Posted June 28, 2010 Author Share Posted June 28, 2010 hi tvern, thanks for you reply. the code doesent download the links, and neither gives any error :/ Link to comment Share on other sites More sharing options...
Tvern Posted June 28, 2010 Share Posted June 28, 2010 Yeah I made a cockup when renaming vars. Try the edited code instead(untested). There won't be any errors returned as you'll have to add errorchecking and timeouts yourself. This is just to show the concept. 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