Jump to content

FileHippo Download and retrieve version V2.13


storme
 Share

Recommended Posts

It does exactly what i want at this time

It allows my script to grab the file regardless of any rubbish they do to mask the download, allows me to chose the filename for the downloaded file and gives me a progress to tell me its doing something.

What more does a boy need :mellow:

For the script im doing it does exactly what it says on the tin

Top Marks

Ill have to have a look at other sites like the ccleaner one to see if it can grab slim... might go do that now

Thanks again

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

New version is really nice, this is going the right way. :mellow:

Here my remarks on the latest version:

- Shouldn't the size of the array be +1?

- The name of the UDF: _FileDownloaderWebsites_UFF (still pretty long, but this covers it...kinda). Storme, (when you post it) can you post the UDF in a different thread?

- Maybe if the download folder parameter is empty then use the @scriptdir macro by default

- If een @error occured and $_FileDetails is empty then return "-1"

- I created a _DonwloadComDownload function (it's still based on 2.0). Based on that I think the array returned should either settle on a few entries that are found on most download sites or return a site specific array back. I set the entry to not available if nothing is found for an entry.

; #FUNCTION# ====================================================================================================================
; Name...........: _DonwloadComDownload
; Description ...: Downloads the designated file from Download.com and/or returns array with information about the software
; Syntax.........: _DonwloadComDownload($sProgramTitle, $sDownloadFolder[, $sDownloadFileName = ""][, $bDownload = True])
; Parameters ....: $sProgramTitle        - the title of the program as it appears in the URL
;                                        - "ccleaner" from http://download.com/ccleaner/
;                  $sDownloadFolder - the full path for the file to be downloaded to
;                  $sDownloadFileName    - the filename of the file to be downloaded
;                                        - if filename = "" use filename from download.com
;                  $bDownload            - True = program will be downloaded
;                                        - False = return Version number ONLY
; Return values .: Success - returns a 2D array containing technical details about the file (eg Filename, author, etc)
;                  Failure - ""
;                   @error = 1 - Unable to download programs/description page
;                   @error = 2 - Unable to read programs/description page
;                   @error = 3 - Unable to read download page
;                   @error = 4 - Unable to read URL to download program
;                   @error = 5 - Unable to download program
; Author ........: John Morrison aka Storm-E
; Modified.......: V2.0 Added details from TECH tab
; Remarks .......: Based on v2.0 for FileHippo
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _DonwloadComDownload($sProgramTitle, $sDownloadFolder, $sDownloadFileName = "", $bDownload = True)
    Local $DownloadUrl, $asDownloadUrl
    Local $sCurrentVersion, $asCurrentVersion
    Local $sBaseSite = 'http://download.com'
    Local $sBaseFolder = '/' & $sProgramTitle & '/'
    Local $avFileDetails[12]

    ;String trailing slash "\"
    If StringRight($sDownloadFolder, 1) = "\" Then StringLeft($sDownloadFolder, StringLen($sDownloadFolder) - 1)

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

    ;Get download URL
    $asDownloadUrl = StringRegExp($sPageSource, '(?s)(?i)<div class="downloadNow darkYODA"> <a href="(.*?)"><img src="http://i.i.com.com/cnwk.1d/i/tron/download/yoda/dlShuttleCock.png"', 3)
    $asDownloadUrlDetails = StringRegExp($sPageSource, '(?s)(?i)Diagnostic Software</a></li> <li> <a href="(.*?)" class="readMore">See full specifications</a>', 3)
    If @error Then
        Return SetError(2, 0, "")
    EndIf
    $DownloadUrl = $asDownloadUrl[0]
    $DownloadUrlDetails = $asDownloadUrlDetails[0]

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

    ;Get Details/description Table
    $asDescTable = StringRegExp($sPageSource, '(?s)(?i)<h2 class="mainS1">General</h2>(.*?)</section> <aside>', 3)
    If @error Then
        Return SetError(2, 0, "")
    EndIf
    $sDescTable = $asDescTable[0]

    ; create 1d array
    $avFileDetails[0] = "11"
    $avFileDetails[1] = "Version"
    $avFileDetails[2] = "Title"
    $avFileDetails[3] = "File name"
    $avFileDetails[4] = "File size"
    $avFileDetails[5] = "Operating systems"
    $avFileDetails[6] = "Languages"
    $avFileDetails[7] = "License model"
    $avFileDetails[8] = "Date added"
    $avFileDetails[9] = "Publisher"
    $avFileDetails[10] = "Publisher web site"
    $avFileDetails[11] = "MD5 Checksum"

    ;Convert to 2D array
    Dim $_FileDetails[UBound($avFileDetails)][2]
    $_FileDetails[0][0] = UBound($avFileDetails) ; number of rows in array
    For $item = 1 To UBound($avFileDetails) - 1 Step 1
        $asDescTable = StringRegExp($sDescTable, '(?s)(?i)' & $avFileDetails[$item] & '</strong> <span> (.*?) </span> </li>', 3)
        $_FileDetails[$item][0] = $avFileDetails[$item]
        If IsArray($asDescTable) Then
            $_FileDetails[$item][1] = $asDescTable[0]
        Else
            $asDescTable = StringRegExp($sDescTable, '(?s)(?i)' & $avFileDetails[$item] & '</strong> <span>(.*?)</span> </li>', 3)
            If IsArray($asDescTable) Then
                $_FileDetails[$item][1] = $asDescTable[0]
            ElseIf $item = 2 Then
                $_FileDetails[$item][1] = $sProgramTitle
            Else
                $_FileDetails[$item][1] = "Not available"
            EndIf
        EndIf
    Next

    ;Cleanup HomePage
    $iIndex = _ArraySearch($_FileDetails, "Publisher web site")
    $_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)

    If $bDownload Then

        If $sDownloadFileName = "" Then
            ;Use Download.com filename
            $sDownloadFileName = $_FileDetails[3][1]
        EndIf

        ; DOWNLOAD FILE
        Local $hDownload = InetGet($DownloadUrl, $sDownloadFolder & "\" & $sDownloadFileName, 1, 0)
        If @error Then
            Return SetError(5, 0, "")
        EndIf
    EndIf
    Return $_FileDetails

EndFunc   ;==>_DonwloadComDownload


Func _GetSourceCode($_Url)
    Local $_InetRead = InetRead($_Url)
    If Not @error Then
        Local $_BinaryToString = BinaryToString($_InetRead)
        If Not @error Then Return $_BinaryToString
    EndIf
EndFunc   ;==>_GetSourceCode
Edited by skin27
Link to comment
Share on other sites

Ill have to have a look at other sites like the ccleaner one to see if it can grab slim... might go do that now

The one liner you were given will get ccleaner_slim IF it's on the site but it is removed whenever they update the program and stays off for a week or 2. I've done a lot of searching and it just isn't available untill they put it up again.

You could try it and if there is no file there use the code you were given for "freewarehunter" to download the previous version.

At least then you'd have "a" version to install. :mellow:

Good Luck and let me know how you go. :)

John Morrison

Link to comment
Share on other sites

Yep the oneliner from ripdad is the kiddie

I already have the last downloaded version on the pendrive from the last successful attempt which is what i compare against the online version to tell whether to update or not.

So it doesn't really matter if cleaner drops for a week because the next time the update button is used when the link is back up it will get it as soon as available.

Its looking hopefull i might actually finish a script ... :mellow:

@ skin27 is this a deliberate error?

Func _DonwloadComDownload($sProgramTitle, $sDownloadFolder, $sDownloadFileName = "", $bDownload = True)

Look at the first Download after func Edited by Chimaera
Link to comment
Share on other sites

hey guys

looking fantastic so far. storme i was using an much earlier version of your file hippo and glad to find this awesome update. i may be able to dump ketarin soon woo hoo. File hippo works a treat, tried the sourceforge and it came up with error 3. i was using the following

$test = _SourceforgeDownload("drvback",@ScriptDir & "\downloads\",True)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $test = ' & $test & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

maybe as im tired im doing something stupid and cant see it.

anyway ill try the download com one soon too

keep up the great work

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

hey guys

looking fantastic so far. storme i was using an much earlier version of your file hippo and glad to find this awesome update. i may be able to dump ketarin soon woo hoo. File hippo works a treat, tried the sourceforge and it came up with error 3. i was using the following

$test = _SourceforgeDownload("drvback",@ScriptDir & "\downloads\",True)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $test = ' & $test & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

maybe as im tired im doing something stupid and cant see it.

anyway ill try the download com one soon too

keep up the great work

engjcowi, the sourceforge.com and download were just some other examples for Storme to get it in the udf. For your case, you may try the code below (turned out that driver backup projece using some whitespace in the download url).

; #FUNCTION# ====================================================================================================================
; Name...........: _SourceForgeDownload
; Description ...: Downloads the featured downloadfile from Sourceforge and/or returns the filename
; Syntax.........: _SourceforgeDownload($sProgramTitle, $sDownloadPathAndName, $bDownload = True)
; Parameters ....: $sProgramTitle        - the title of the program as it appears in the URL
;                                        - "projectname" from http://sourceforge.net/projects/projectname/
;                  $sDownloadPath - the full path to be downloaded to
;                  $bDownload            - True = program will be downloaded
;                                        - False = return Version number ONLY
; Return values .: Success - returns the latest version number
;                  Failure - ""
;                   @error = 1 - Unable to read programs page
;                   @error = 2 - Unable to read URL to download page
;                   @error = 3 - Unable to download program

; Author ........: Storme
; Modified.......: skin27
; Remarks .......:
; Related .......: _FileHippoDownload
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _SourceforgeDownload($sProgramTitle, $sDownloadPath, $bDownload = True)
    Local $_DownloadUrl1, $asFilename, $Filename
    Local $sCurrentFile, $asCurrentFile
    Local $sBaseSite = 'http://sourceforge.net'
    Local $sBaseFolder = '/projects/' & $sProgramTitle & '/'

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

    ;get latest file to download
    $asCurrentFile = StringRegExp($sPageSource, '(?s)(?i)title="Download /(.*?)from', 3)
    If @error Then
        Return SetError(2, 0, "")
    EndIf
    $sCurrentFile = $asCurrentFile[0]

    If $bDownload = true Then

        $_DownloadUrl1 = $sBaseSite & $sBaseFolder & 'files/' & StringStripWS($sCurrentFile,2) & '/download/'

        If StringInStr($asCurrentFile[0],"/") > 0 Then
            $item = StringSplit($asCurrentFile[0],"/")
            $sCurrentFile = $item[UBound($item) - 1]
        EndIf
        ; DOWNLOAD FILE
        Local $hDownload = InetGet($_DownloadUrl1, $sDownloadPath & $sCurrentFile, 1, 0)
        If @error Then
            Return SetError(3, 0, "")
        EndIf
    EndIf

    Return $sCurrentFile

EndFunc


Func _GetSourceCode($_Url)
    Local $_InetRead = InetRead($_Url)
    If Not @error Then
        Local $_BinaryToString = BinaryToString($_InetRead)
        If Not @error Then Return $_BinaryToString
    EndIf
EndFunc   ;==>_GetSourceCode
Link to comment
Share on other sites

Minor update to add some more error checking.

V2.121 Minor fix for properties that may not exist (Author & HomePage) Thanks 'Chimaera'

Link to comment
Share on other sites

  • 5 months later...

I can honestly say it was never and issue for me. (No beta for the programs I tested it with)

Can you give me an example of a program that picks up BETA copies?

Thanks!

John Morrison

Link to comment
Share on other sites

Here's two on Filehippo could you just not filter the word Beta in some way?

I never use Beta on Ketarin either, because in a workplace i dont need the hassle of on the edge builds

Edited by Chimaera
Link to comment
Share on other sites

I had a look last night and it's not quite that easy.

What I have to do is to check for "beta" in the "current" version.

Then scan the list of old versions untill I find one with out "beta" in the version.

Then change to the page for the old version.

I've got the skelton code worked out so give me a few days to get some paying work done and I'll put out the next version.

John Morrison

Link to comment
Share on other sites

New version

V2.13 Added option to ignore BETA copies "$bSkipBeta"

SCRIPT BREAKING CHANGES!!

$bSkipBeta was added before $FunctionToCall

So scripts that use the "$FunctionToCall" parameter will have to add a TRUE or FALSE for the "$bSkipBeta" parameter befoer it.

Let me know if you hit any errors and if you have any suggestions for improvments.

Link to comment
Share on other sites

  • 2 months later...

Hey

Is anyone having an issue with filehippo at the moment. everytime i use this at the moment it keeps throwing up error code 2.

jamie

Hi Jamie

There was a small change on the web site. All fixed now. ;)

Version 2.14 uploaded.

John Morrison

Link to comment
Share on other sites

  • 3 months later...

Just sharing an example to others how I use this code to keep my flash installers up to date. This is useful for offline sites with no ninite or internet etc

get_flash.au3

#Include <filehippoupdater.au3>

ProgressOn("FileHippo Download", "Downloading : flashplayer_ie")
$test = _FileHippoDownload("flashplayer_ie", @ScriptDir & "..InternetFlashx86", "", True, True, "_UpdateProgress")
ProgressOff()
ProgressOn("FileHippo Download", "Downloading : flashplayer_firefox")
$test = _FileHippoDownload("flashplayer_firefox", @ScriptDir & "..InternetFlashx86", "", True, True, "_UpdateProgress")
ProgressOff()

ProgressOn("FileHippo Download", "Downloading : flashplayer_ie_64")
$test = _FileHippoDownload("flashplayer_ie_64", @ScriptDir & "..InternetFlashx64", "", True, True, "_UpdateProgress")
ProgressOff()
ProgressOn("FileHippo Download", "Downloading : flashplayer_firefox_64")
$test = _FileHippoDownload("flashplayer_firefox_64", @ScriptDir & "..InternetFlashx64", "", True, True, "_UpdateProgress")
ProgressOff()


_ArrayDisplay($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

Next I will want to install flash to client machines. I do need to manually update the version number in the registry in this script, however its a fairly trival simple edit.

install_flash.au3

#NoTrayIcon
Opt("TrayIconDebug", 1)
Opt("WinTitleMatchMode", 2)
$g_szVersion = "SoFtWaRe"
If WinExists($g_szVersion) Then Exit ; It's already running
AutoItWinSetTitle($g_szVersion)
HotKeySet("{ESC}", "MyExit")
Func MyExit()
Exit
EndFunc

#requireadmin

; ===============================================================================================================================
; Flash Player (Non-IE)
$reldir = "InternetFlash"
$exe_x86 = "install_flash_player.exe"
$exe_x64 = "install_flash_player.exe"
$title = "Install Adobe Flash Player"

Select
Case @OSArch = "x86"
$exe = $exe_x86
$displayversion = "11.3.300.268"
Case @OSArch = "x64"
$exe = $exe_x64
$displayversion = "11.3.300.257"
EndSelect
$processname = $exe
$uninstallkey = "Adobe Flash Player Plugin"

$uninstallversion = RegRead("HKLM64SOFTWAREMicrosoftWindowsCurrentVersionUninstall" & $uninstallkey, "DisplayVersion") ; incase launched from 64bit installer
If $uninstallversion < $displayversion then
Install()
EndIf

; ===============================================================================================================================
; Flash Player (IE)
$reldir = "InternetFlash"
$exe_x86 = "install_flash_player_ax.exe"
$exe_x64 = "install_flash_player_ax.exe"
$title = "Install Adobe Flash Player"

Select
Case @OSArch = "x86"
$exe = $exe_x86
$displayversion = "11.3.300.268"
Case @OSArch = "x64"
$exe = $exe_x64
$displayversion = "11.3.300.257"
EndSelect
$processname = $exe
$uninstallkey = "Adobe Flash Player ActiveX"

$uninstallversion = RegRead("HKLM64SOFTWAREMicrosoftWindowsCurrentVersionUninstall" & $uninstallkey, "DisplayVersion") ;incase launched from 64bit installer
If $uninstallversion < $displayversion Then
Install()
EndIf

; ===============================================================================================================================

Func Install()
If Not ProcessExists($processname) Then
RunWait(@ScriptDir & ".." & $reldir & "" & @OSArch & "" & $exe & " -install")
;Stop updates from prompting
$File = FileOpen(@SystemDir & 'MacromedFlashmms.cfg',138) ;Use UTF8, overwrite existing data, create directory
FileWrite($File, "AutoUpdateDisable=1")
FileClose($File)
;Remove the scheduled task Adobe Flash Player Updater
ShellExecuteWait("schtasks.exe", '/delete /tn "Adobe Flash Player Updater" /f' , @SW_HIDE )
EndIf
While ProcessExists($processname)
Sleep(500)
WEnd
EndFunc

btw Im sure why the autoit forums always trim my tab characters,

Edited by NDog
Link to comment
Share on other sites

Great Work Storm-E!

Here is a small contribution.

#include-once
#include <Array.au3>
#include <File.au3>
; #FUNCTION# ====================================================================================================================
; Name...........: _PortableApp_Download
; Description ...: Downloads the designated file from SourceForge
; Syntax.........: _PortableApp_Download($sProgramTitle, $sDownloadFolder = @WorkingDir[, $sDownloadFileName = Default])
; Parameters ....: $sProgramTitle    - Any part of the program name that uniquely identifies the portable app
;                                        - "utorr" = [uTorrentPortable]
;                $sDownloadFolder   - the full path for the file to be downloaded to
;                                     - if sDownloadFolder omitted then uses the current working directory
;                $sDownloadFileName - the filename of the file to be downloaded
;                                   - if filename = Default the func uses the original file name.
;                $FunctionToCall    - [optional] A function which can update a Progressbar and react on UserInput like Click on Abort or Close App.
;                                   - If "$FunctionToCall" returns False abort download
;                                    -    Func _UpdateProgress($Percentage)
;                                  -      ProgressSet($Percentage,$Percentage &"%")
;                                    -    If _IsPressed("77") Then Return False ; Abort on F8
;                                    -    Return True ; ALL OK Continue download
;                                    -    Endfunc
; Return values .: Success - none
;              Failure - ""
;                 @error = 1 - Unable to download portable configuration file
;                 @error = 2 - Unable to parse configuration file
;                 @error = 3 - Unable to find download information for selected portable app
;                 @error = 4 - Unable to read URL to download program from configuration file
;                 @error = 5 - Unable to download program
;                 @error = 6 - Destination not reachable
;                 @error = 7 - Aborted by $FunctionToCall
;                 @error = 8 - $FunctionToCall doesn't exist
; Author ........: Rodney Teal + credited for function template John Morrison
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================

_PortableApp_Download("uTorrent")
If @error Then MsgBox(0, "", @error)

Func _PortableApp_Download($sProgramTitle, $sDownloadFolder = @WorkingDir, $sDownloadFileName = Default, $FunctionToCall = "", $sBaseSite = "http://downloads.sourceforge.net/portableapps/", $sConfig_File_URL = "http://portableapps.com/updater/update.ini")
    Local $sTemp_Dir = _TempFile() ; Reguires #include <File.au3>
    DirCreate($sTemp_Dir) ; Create Temp Dir for Ini file necessary to call Ini functions.

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

    HttpSetUserAgent("Wget/1.13.4") ; The Portable App Updater uses this User Agent to access portableapps.com/updater/update.ini
    Local $sPA_Config_File = $sTemp_Dir & "Config.ini"
    InetGet($sConfig_File_URL, $sPA_Config_File, 1, 0)
    If @error Then Return SetError(1, 0, 0)
    HttpSetUserAgent("") ; Resets User Agent

    Local $aPA_List = IniReadSectionNames($sPA_Config_File)
    If @error Then Return SetError(2, 0, 0)
;~     _ArrayDisplay($aPA_List)

    For $iPA = 1 To $aPA_List[0]
        If StringInStr($aPA_List[$iPA], $sProgramTitle, 2) Then ExitLoop
        If $iPA = $aPA_List[0] Then Return SetError(3, 0, 0) ; Return error if Portable app info wasn't found.
    Next

    Local $DownloadUrl = IniRead($sPA_Config_File, $aPA_List[$iPA], "DownloadFile", "")
    If $DownloadUrl = "" Then Return SetError(4, 0, 0)

    DirRemove($sTemp_Dir, 1) ; Remove Temp Dir

    If $sDownloadFileName = Default Then $sDownloadFileName = $DownloadUrl ; Set filename to i.e. uTorrentPortable_3.2.0.27636_online.paf.exe
    Local $hDownload = InetGet($sBaseSite & $DownloadUrl, $sDownloadFolder & "" & $sDownloadFileName, 1, 1)

    Local $iFileSize = InetGetSize($sBaseSite & $DownloadUrl, 1)
    Local $DownloadedSoFar = 0 ; howmany bytes of the file have been downloaded
    Local $bRtn = True ; Progress function return OK
;~     MsgBox(0, $sBaseSite & $DownloadUrl, $sDownloadFolder & "" & $sDownloadFileName)
    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
EndFunc

Later bro

Spoiler

censored.jpg

 

Link to comment
Share on other sites

  • 2 months later...

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...