4got

InetGet download won't work correctly

9 posts in this topic

Hello everybody, it's been a long time since I wrote here last time, But I was focused on other projects :)

Now I've just started to code with autoit again, and need the help of the forum:

I have an url that points to a file that I need to download, and in this case the function InetGet is what I need, so this is the code:

InetGet("http://download.piriform.com/ccsetup504.exe", @HomeDrive & @HomePath & "\setup\CCleaner.exe",0,1)
InetGet("http://donate.libreoffice.org/home/dl/win-x86/4.4.1/en/LibreOffice_4.4.1_Win_x86.msi", @HomeDrive & @HomePath & "\setup\LibreOffice.msi",0,1)

In the first case, the program is downloaded ,but during the installation process, the installer unexpectedly closes; I think the installer is not entirely downloaded, because if I paste the same url in a browser the program is correctly downloaded.

In the second case the installer is downloaded, but it won't even starts, showing me an error.

What is wrong with this???

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Did you compare the size of the manual downloaded files?

PS. Your are downloading in the background so I hope you added logic to check whether it is finished or not to your script.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The size is the same for both the two files (CCleaner) but for Libreoffice the script downloads only a 32 KB file , and to check the download status I use

InetGetInfo($DownStatus, 2)
Edited by 4got

Share this post


Link to post
Share on other sites

This is the section of code for the download:

Local $DownStatus = InetGet("http://download.piriform.com/ccsetup504.exe", @HomeDrive & @HomePath & "\setup\CCleaner.exe",0,1) 
        
                ProgressOn("Downloading", "CCleaner", "In progress")
                Do
                    $PercDown = CalcDown(InetGetInfo($DownStatus, 1), InetGetInfo($DownStatus, 0))
                    ProgressSet($PercDown)
                    Sleep(250)
                Until (InetGetInfo($DownStatus, 2))
                ProgressOff();

There is a progress bar to see the download % , and CalcDown is a function that calculates the among of bytes downloaded , in order to update it.

Func CalcDown($total, $current)

    If $total <> 0 Then
        Local $MB = (($current * 100) / $total)
        Return Round($MB, 0)
    Else
        Return 0
    EndIf

EndFunc

Share this post


Link to post
Share on other sites

Looks good and this is the one that had the same size. Did you do a compare of the 2 files to see whether they are binary equal?

WinMerge could do that for example.

It should work when that is the case.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'll check with WinMerge, but what about libreoffice?

The code is the same but in this case only a small file is downloaded ,that's not Libreoffice.

 

***EDIT***

Maybe I catch the problem: when you open the link to Libreoffice , a web page is displayed ,and then the download starts, so MAYBE the inetget downloads the html and not the file.

Am I wrong?

Edited by 4got

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I'll check with WinMerge, but what about libreoffice?

The code is the same but in this case only a small file is downloaded ,that's not Libreoffice.

Have you looked at the actual content of the downloaded file?

You will see it is an HTML file that contains a redirect for the actual installer:

<meta http-equiv="Refresh" content="0; url=http://download.documentfoundation.org/libreoffice/stable/4.4.1/win/x86/LibreOffice_4.4.1_Win_x86.msi"/>

So just change your Inetget to:

InetGet("http://download.documentfoundation.org/libreoffice/stable/4.4.1/win/x86/LibreOffice_4.4.1_Win_x86.msi", "c:\temp\LibreOffice.msi")

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Checked the two version of CCleaner with WinMerge , it's the same file..........So I think it's not an autoit's problem.......

**EDIT**

Found the problem: I don't have to change the name of the downloaded file, because the installer probably crashes when tries to extract files from the .exe

Edited by 4got

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now