Page 1 of 3

Download utility for devs. Xdialog progress. # New version.

Posted: Wed 27 Nov 2013, 07:41
by sunburnt
This is a script that uses Xdialog`s progress dialog as a stand-alone downloader.
The progress bar is accurate unlike most Linux and Win. progress gui`s.

I could have used GtkDialog to add extras, like download speed and ETA. Feature creep...

# Usage: xdlg.dnldprogress (/path/file) (url)

# Help: xdlg.dnldprogress -h .......... ( Just shows above Usage.)

If the titlebar [x] is clicked the download stops and the file is deleted.

URLs at many sites are horribly mangled ( intentionally I`m sure...).
So this could be a problem.
Only Ubuntu and Debian have I seen to be "normal".

It`s simple to use and very useful too.
Seems to work well, post any problems or suggestions.


# New version. Cleaned it up a bit, and now it continues a broken download.

Note: If the site is rotten and just won`t do it, then xdlg.dnldprogress will try forever.
.......... So at some point the user will want to just click the [x] and end the download.

### Brokeman suggested to add a option so it will download from SourceForge.

# New version adds option: --trust-server-names
.

Posted: Wed 27 Nov 2013, 10:29
by amigo
Pretty scripting there feller! Funny paths in that archive though...

Posted: Wed 27 Nov 2013, 12:02
by Keef
I think he's done that before....

Posted: Wed 27 Nov 2013, 14:00
by sfs

Code: Select all

f="$@"
f=ftp://ftp.yandex.ru/ubuntu/ls-lR.gz
wget  --connect-timeout=3 -t 2 "$f" 2>&1 |tee /dev/stderr |sed -u "s/^ *[0-9]*K[ .]*\([0-9]*%\).*/\1/" | \
yad --image=save48-alt --no-buttons --progress-text="Load $f" \
    --progress --auto-close --auto-kill  --undecorated --center 2> /dev/null

Posted: Wed 27 Nov 2013, 15:13
by amigo
There's a distinct advantage to using Xdialog here as it is available for both gtk1 and gtk2 and, even more so, the same syntax works for cdialog(ncurses). One script -three toolkits.

The polling every two seconds may make long downloads excruciating, though.

Posted: Wed 27 Nov 2013, 19:27
by Keef
Is (/path/file) for naming/renaming the file to download? That's what it does anyway. Seems an unnecessary complication.
Just putting in a URL (on its own) fails, and I wouldn't want to have to type the name of a file I don't want to rename - I can do that afterwards.

Posted: Wed 27 Nov 2013, 21:23
by sunburnt
Keef; Yes I wanted to have the file parsed from the url, but so many urls are "abnormal".

koulaxizis`s web site url`s end with: /download, so using "wget -P" the name of the file is "download".
And Yandex totally mutilates it`s urls, they`re a mile long. Only Ubuntu and Debian are okay.
So I figured using the wget -O is the best idea.
BUT... If you have an idea about how to control the /path/file with an option speak up.!
I could allow the user to do: -o = /path/file & -p = /path

amigo; Thanks... And yes, the archive was made from rxvt with a pasted path. Gotta watch that...
Need to find one of these Rox desktop icon archivers like the one MU made years ago.
# Any suggestions on how to improve the gui`s apparent activity for large downloads?

sfs; Like amigo said, I thought about Yad as it`s more capable, but it`s not all that common.
As I said, I could have used GtkDialog and "feature creeped" it and added speed and eta.
I`ll add the "-t" to my wget command, I figured it could probably use a little tuning. Thanks...
.

Posted: Wed 27 Nov 2013, 21:33
by Keef
sunburnt

Yes I see what you are doing now. I've pasted urls like that into wget and had to chop out the crap manually.

I'll have to remain silent on a solution unfortunately.

Posted: Wed 27 Nov 2013, 21:57
by sunburnt
Yeah... The user would have to analyze the url manually to see if it`s "normal" and usable.
The user still has to know the Path he wants, and the FullFileName.
Again, I figure it`s just best for the user to enter the /path/file verbatim so there`s no mistakes.

A wrapper GUI to call it could have buttons and text boxes for URL and /Path/File info.
It`s a add-on gui like a file/dir. selector to make writing bigger apps easier to do.
.

Posted: Wed 27 Nov 2013, 23:37
by smokey01
This is quite a nice little script that uses wget with a gtkdialog progress bar.

Code: Select all

#!/bin/bash 
url="$1"
export MAIN_DIALOG=' 
<vbox> 
<progressbar> 
<label>Some Text</label> 
<input>wget "'$url'" 2>&1 | sed -nru "s/.* ([0-9]+%) +([^ ]+).*$/\1\n« \1 downloaded \2 »/p"</input> 
<action type="exit">Ready</action> 
</progressbar> 
</vbox> 
' 
gtkdialog --program=MAIN_DIALOG
I call it dl.

Usage is: dl url

The downloaded file will be placed in the same directory that you executed the script.

Posted: Thu 28 Nov 2013, 02:34
by sunburnt
smokey; What about mangled urls? Like this one for Firefox, the file ends up being named "download":

http://sourceforge.net/projects/puppyst ... s/download

And other urls I`ve seen are really messed up ( on purpose I`m sure...).
Also as amigo said, Xdialog code is extremely portable, where as GtkDialog is only used here at Puppy.

But your GtkDialog one could be "feature banged" by adding Speed and ETA. Xdialog one can`t do that.
Also it could be setup to show multiple simultaneous downloads and a big progress bar for total completed.
.

Posted: Thu 28 Nov 2013, 02:59
by smokey01
The script was named dl. The following code downloaded the file but it had to be renamed to whatever.sfs.

Code: Select all

dl http://sourceforge.net/projects/puppystuff/files/Internet/Firefox/firefox-23.0.1-en_5.6.0.sfs/download 
If you back off the /download like:

Code: Select all

dl http://sourceforge.net/projects/puppystuff/files/Internet/Firefox/firefox-23.0.1-en_5.6.0.sfs
It worked fine.

Maybe the script is transportable to Xdialog. I haven't tried.

Cheers.

Posted: Thu 28 Nov 2013, 08:41
by sunburnt
smokey; It looks like the wget line could be piped to Xdialog, I couldn`t get it to work.
Like I`m trying to get 9menu to work, as I tried getting Yad to work. Bash quoting`s a nightmare.

If you wanna see something truly horrible, look at the link code for Chromium-31 here:
https://disk.yandex.com/public/?hash=5% ... &locale=en

My dialog is add-on support for other apps. So I chose to have the /path/file an argument.
.

Posted: Thu 28 Nov 2013, 09:35
by amigo
Here, I've found some stuff that I did before:
http://distro.ibiblio.org/amigolinux/do ... Resources/

I'm still looking locally for some other examples I used to add...

I mostly use the while_box which just shows a static notification window. The gauge or progressbar are always more costly than doing anything else, but wget helps you a lot there. I also used infoboxes which can be piped to or to simply create a moving 'busy' notification like a small animation -by simply printing characters like:
. (.) (..) ((..)) . (.) (..) ((..)) to create 'movement'.

Anyway, you might find something useful in there -it was mostly done relevant to my SqueezeMe AppDir which later became ZipZap. The gauges were estimating the time to create archives -probably more expensive than what you are doing with wget which provides usable progress output. There's also a proc_dot function in there that creates a spinning cursor.

Posted: Thu 28 Nov 2013, 11:17
by mikeb
I won't mention my gtkdialog wget thing :D.

amigo...any tips to make Xdialog log/tail box work better....want a smooth one second update. It was suggested after I had a problem testing yad with cdrecord but was not useable so I went back to gtklogfileviewer.

mike

Posted: Thu 28 Nov 2013, 13:13
by amigo
What do you mean by smooth? I mean, is the box flickering on and off, or what?

Posted: Thu 28 Nov 2013, 13:15
by mikeb
log messages scroll up but in 5-10 second chunks lagging behind the action significantly...makes it unreadable in effect.

mike

Posted: Thu 28 Nov 2013, 16:38
by sunburnt
mikeb; I`m sure a better download/gui utility can be made. I`d like to see your "version".
Your logbox problem is sooo typical, I get disgusted before I finish and give up...

amigo; Grabbed a bunch of stuff of yours to look at. Always looking for a better way.

# Thoughts: Devs need add-on gui and back-end utilities like a downloader or file/dir. selector.
The dev. process can be rapid, or prolonged agony. Linux is sooo scattered. Solutions?

Trying to get Yad or 9menu to work is a struggle, Bash quoting being what it is.
They work okay with literal arguments or individual vars., but args. grouped into vars. bomb.
9menu should be easy to use, but it won`t do commands with lots of args. Have to call script.
.

Posted: Thu 28 Nov 2013, 23:10
by mikeb
Actually you don't...has a url box, a save name/path box , a window of active downloads with option to kill and it spawned gtklogfileviewer log boxes. It was originally written to also include cclive so any you tube and similar urls would download the vid and offer to play as it did. cclive became ridiculous so I removed that side and I never really used wget by itself. It and curl get called in scripts otherwise I use the browser. My bash/gtkdialog dropbox file manager might be more of interest.

merge gxmessage, yad, gtkdialog, xmessage, Xdialog gtklogfileviewer and the rest into one binary called pad .... make it multicall if yer like... so it covers whatever interface gets the golden dime bar this week :D

mike

Posted: Fri 29 Nov 2013, 04:26
by sunburnt
I see it a bit like putting bandaids on bandaids. The Linux boat needs a new hull, not patches.

I`m not sure of problems with X and xorg, but GTK / QT are ripe for replacement.
After over 20 years the old style of "Windows" is really worn out and looks like crap.
A new solid base with a new solid well designed gui kit. A simplified sane api and syntax.
.