Jump to content

FileHippo Download and retrieve version V2.13


storme
 Share

Recommended Posts

From the error it looks like thay may have changed there "file info" page.

I'll look at it tomorrow (1:30am here) and upload a new version.

Thanks for the feedback!

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

yesterday went to the script for filehippo.com, now is always error 2 display?

I just tried it and it worked perfectly for me.

Could you send me the calling lines (of code) you are using so I can check the file you are trying to get. There may have been a change just in that programs data that I haven't made allowance for.

Thanks!

John

Link to comment
Share on other sites

Hi, thanks for the efforts.

First of all it would be possible to develop a version for Softpedia.com? Below your script, which went up yesterday as well:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=AutoIt_Menu_Icon.ico
#AutoIt3Wrapper_Outfile_x64=Opera-download.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include-once
#include <array.au3>

Func _FileHippoDownload($sProgramTitle, $sDownloadFolder, $sDownloadFileName = "", $bDownload = True, $bSkipBeta = True, $FunctionToCall = "")
            Local $DownloadUrl, $asDownloadUrl
            Local $sCurrentVersion, $asCurrentVersion
            Local $sBaseSite = 'http://filehippo.com'
            Local $sBaseFolder = '/download_' & $sProgramTitle & '/'
            Local $sVersionFolder = "" ; for Beta rejection


            ;String trailing slash ""
            If StringRight($sDownloadFolder, 1) = "" Then StringLeft($sDownloadFolder, StringLen($sDownloadFolder) - 1)
            If DirCreate($sDownloadFolder) = 0 Then Return SetError(6, 0, "") ; destination unreachable

            ;Get source for program page
            Local $sPageSource = _GetSourceCode($sBaseSite & $sBaseFolder)
If @error Then
                        ;Failed to get programs page
                        Return SetError(1, 0, "")
            EndIf
            ;Latest Version<br/><b>Malwarebytes Anti-Malware 1.51.1</b><br/><br/>Old Versions
            $asCurrentVersion = StringRegExp($sPageSource, '(?s)(?i)Latest Version<br(.*?)</b><br/><br/>Old Versions', 3)
            If @error Then
                        Return SetError(2, 0, "")
            EndIf
            $sCurrentVersion = StringMid($asCurrentVersion[0], StringInStr($asCurrentVersion[0], " ", 0, -1) + 1)

            ;Check for BETA copy rejection
            If $bSkipBeta And StringInStr($asCurrentVersion[0], "beta") <> 0 Then
                        ;Get table of old versions
                        $asCurrentVersion = StringRegExp($sPageSource, '(?s)(?i)>Old Versions<(.*?)download_opera/history/', 3)
                        If @error Then
                                    Return SetError(2, 0, "")
                        EndIf

                        ; Break table into array
                        $asCurrentVersion = StringRegExp($asCurrentVersion[0], '(?s)(?i)<a href="/download_opera/(.*?)/">(.*?)</a>', 3)
                        If @error Then
                                    Return SetError(2, 0, "")
                        EndIf

                        ;search array for NON beta version
                        For $iItem = 1 To UBound($asCurrentVersion) - 1 Step 2
                                    If StringInStr($asCurrentVersion[$iItem], "beta") = 0 Then
                                                $sVersionFolder = $asCurrentVersion[$iItem - 1] & "/"
                                                $sCurrentVersion = StringMid($asCurrentVersion[$iItem], StringInStr($asCurrentVersion[$iItem], " ", 0, -1) + 1)
                                                ExitLoop
                                    EndIf
                        Next

                        If $sVersionFolder = "" Then
                                    ;NO NON BETA version available
                                    Return SetError(9, 0, "")
                        Else
                                    ;Found non beta

                                    ;Get source for non beta program page
                                    Local $sPageSource = _GetSourceCode($sBaseSite & $sBaseFolder & $sVersionFolder)
                                    If @error Then
                                                ;Failed to get programs page
                                                Return SetError(1, 0, "")
                                    EndIf
                        EndIf
            EndIf

            ;Get download URL
            $asDownloadUrl = StringRegExp($sPageSource, '(?s)(?i)<a href="' & $sBaseFolder & 'download/(.*?)/">', 3)
            If @error Then
                        Return SetError(2, 0, "")
            EndIf
            $_DownloadUrl1 = $asDownloadUrl[0]

            ;Get source for details page
            Local $sPageSource = _GetSourceCode($sBaseSite & $sBaseFolder & 'tech/')
            If @error Then
                        ;Failed to get programs page
                        Return SetError(1, 0, "")
            EndIf

            ;Get Details/description Table
            ;$asDescTable = StringRegExp($sPageSource, '(?s)(?i)<div class="desc">.*?<table>(.*?)</table>', 3)
            $asDescTable = StringRegExp($sPageSource, '(?s)(?i)<div id="txt">.*?<table>(.*?)</table>', 3)
            If @error Then
                        Return SetError(2, 0, "")
            EndIf
            $sDescTable = $asDescTable[0]

            ;Split up table
            $asDescTable = StringRegExp($sDescTable, '(?s)(?i)<tr><td><b>(.*?):</b></td><td>(.*?)</td></tr>', 3)
            If @error Then
                        Return SetError(2, 0, "")
            EndIf

            ;Convert to 2D array
            Dim $_FileDetails[UBound($asDescTable) / 2 + 2][2]
            $_FileDetails[0][0] = UBound($asDescTable) / 2 ; number of rows in array
            $_FileDetails[2][0] = $asDescTable[0]
            $_FileDetails[2][1] = $asDescTable[1]
            For $item = 2 To UBound($asDescTable) - 1 Step 2
                        $_FileDetails[$item / 2 + 2][0] = $asDescTable[$item]
                        $_FileDetails[$item / 2 + 2][1] = $asDescTable[$item + 1]
            Next

            ;Cleanup Author
            Local $iIndex = _ArraySearch($_FileDetails, "Author")
            If Not @error Then
                        $_FileDetails[$iIndex][1] = StringLeft($_FileDetails[$iIndex][1], StringInStr($_FileDetails[$iIndex][1], "<") - 1)
            EndIf

            ;Cleanup HomePage
            $iIndex = _ArraySearch($_FileDetails, "HomePage")
            If Not @error Then
                        $_FileDetails[$iIndex][1] = StringMid($_FileDetails[$iIndex][1], StringInStr($_FileDetails[$iIndex][1], "href=") + 6)
                        $_FileDetails[$iIndex][1] = StringMid($_FileDetails[$iIndex][1], 1, StringInStr($_FileDetails[$iIndex][1], '"') - 1)
            EndIf

            $_FileDetails[1][0] = "Latest Version"
            $_FileDetails[1][1] = $sCurrentVersion

            If $bDownload Then
                        ;<a href="/download_opera/download/f9c81a8e689661f472f47aa7a0b12ada/"><img src="http://cache.filehippo.com/img/down5.png" alt="Download"/></a>
                        ;Get source for download page
                        $sPageSource = _GetSourceCode($sBaseSite & $sBaseFolder & 'download/' & $_DownloadUrl1) ; downlaod page
                        If @error Then
                                    ;Failed to get programs page
                                    Return SetError(3, 0, "")
                        EndIf
                        ;<a id="_ctl0_contentMain_lnkURL" class="black" href="/download/file/de709ff1117ec419609d7fceecd86e625fe523b1385fa00515aa824249206a40/">If not then please click this link</a>
                        $asDownloadUrl = StringRegExp($sPageSource, '(?s)(?i)href="/download/file/(.*?)/">', 3)
                        If @error Then
                                    Return SetError(4, 0, "")
                        EndIf
                        $DownloadUrl = "/download/file/" & $asDownloadUrl[0] & "/"

                        If $sDownloadFileName = "" Then
                                    ;Use FileHippo filename
                                    $sDownloadFileName = $_FileDetails[_ArraySearch($_FileDetails, "Filename")][1]
                        EndIf

                        ; DOWNLOAD FILE
                        Local $iFileSize = InetGetSize($sBaseSite & $DownloadUrl, 1)
                        Local $DownloadedSoFar = 0 ; howmany bytes of the file have been downloaded
                        Local $bRtn = True ; Progress function return OK
                        Local $hDownload = InetGet($sBaseSite & $DownloadUrl, $sDownloadFolder & "" & $sDownloadFileName, 1, 1)
                        Do
                                    If $FunctionToCall <> "" Then
                                                $bRtn = Call($FunctionToCall, Floor((InetGetInfo($hDownload, 0) / $iFileSize) * 100))
                                                If @error Then
                                                            InetClose($hDownload) ; Close the handle to release resourcs.
                                                            Return SetError(8, 0, "")
                                                EndIf
                                    EndIf
                                    Sleep(250)
                        Until InetGetInfo($hDownload, 2) Or $bRtn = False ; Check if the download is complete.
                        Local $nBytes = InetGetInfo($hDownload, 0)
                        InetClose($hDownload) ; Close the handle to release resourcs.
                        If @error Then
                                    Return SetError(5, 0, "")
                        EndIf
                        If $bRtn = False Then
                                    ;Download aborted by $FunctionToCall
                                    Return SetError(7, 0, "")
                        EndIf
            EndIf
            Return $_FileDetails
EndFunc   ;==>_FileHippoDownload

Func _GetSourceCode($_Url)
            Local $_InetRead = InetRead($_Url)
            If Not @error Then
                        Local $_BinaryToString = BinaryToString($_InetRead)
                        If Not @error Then Return $_BinaryToString
            EndIf
EndFunc   ;==>_GetSourceCode


ProgressOn("FileHippo Download", "Downloading : opera")
$test = _FileHippoDownload("opera", @ScriptDir & "", "install_opera.exe", True, True, "_UpdateProgress")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $test = ' & $test & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
ProgressOff()
Run("$test")
Exit
#include <Misc.au3>
Func _UpdateProgress($Percentage)
    ProgressSet($Percentage, $Percentage & "%")
    If _IsPressed("77") Then Return False ; Abort on F8
    Return True ; bei 1 Fortsetzten
EndFunc   ;==>_UpdateProgress
Edited by timyboy
Link to comment
Share on other sites

Hi, thanks for the efforts.

First of all it would be possible to develop a version for Softpedia.com? Below your script, which went up yesterday as well:

ProgressOn("FileHippo Download", "Downloading : opera")
$test = _FileHippoDownload("opera", @ScriptDir & "\", "install_opera.exe", True, True, "_UpdateProgress")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $test = ' & $test & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
ProgressOff()
Run("$test")
Exit
#include <Misc.au3>
Func _UpdateProgress($Percentage)
ProgressSet($Percentage, $Percentage & "%")
If _IsPressed("77") Then Return False ; Abort on F8
Return True ; bei 1 Fortsetzten
EndFunc ;==>_UpdateProgress

I'll look into a "Softpedia" version and see if it's possible.

2nd - its never a good idea to remove the header of a function because there is usually good inforamtion in it and the author (me) was trying to help you use the function.

; $bSkipBeta - [optional] True = BETA copies will not be downloaded False = latest version will be downloaded

Opera is beta and you specified that you don't want beta copies.

I'll have to think about this situation and work out how to handle it.

My thoughts are just raise another error number that specifies no non-betas available.

hmmm

Anyway your problem can be fixed by changing the "$bSkipBeta" (the second true) to a False.

If you have any more problems let me know.

John Morrison

Link to comment
Share on other sites

Hi, thanks for the efforts.

First of all it would be possible to develop a version for Softpedia.com?

I had a look at the site and it doesn't look easy or maybe even do-able.

The software is sorted into catagories so the script would have to search for the software first.

and the pages I looked at have been convereted to hex to stop easy access so it would all have to be done with the IE library.

I can forsee a lot of pain for anyone who tries to automate this site.

So sorry I won't be tackling this one. :(

Link to comment
Share on other sites

  • 5 months later...

Hello - Thanks for fhe script!

I've been working on an iTunes updater/installer using AutoIt and found this thread today.

Regarding the version number element[1][1] - for iTunes it is returning "(32-bit)" or "(64-bit)" which is the end of the string rather than the actual version number.

It will do the same for VLC considering the same scenario.

Is there a way to except those in your script for $sCurrentVersion or $asCurrentVersion ?

Edited by rogerthehart
Link to comment
Share on other sites

Hello - Thanks for fhe script!

I've been working on an iTunes updater/installer using AutoIt and found this thread today.

Regarding the version number element[1][1] - for iTunes it is returning "(32-bit)" or "(64-bit)" which is the end of the string rather than the actual version number.

It will do the same for VLC considering the same scenario.

Is there a way to except those in your script for $sCurrentVersion or $asCurrentVersion ?

Hi rogerthehart

This is a problem I ran into when I was developing the script. The version number is part of the program name and can come in a multiitude of forms.

I eventually came up with this simple line to remove the program name

$sCurrentVersion = StringMid($asCurrentVersion[0], StringInStr($asCurrentVersion[0], " ", 0, -1) + 1)

Which just looks for the LAST space and extracts everything after that as the version number.

Which worked fine for everything I tested it on back then but that then added " (32-Bit)" and messed it up....sigh

Sorry for the late reply I wrote the above days ago wandered off to try and find a solution (haven't found one yet). Then for got to send this. Sorry!

I was hoping there was a quick fix... but no... There are other variations that won't work either. :(

So I'm at a bit of a lose what to do next.

When I"m out form under the computers I'm working on I'll get back onto it but maybe one of the RegEX experts could build something up to just extract the version from the full name...

In the mean time you could mod the code to remove the (32bit)/(64bit) form the end of the name as a temporary solution while we try and find a more perminent solution.

Link to comment
Share on other sites

I think I got something--

I inserted these lines right before the line "$sCurrentVersion = StringMid($asCurrentVersion[0], StringInStr($asCurrentVersion[0], " ", 0, -1) + 1)"

and got the version info back.

; strip (32-bit) or (64-bit) from version string
   if StringInStr($asCurrentVersion[0], "(32-bit)") Then
    $asCurrentVersion[0] = StringReplace($asCurrentVersion[0], " (32-bit)", "")
   EndIf
   if StringInStr($asCurrentVersion[0], "(64-bit)") Then
    $asCurrentVersion[0] = StringReplace($asCurrentVersion[0], " (64-bit)", "")
   EndIf
Link to comment
Share on other sites

I think I got something--

I inserted these lines right before the line "$sCurrentVersion = StringMid($asCurrentVersion[0], StringInStr($asCurrentVersion[0], " ", 0, -1) + 1)"

and got the version info back.

; strip (32-bit) or (64-bit) from version string
if StringInStr($asCurrentVersion[0], "(32-bit)") Then
$asCurrentVersion[0] = StringReplace($asCurrentVersion[0], " (32-bit)", "")
EndIf
if StringInStr($asCurrentVersion[0], "(64-bit)") Then
$asCurrentVersion[0] = StringReplace($asCurrentVersion[0], " (64-bit)", "")
EndIf

Yep that will work fine for your situation. Well Done!

I'm looking for a more permanent solution to handle your situation and the others like this "Picasa 3.9 Build 136.20".

The simplest solution would be to add a string replace for each situation (maybe replace the " build " in the above situation with a full stop ".") but that grates against my sense of neatness. :(

Anyway if all else fails you'll see the solution in the code. :)

BTW a quick dirty way of doing the same thing is

$asCurrentVersion[0] = StringReplace($asCurrentVersion[0], " (32-bit)", "")
$asCurrentVersion[0] = StringReplace($asCurrentVersion[0], " (64-bit)", "")

The IF's are nice and neat but the string replace can handle the situation if the strings aren't there.

OR you could even nest functions like this

; remove platform indicators from program name
$asCurrentVersion[0] = StringReplace(StringReplace($asCurrentVersion[0], " (32-bit)", ""), " (64-bit)", "")

and save redefining $asCurrentVersion[0] twice.

I didn't do any checks on speed or "garbage" creation on these but they will all work. :)

Let me know if you have any other problems. It's good to know when people are using the code I put out. :)

John Morrison

Edited by storme
Link to comment
Share on other sites

  • 8 months later...

I've just had a look and yes with the update the pages have changed.

I'll have a look and see what needs to be changed.  Hopefully not too much. :)

Stay tuned...

Link to comment
Share on other sites

OK here is a new version hot off the presses. :)

It hasn't been fully tested yet so far if you find any bugs let me know ASAP

Have fun

John Morrison

Edit: New version (V2.3.1) uploaded down a few messages. :)

Edited by storme
Link to comment
Share on other sites

  • 1 month later...

No problem I'm glad to help!

If you have any problems with it in future let me know and I'll get it fixed.

 

Have fun

John

Link to comment
Share on other sites

For 7-zip_64 it returns Latest Version as: (64-bit) if searching for NON beta version.

 

Change This:

;search array for NON beta version
        For $iItem = 1 To UBound($asCurrentVersion) - 1 Step 2
            If StringInStr($asCurrentVersion[$iItem], "beta") = 0 Then
                $sVersionFolder = $asCurrentVersion[$iItem - 1]
                $sCurrentVersion = StringMid($asCurrentVersion[$iItem], StringInStr($asCurrentVersion[$iItem], " ", 0, -1) + 1)
                ExitLoop
            EndIf
        Next

 

With This:

;search array for NON beta version
        For $iItem = 1 To UBound($asCurrentVersion) - 1 Step 2
            If StringInStr($asCurrentVersion[$iItem], "beta") = 0 Then
                $sVersionFolder = $asCurrentVersion[$iItem - 1]
    $asCurrentVersion[$iItem] = StringStripWS(StringRegExpReplace($asCurrentVersion[$iItem],"\((32|64)-bit\)",""),3) ; remove (32|64-bit)
                $sCurrentVersion = StringMid($asCurrentVersion[$iItem], StringInStr($asCurrentVersion[$iItem], " ", 0, -1) + 1)
                ExitLoop
            EndIf
        Next

 

That should fix it. ;)

Link to comment
Share on other sites

Thank you Proph for catching that one for me.

Here is the updated version with your fix in. :)

Let me know if you find any other errors.

John

_FileHippoDownloadV2.3.1.zip

Link to comment
Share on other sites

  • 1 month later...

I've been trying to modify the script to also skip "Dev" when Betas are supposed to be skipped.  Since Google Chrome releases Dev versions all the time.  They don't call them beta's... but I personally would consider them Betas.  The issue I have is that if all of the versions found on the first page are Devs or Betas... then there is an issue with the script.  Because the script does not know how to check the next page of releases.

I know this isn't an issue with any of the other downloads on FileHippo currently.... and I am only noticing this issue on chrome when I skip "Dev" releases. (Also Chrome download from FH cannot be automated... since it send you to another page to download chrome anyways)  But... if there is ever a file that has a bunch of Beta releases in a row... I could see there being an issue with this script because it does not try to go to the next page.

Other than that it is pretty great at what it is intended to do.  Thanks Again!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...