How to add destination folder to magnet?

General support for problems installing or using Deluge
Post Reply
brianx
New User
New User
Posts: 5
Joined: Sun Apr 04, 2021 10:31 am

How to add destination folder to magnet?

Post by brianx »

I have a list of magnets, which I wish to add to Deluge programmatically.

If I add the magnet manually to Deluge, there is an Options tab in which I can select the Download Folder for the given magnet.

I am looking for a way/code/plugin to automatically select a specific folder for each magnet.

magnet1 => folder1
magnet2 => folder2

I have Deluge 2.0.3 on Ubuntu 20.04
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to add destination folder to magnet?

Post by mhertz »

Code: Select all

martin@arch ~ % deluge-console add --help
usage: add [-h] [-p PATH] [-m MOVE_COMPLETED_PATH] <torrent> [<torrent> ...]

Add torrents

positional arguments:
  <torrent>             One or more torrent files, URLs or magnet URIs

optional arguments:
  -h, --help            show this help message and exit
  -p PATH, --path PATH  Download folder for torrent
  -m MOVE_COMPLETED_PATH, --move-path MOVE_COMPLETED_PATH
                        Move the completed torrent to this folder
You can use above to script it, e.g. loop through text file and add, with whatever wanted logic for destination folder assignments. Some magnets feature the optional '?dn=' field specifying name of content, used for clients to display without needing resolve metadata first, and which for multi-file torrents is a folder name, or gets generated as such by deluge/libtorrent, and if single-file torrent then will include file-extension, if any, so needs extra parsing filtering logic if wanna utilize that.

if want specific help for this, then detail exactly what you're after regarding the destination folders, as i'm guessing your example of ''folder1' and 'folder2' etc wasen't a literal example :)
brianx
New User
New User
Posts: 5
Joined: Sun Apr 04, 2021 10:31 am

Re: How to add destination folder to magnet?

Post by brianx »

WOW this works perfectly. I didn't hope to find such a straightforward solution.

Since I am new to deluge-console, I do not understand its relationship with the main Deluge (GUI).

When I add a torrent via deluge-console add, they do not appear in the list of torrents in the main Deluge (GUI). However, when I open deluge-console in the terminal, both the torrents added in Deluge (GUI) and those added by deluge-console add appear.

Can I make the torrents added via deluge-console add command appear in the main Deluge window (as I do not need to open deluge-console in the terminal to check their progress?

Or can I make Deluge GUI separate from deluge-console (to have completely different lists)?
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to add destination folder to magnet?

Post by mhertz »

If you run deluge-console/deluged from own user, then deluge is using ~/.config/deluge profile and if you start deluge gtk GUI from own user also, either in classic/default mode, or connect to deluged daemon manually started, in thinclient mode, then all torrents should end same place and can be monitored from any GUI or consoleUI.

If you have deluged started from a service file e.g from systemd, then usually setup to start deluged under 'deluge', or 'debian-deluged' user, and so then deluge stores its profile/running-torrents into often '/var/lib/deluge/.config/deluge' or ''/var/lib/deluged/.config/deluge', so it seems some is running under there and others under own user, from the sound of it. Little confusing for newcomers honestly, and I'm probably not explaining it very good either, which further adds to the confusion.

If you e.g copy the auth file from e.g /var/lib/deluge/.config/deluge, into and owerwrite old in ~/.config/deluge, then you can I believe kinda chain them together so only the /var/xxxx folder is used for running torrents, and deluge-console will connect to that daemon running under that special user by default. I'm not at my PC now, and cannot remember, but think hostlist.conf also needs copied/overwrite over, for deluge-console to work in interactive mode I.e in the curses TUI and not just CLI mode, in contrary to deluge1 I believe. You could also without copying any configs, run deluge-console like either 'sudo -u deluge deluge-console', or 'deluge-console -c /var/lib/deluge/.config/deluge', and exchange with debian-deluged and other /var/* path if using that instead. PPA package uses deluge user I believe and repo package uses debian-deluged.

If not running deluged under other user, then all this doesn't even apply to you, sorry, and I don't know why not shown together honestly, but just sounds like that is the issue from your description.
brianx
New User
New User
Posts: 5
Joined: Sun Apr 04, 2021 10:31 am

Re: How to add destination folder to magnet?

Post by brianx »

Your explanations were crystal clear. Not only I learned a lot, but also I managed to resolve the problem. I describe my experience, as it may help someone else.

I installed deluge-console and deluged from the official repository of Ubuntu 20.04.

The key is that to run deluge-console, deluged daemon should be running. If running deluged with the current user config as

Code: Select all

deluged -c /home/$HOME/.config/deluge
deluged and Deluge GTK GUI will be synchronised (using the same config). However, the key point is that you cannot run Deluge GTK GUI when deluged daemon is running. Therefore, you need to run Deluge GTK GUI under Thin Mode in which it is connected to the deluged daemon instead.

As a side note, if deluge-console could use the original deluge daemon (the one originally used by Deluge GTK GUI; my terminology might be incorrect here), we could omit deluged daemon. As I believe it is not possible, all instances of deluge (GTK or deluge-console) should rely on deluged daemon.

A good reference is https://dev.deluge-torrent.org/wiki/Use ... ThinClient
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to add destination folder to magnet?

Post by mhertz »

Thanks, and good job mate! :)

Indeed, you cannot connect from deluge-console to classic(default/non-thinclient-mode) deluge, and need start deluged, which cannot run simultaniously with classic GTK-UI's "internally started deluged copy" used by the GTK client behind it's scenes, well unless adding -c with other profile dir than used already by GTK-UI's internal deluged-copy(non-thinclient mode) and other daemon listen port I presume since all under localhost. However, you could make this seamless by using thinclient-mode in GTK-UI, and in connection-manager there, selecting auto-connect to daemon, or alike called. You could also select the two underneath options if wanted, so if not already running, then auto-starting deluged for you and connecting, which shows the connection-manager for a few secs while loading, so the last option underneath hides that, but not really important but might as well.

However, if using systemd or whatever service-management to start deluged(so not running 'deluged' manually in terminal yourself everytime using it), then as I see from your command-line posted, that you're after using same profile as own user, then would need change so that is run always when started(append -c xxxx), or e.g. alternatively change the defined user deluged setup to start under, debian-deluged in repo package, to instead own user in that service-management-system(service file or user.conf) if wanting that, which isn't as secure though, but easier to work with generally, which in that case doesn't need use the -c option as always will use default profile dir for said user deluged is running under(e.g. check in htop/ps or whatever to verify), so by default the config dir would be ~/.config/deluge if deluged is running under your user, so don't need specify in that case, only needed if run e.g. from a service like mentioned before, since not runs as own user normally.

This further is confused by the fact that ubuntu adds some stupid extra layer for the package between old sysv init and newer systemd, which is why if wanna use a service to start/stop deluge, e.g. at boot, then I posted instructions previously to get that layer away and continue with straight systemd service files added yourself from official documentation, as e.g. changing away to other user or make other mods was hard to do in default setup when that layer interferred, atleast for me when previously testing it for other users here. This is the instructions, though use debian-deluged, so if wanna use default user, then change user and group in the files after wget'ing them, to own user and primary group, well the group lines can be removed from both as users primary group used by default, but doesn't hurt either adding, or, if wanna add that -c you did to change the profile dir, though not needed as said if changing the user as already used then. viewtopic.php?f=7&t=55906&start=10#p233180 (stop all deluge UIs and daemons before following instructions, if ever wanting try that, though you probably don't need and just posted just in case - if not using services or if not having issues with them, then no need)

Good link you posted before about thinclient, which I obviously should have posted initially to you :)
brianx
New User
New User
Posts: 5
Joined: Sun Apr 04, 2021 10:31 am

Re: How to add destination folder to magnet?

Post by brianx »

This is a conclusion of the practical tips given by mhertz for using Deluge GTK GUI and deluge-console.

By changing the Application Mode to Thin Mode, Connection Manager can be used to automatically run deluged daemon. I believe when Deluge GTK GUI loads the deluged daemon, it runs with

deluged -c /home/$HOME/.config/deluge

If running deluged from the terminal -c argument is necessary.

WARNING: If you run deluged from the terminal with -c argument, Deluge GTK GUI will be disconnected, and you have to connect to deluged daemon via Thin Mode. However, if you rung deluge without -c argument, Deluge GTK GUI works along with the deluged daemon. In this case, deluged daemon (via deluge-console) writes to the torrent files added via Deluge GTK GUI. Since two instances of deluge simultaneously download the torrent, the files will be corrupted.
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to add destination folder to magnet?

Post by mhertz »

Just wanted to add that it depends how run from terminal, e.g 'deluged' don't need -c if logged in under own user, but 'sudo systemctl start deluged' does, as other user defined in deluged.service or user.conf override file supplied. (If I run 'deluged' now, from my terminal from own user, then automatically is used: /home/martin/.config/deluge, though -c doesn't hurt there additionally, just redundant)

Would be nice if consoleui had such autostart local daemon also(if not running already), like GTKUI, which I believe was planned but never implemented yet, though a shell-function/alias could be made to start it, if not running, or change the code manually for this. In my scripts/functions for deluge-console, there's always checks for deluged, and starting it if not running + closing when sharing-ratio is meet, which usually is 0 to be honest(public torrents, very rarely torrent, plus you do upload while downloading, though of-course I recognize not good etiquette, and so am little selfish in some areas honestly.)
Post Reply