aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: [1] 2

Author Topic: Don't download already downloaded files  (Read 9289 times)

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Don't download already downloaded files
« on: November 04, 2008, 06:17:26 PM »

I use a lot firefox to send new downloads to amule. When I click on a ed2k link in firefox, it is added into the downloads in amule.

If the file is already into the downloading or shared files, I get a message like what I already have the file or that the file is already in download. And the file is not added again. That's fine.

But, if I already downloaded the file and moved it out of the shared files, amule will start to download again the file. That's bad for me because I just cannot remember of every single file I downloaded with amule. But I think that amule can do that for me.

I think that the best way to implement that would be by a preference setting. So, an user that don't want to use this feature can disable it. Or an user that use this feature but want to download again an already downloaded file can temporarily disable it.

Such a feature would be really helpful for me, and I think for other users sharing collection of files via some ed2k forums.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Don't download already downloaded files
« Reply #1 on: November 04, 2008, 07:20:12 PM »

Makes perfect sense to me.
Do I understand this right - known.met stores all files ever downloaded, but CDownloadQueue::IsFileExisting checks only downloading/shared files ? There should also be a check against known files, and a hint "You already downloaded this file once." Also, the long outstanding request to memorize canceled files and give a hint when downloading them again should be fulfilled.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: Don't download already downloaded files
« Reply #2 on: November 04, 2008, 07:49:28 PM »

Makes perfect sense to me.
Do I understand this right - known.met stores all files ever downloaded, but CDownloadQueue::IsFileExisting checks only downloading/shared files ?
Yes, I don't know the function name, but it is how amule is working when I click on an ed2k link.
Quote
There should also be a check against known files, and a hint "You already downloaded this file once." Also, the long outstanding request to memorize canceled files and give a hint when downloading them again should be fulfilled.
I guess so. But to be fully accepted by the users, it must be a preference option to disable/enable the download. Or a popup asking what I want to do in such a case, But I think that a pref option is better, and maybe also easier to implement.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Don't download already downloaded files
« Reply #3 on: November 04, 2008, 08:21:16 PM »

I'd make a popup, and no config option. Why would anybody not want to be informed that he downloaded a certain file before ?
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Don't download already downloaded files
« Reply #4 on: November 04, 2008, 08:27:16 PM »

Because he doesn't want to be. Make it a popup with a checkbox for "don't tell me again", and a preferences option initially stating to inform, so it can be reenabled.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Don't download already downloaded files
« Reply #5 on: November 04, 2008, 08:37:00 PM »

Ah, the wish-my-wife-had-this-checkbox.  ;D
Ok.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: Don't download already downloaded files
« Reply #6 on: November 04, 2008, 09:05:13 PM »

I am not sure if you are understanding me right.

It is enough for me if amule tell me into the network tab that I already downloaded this file. It is how it work now for the in-download and shared files.

What I want to be able to do is to choose if I want to re-donwload the file or not. That only in the case where I downloaded the file but it is not into the shared files anymore.

Most of the time, the info into the serveur tab will be enough, but in a few cases, I may want to download the file again. So, I don't think that a popup is needed.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Don't download already downloaded files
« Reply #7 on: November 04, 2008, 09:27:30 PM »

What I want to be able to do is to choose if I want to re-donwload the file or not.
And you can't choose without a popup, right ? Otherwise aMule could just print a log message (which would probably go unnoticed), and you had to manually cancel the download afterwards.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: Don't download already downloaded files
« Reply #8 on: November 04, 2008, 09:54:15 PM »

What I want to be able to do is to choose if I want to re-donwload the file or not.
And you can't choose without a popup, right ? Otherwise aMule could just print a log message (which would probably go unnoticed), and you had to manually cancel the download afterwards.
It is how it work now. I get a message in the net tab (and status area) like what a new download is started.

It can be fine with a popup, but most of the time, I don't want to re-download the file, so it will just popup for nothing. With a pref option, it would be possible to choose if we want to re-donload or not such files, and to temporarily change that option when we are sure that we really want to re-donload a file.

As example, if I am on a forum thread with a lot of ed2k links, I can send all of them  with one click using firemule in firefox, and only the few that I dont already have downloaded will be added into amule's download. And I will be able to read the log into the net tab.

But if I a file is missing for some reason, and I want to download it, and that the log tell me that I already downloaded this file in the past, I want to be able to enable this download into the pref (or with a right-click menu into the message log, maybe even better).

In fact, it doesn't matter much if it is a popup, a pref option or a right-click menu that let me to enable the download. But I think that a popup will be some kind of overkill because most of the time, I don't want to re-download a file.
« Last Edit: November 04, 2008, 09:55:58 PM by libre »
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Don't download already downloaded files
« Reply #9 on: November 04, 2008, 10:09:53 PM »

So we need a setting:
Download files downloaded before: Yes[ ] No [ ] Ask me [ ]

And the dialog should ask:
Name was downloaded before. Download again ?
Yes  No  Always  Never


Think we're getting closer.  ;)
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: Don't download already downloaded files
« Reply #10 on: November 05, 2008, 09:23:43 PM »

Yes, that's it.  ;D

Left is to choose if Always  and Never  into the dialog will be permanent or just for the current session.

I don't care, but for the current session seam to be more logical for me.
Logged

LittleAbacus

  • Jr. Member
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 54
Re: Don't download already downloaded files
« Reply #11 on: November 06, 2008, 05:13:44 AM »

I think it's less a question if the dialog's scope is per-session or permanent, but to make it clear to the users who haven't read this thread that always/never means "always/never download" fileS that had previously been downloaded and NOT always/never do it for THIS file...
Anyway, I like the idea.
Logged

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: Don't download already downloaded files
« Reply #12 on: December 29, 2008, 08:00:10 PM »

Well, I done a bash script that make it and will even do more when finished.

I want to be able to choose the final location of the downloaded file, move it to the choosen location and make a symlink into the share directory if needed. But for know, it just check if the file is in downlaod /incoming or already moved, and let you choose if you want to download in the case it already has been moved.

I called this script ed2kmanage.

Code: [Select]
#!/bin/bash
# ed2kmanage
# Usage :
# ed2kmanage <ed2k_link>
#
# The best way is to call it from firefox. Load "about:config", search for 2ed2k"
# and replace the "ed2k" string by "ed2kmanage".
#
# This script will send <ed2k_link> to ed2k, extract the filename from <ed2k_link>
# and add it to ~/.aMule/man_globalfilelist and ~/.aMule/man_movefilelist
#
# man_globalfilelist is the list of file that was put in queue, it grow when new files are added.
# man_movefilelist is the list of file waiting to be moved, it grow when new files are added
#  and shrink when downloaded files are moved.
#
# This script need perl and xdialog.
#

# Don't change it !
INCOMING_ROOT=$(id -un) # user's root
############################################################
# You can change the following settings to suit your needs #
############################################################
EXEC="ed2k" # The ed2k executable, used to add files in ed2k download queue
GLOBAL=/home/"$INCOMING_ROOT"/.aMule/man_globalfilelist # globalfilelist location
MOVE=/home/"$INCOMING_ROOT"/.aMule/man_movefilelist # movefilelist location
MOVE_ROOT=/home/"$INCOMING_ROOT"

#########################################
# Don't change anything paste this line #
#########################################
# Some functions #
##################
# choose directory for later move
move_dir()
{
DIR=`Xdialog --stdout --title "Please choose a directory for later move" --dselect "$MOVE_ROOT" 0 0`

case $? in
0)
;;
1)
move_dir;;
255)
move_dir;;
esac
}

# send <ed2k_link> to ed2k
send_ed2k()
{
ed2k "$1"
}

# write the file in the global list
write_global()
{
echo "\"$DIR$FILENAME\" $HASH" >> "$GLOBAL"
}

# write the file in the move list
write_move()
{
echo "\"$FILENAME\" \"$DIR\"" >> "$MOVE"
}

######################################
# Do something now, the main program #
######################################
# test if <ed2k_link> exist
if [ -z "$1" ]
then
  echo "Usage: `basename $0` <ed2k_link>"
  exit 65 #Why not?
fi

# extract the filename (work fine when called from firefox, give strange result sometime when called in the console)
FILENAME=$(echo "$1" | sed -e 's\ed2k://|file|\\' -e 's\|.*\\' | perl -pe 's|%([0-9a-f]{2})|pack('C',hex($1))|segi;')

# extract the MD4-HASH
HASH=$(echo "$1" | cut -d "|" -f5)

# check if the file already exist
if grep -q -F "$HASH" "$GLOBAL"
then # file exist in global
if grep -q -F "$HASH" "$MOVE"
then # file is in download or in incoming
Xdialog --infobox "$FILENAME is already in download or in incoming." 0 0 0 #<height> <width> [<timeout>]
else # the file is moved
Xdialog --wrap --no-close --title "Download Again" --help "You already have this file in place, do you want to download it again?"\
        --yesno "The file $FILENAME has already been moved, do you want to download it again?" 0 0

case $? in
  0)
    send_ed2k "$1"
    move_dir
    write_move;;
  1)
    exit;;
esac
fi
else # file don't exist
send_ed2k "$1"
move_dir
write_global
write_move
fi

It is not my first bash script, but I am not a bashist specialist, so any comment will be appreciated.

EDIT: I done a little change, it is better to check the files only with the hash instead of alternatively with its name and its hash.
« Last Edit: December 29, 2008, 11:02:39 PM by libre »
Logged

libre

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: Don't download already downloaded files
« Reply #13 on: December 31, 2008, 12:45:51 AM »

My script is done. It is in 2 parts in the same file. I call it ed2kmanage.

ed2kmanage "<ed2k link>" manage the ed2k links.
ed2kmanage -m manage the the files that ed2k will download.

It need sed, cut, xdialog and perl. To install it, just put it in your path and go to about:config into firefox. Search for ed2k and change the string from "ed2k" to "ed2kmanage".

When clicking on an ed2klink, the script will get the link, ask for a directory to move the file after the donload and if you want to make a symlink in amule share directory. The link will be send to ed2k for download.

If the file is already in download or in incoming, nothinj will be done. If the file has already been downloaded, but have been already moved or erased, the script will ask if you want to download it again. If yes, the same actions that with a new file will be done.

Be aware that, in order to know the state of a file, the script manage 3 files and doesn't know nothing of what ed2k is doing. So, it will not work with old files or with files found in the search tab of amule. For those files, you have to open a console, copy the link from amule and run "ed2kmanage <ed2k link>" by hand.

I guess that those 3 files can be useful if you want to manage your files with a database.

When you want to move the downloaded files, just open a console and run:
Code: [Select]
ed2kmanage -mThe downloaded files will be moved to their wanted locations and the symlinks will be created. You will get an output into the console for each moved file and its location.

That's all!

The script is join with this message.

It work for me. I tested it with all kinds of characters, europeans, chineses, double consecutive spaces,...
I get no problem with firefox.

But sometime in the consiƓle, I get a wrong result when running it from the console. The same ed2k link was just working from firefox. I think that this is a problem specific to my system, but I am not 100% sure of this. It is a comment about this in the script (download() function). If someone can look at it and tell me what to do, it will be very kind.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Don't download already downloaded files
« Reply #14 on: December 31, 2008, 01:20:30 PM »

If you use perl you could do the whole thing in it and not bother with sed, cut, bash, whatever.  ;)
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon
Pages: [1] 2