Download via input box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • rexzooly
    No longer a forum member
    • Jul 2007
    • 1512

    Download via input box

    Download via input box
    Hey i am trying to fix a little problem i get with some programs taking over my
    urls when downloading like a mp3 people know whom have some media players install love to take over the handling of this and plays now downloads.
    i have easly done this but i want to be able to so say if there is no
    mp3 or that ever file EX so if its .co.uk is just save a simple html version of the
    link

    get

    .co.uk or co.uk/ or net/here/there/anotherdir/file/

    so far i am doing a very long way like so

    Code:
    [B]
    getlinkme [COLOR="DarkOrange"]=[/COLOR] Input[COLOR="Red"].[/COLOR]GetText([COLOR="DarkOrchid"]"linkme"[/COLOR]);
    
    urlLink [COLOR="DarkOrange"]=[/COLOR] String[COLOR="Red"].[/COLOR]SplitPath(getlinkme);
    
    isTrue [COLOR="DarkOrange"]= [/COLOR]HTTP.TestConnection(getlinkme[COLOR="Red"],[/COLOR] 5[COLOR="Red"],[/COLOR] 80);
    nFileFN [COLOR="DarkOrange"]=[/COLOR] urlLink[COLOR="Red"].[/COLOR]Filename
    nFileEX [COLOR="DarkOrange"]=[/COLOR] urlLink[COLOR="Red"].[/COLOR]Extension
    
    [COLOR="Blue"]if[/COLOR] nFileEX [COLOR="DarkOrange"]== [/COLOR][COLOR="DarkOrchid"]".com" [/COLOR][COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]= [/COLOR]nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]==[/COLOR] [COLOR="DarkOrchid"]".co.uk" [/COLOR][COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]==[/COLOR][COLOR="DarkOrchid"] ".net"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif [/COLOR]nFileEX [COLOR="DarkOrange"]==[/COLOR] [COLOR="DarkOrchid"]".de"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]== [/COLOR][COLOR="DarkOrchid"]".fr"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]==[/COLOR] [COLOR="DarkOrchid"]".co.jp"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]==[/COLOR] [COLOR="DarkOrchid"]".org"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]= [/COLOR]nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif [/COLOR]nFileEX [COLOR="DarkOrange"]==[/COLOR] [COLOR="DarkOrchid"]".org.uk"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]== [/COLOR][COLOR="DarkOrchid"]".gov" [/COLOR][COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]elseif[/COLOR] nFileEX [COLOR="DarkOrange"]==[/COLOR] [COLOR="DarkOrchid"]".gov.uk"[/COLOR] [COLOR="Blue"]then[/COLOR]
    nFile [COLOR="DarkOrange"]=[/COLOR] nFileFN[COLOR="Red"]..[/COLOR][COLOR="DarkOrchid"]".html"[/COLOR]
    [COLOR="Blue"]else[/COLOR]
    nFile [COLOR="DarkOrange"]= [/COLOR]nFileFN..nFileEX
    [COLOR="Blue"]end[/COLOR]
    
    [COLOR="Blue"]if[/COLOR](isTrue [COLOR="DarkOrange"]==[/COLOR] false) [COLOR="Blue"]then[/COLOR]
    Dialog[COLOR="Red"].[/COLOR]Message("Error 404", [COLOR="DarkOrchid"]"Error seems the url is missing, wrong, locked or your internet connection is disabled"[/COLOR], MB_OK, MB_ICONNONE, MB_DEFBUTTON1);
    [COLOR="Blue"]else[/COLOR]
    StatusDlg[COLOR="Red"].[/COLOR]Show(MB_ICONNONE, false);
    HTTP[COLOR="Red"].[/COLOR]Download(getlinkme[COLOR="Red"],[/COLOR] _DesktopFolder[COLOR="Red"]..[/COLOR]"[COLOR="DarkOrchid"]\\"[/COLOR][COLOR="Red"]..[/COLOR]nFile[COLOR="Red"],[/COLOR] MODE_BINARY[COLOR="Red"],[/COLOR] 20[COLOR="Red"],[/COLOR] 80);
    StatusDlg[COLOR="Red"].[/COLOR]Hide();
    [COLOR="Blue"]end[/COLOR][/B]
    anyone got any ideas how to clean up this prosse and the / facter thanks

    :yes
    Last edited by rexzooly; 04-01-2008, 02:57 PM.
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    #2
    you could use a table for your extensions eg:

    Code:
    local getlinkme = Input.GetText("linkme");
    local urlLink = String.SplitPath(getlinkme);
    local isTrue = HTTP.TestConnection(getlinkme, 5, 80);
    local nFileFN = urlLink.Filename
    local nFileEX = urlLink.Extension
    if nFileEX ==  then
    	tbExtension={"com","co.uk","net","de","fr","co.jp","org","org.uk","gov","gov.uk"}
    	for index, strExtension in tbExtension do
    		if strExtension == nFileEX then
    			nFile = nFileFN..".html"
    			break;
    		else
    			nFile = nFileFN..nFileEX
    		end
    	end
    end
    if(isTrue == false) then
    	Dialog.Message("Error 404", "Error seems the url is missing, wrong, locked or your internet connection is disabled", MB_OK, MB_ICONNONE, MB_DEFBUTTON1);
    else
    	StatusDlg.Show(MB_ICONNONE, false);
    	HTTP.Download(getlinkme, _DesktopFolder.."\\"..nFile, MODE_BINARY, 20, 80);
    	StatusDlg.Hide();
    end
    code is untested (but it looks good to me), just a quick edit as a example
    Embrace change in your life, you never know, it could all work out for the best

    Comment

    • rexzooly
      No longer a forum member
      • Jul 2007
      • 1512

      #3
      Originally posted by RizlaUK View Post
      you could use a table for your extensions eg:

      Code:
      local getlinkme = Input.GetText("linkme");
      local urlLink = String.SplitPath(getlinkme);
      local isTrue = HTTP.TestConnection(getlinkme, 5, 80);
      local nFileFN = urlLink.Filename
      local nFileEX = urlLink.Extension
      if nFileEX ==  then
      	tbExtension={"com","co.uk","net","de","fr","co.jp","org","org.uk","gov","gov.uk"}
      	for index, strExtension in tbExtension do
      		if strExtension == nFileEX then
      			nFile = nFileFN..".html"
      			break;
      		else
      			nFile = nFileFN..nFileEX
      		end
      	end
      end
      if(isTrue == false) then
      	Dialog.Message("Error 404", "Error seems the url is missing, wrong, locked or your internet connection is disabled", MB_OK, MB_ICONNONE, MB_DEFBUTTON1);
      else
      	StatusDlg.Show(MB_ICONNONE, false);
      	HTTP.Download(getlinkme, _DesktopFolder.."\\"..nFile, MODE_BINARY, 20, 80);
      	StatusDlg.Hide();
      end
      code is untested (but it looks good to me), just a quick edit as a example
      this on the button or somewhere else and just a little think i found might
      be me but

      Code:

      Code:
      if nFileEX ==  then
      should this be
      Code:
      if nFileEX ==  "" then
      or this the first one right


      //edit//

      and thanks sorry i rust my posts sometimes and forget to say thanks :yes
      Last edited by rexzooly; 04-01-2008, 03:15 PM. Reason: /// manners

      Comment

      • RizlaUK
        Indigo Rose Customer
        • May 2006
        • 5552

        #4
        should be
        Code:
        if nFileEX [COLOR="Red"]~[/COLOR]=  "" then
        like i said, untested, lol
        Embrace change in your life, you never know, it could all work out for the best

        Comment

        • rexzooly
          No longer a forum member
          • Jul 2007
          • 1512

          #5
          Originally posted by RizlaUK View Post
          should be
          Code:
          if nFileEX [COLOR="Red"]~[/COLOR]=  "" then
          like i said, untested, lol
          ok thanks i am testing it now got a error let me see with this change

          // edit //

          thanks that worked how do i make it change the name like name(1).html, name(2).html
          like fire fox dose thanks for the help
          Last edited by rexzooly; 04-01-2008, 03:20 PM. Reason: thanks

          Comment

          Working...
          X