Jump to content

Filebeam.com Uploader UDF


boomingranny
 Share

Recommended Posts

;****************************************************
;   Func FileBeamPut (local filename, byref statustext)
;   Uploads the file to be hosted Filebeam.com
;   Returns - download link (or 1 if error)
;   by BoominGranny
;   djbarnes@orcon.net.nz
;   requires IE.au3
;****************************************************
func FileBeamPut($FileName, byref $StatusText)
    local $i
    
;vertify file type
    $status = "Vertifying File Type..."
    for $i = stringlen($FileName) to 1 step -1
        if stringmid($FileName,$i,1) = "." then;found file extention text start
            local $FileEXT = StringTrimLeft($FileName,$i)
            ExitLoop
        endif
    next
    
    switch $fileEXT
        case "exe", "zip", "rar", "gz", "tar", "tgz", "xls", "txt", "pdf", "doc", "ppt", "wmv","avi","mp3","mpg","mpeg","mov","7z","png","gif","jpg","jpeg"
        case Else
            return 1
    EndSwitch
    
    $status = "IE: Browsing to www.filebeam.com..."
    local $IEo = _IECreate("http://www.filebeam.com",0,0,1,0)
    
    $status = "Identifying Upload File Input Box"
    local $FileInput = _IEGetObjByName($IEo,"upfile")
    if @error > 0 then
        _IEQuit ($IEo)
        return 1
    endif
    
    $status = "Identifying Upload Button"
    local $Upload = _IEGetObjByName($IEo,"upload")
    if @error > 0 then
        _IEQuit ($IEo)
        return 1
    endif

    $status = "Selecting File to Upload..."
;Select the file to upload!
    _IEAction($FileInput, "focus")
    if @error > 0 then 
        _IEQuit ($IEo)
        return 1
    endif
    
    $status = "Sending Text to IE Window"
    local $hIE = _IEPropertyGet($IEo, "hwnd")
    ControlSend($hIE, "", "Internet Explorer_Server1", $FileName)
;ControlSend("", "", $FileInput, "C:\myfile.txt")
;_IEFormElementSetValue
;_IEFormElementSetValue ( $FileInput, $FileName)
    
    $status = "Clicking Upload Button"
;Click on upload button
    _IEAction ($Upload, "click") 
    
    $status = "Waiting For Upload..."
;wait for file to upload
;added - timeout is now 24 hours :)
    _IELoadWait($IEo,0,1000*60*60*24) 
    
    $status = "Processing returned HTML..."
;read in the result
    local $sHTML = _IEBodyReadHTML ($IEo)
    local $locatepassedtext = StringInStr($sHTML,"To DOWNLOAD this file go here:")
    if $locatepassedtext = 0 then $locatepassedtext = StringInStr($sHTML,"To view this image go here:")
    if $locatepassedtext > 0 Then
        $sHTML = StringTrimLeft ($sHTML,$locatepassedtext)
        $locatepassedtext = StringInStr ($sHTML,"<a href="&chr(34))
        if $locatepassedtext > 0 Then
            $sHTML = StringTrimLeft ($sHTML,$locatepassedtext + 8)
            $locatepassedtext = StringInStr ($sHTML,chr(34)&">")
            $sHTML = stringleft ($sHTML,$locatepassedtext-1)
            _IEQuit ($IEo)
            return $sHTML
        Else
            _IEQuit ($IEo)
            return 1
        endif
    Else
        _IEQuit ($IEo)
        return 1
    endif
EndFunc

example of usage:

#include <IE.au3>
;upload
If not FileExists ($cmdline[$cmdline[0]]) then;if there wasn't a file specified in the command line...
    $select = FileOpenDialog("Select a file to upload to Filebeam",@MyDocumentsDir,"All Files (*.*)",1)
    if @error then exit
Else
    $select = $cmdline[$cmdline[0]]
endif
global $status = ""
AdlibEnable("UpdateStatus",1000)
$url = filebeamPut($select, $status)
AdlibDisable()
ToolTip("")
if $url = 1 then;if it errored then 
    msgbox (64,"Error","Error Uploading "&$url)
Else
    InputBox ("Filebeam Link:", "Uploaded: "&$select& "Copy the Link to Clipboard?", $url,"", 400,140)
    if @ERROR then exit
    ClipPut ($url)
endif
exit

func UpdateStatus ()
    ToolTip ($status)
EndFunc

Enjoy :)

edit - edited example of usage to include command line params

edit2 - modified the timeout for upload from the autoit default (5min) to 24 hours - for those bigger files!

edit3 - modified so it includes an update for a status text variable - so you can see what its doing

edit4 - fixed so it will work when u upload pictures!

Edited by boomingranny
Link to comment
Share on other sites

Thanks >>

Please Script code Uploader on www.mediafire.com :)

Yes! That is exactly what I need! That would be great if you made a Mediafire uploaded, @boomingranny.

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