possible to sort files automatically after downloading?

General support for problems installing or using Deluge
Post Reply
newdeluge
New User
New User
Posts: 2
Joined: Mon Jun 19, 2017 4:56 pm

possible to sort files automatically after downloading?

Post by newdeluge »

Is it possible to have all of my downloads set to one folder and I can sort it to different folders after it finishes downloading?

For example, folder1, folder2, etc?
mhertz
Moderator
Moderator
Posts: 2195
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: possible to sort files automatically after downloading?

Post by mhertz »

Yes, with label plugin manually, or automatically with either labelplus plugin(not working with magnets), or just simply using a custom shell script(which most clients support) run from the execute plugin. I have made such a script for when I use qbittorrent-nox, as a labelplus(match-file) replacement(though for my simple use, I only had it set to move video files into my video folder and get subs from opensubtitles if available and remove non-video crap like samples/nfo's and also the parent-folder.)
newdeluge
New User
New User
Posts: 2
Joined: Mon Jun 19, 2017 4:56 pm

Re: possible to sort files automatically after downloading?

Post by newdeluge »

Does label plugin work with magnet torrents?
mhertz
Moderator
Moderator
Posts: 2195
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: possible to sort files automatically after downloading?

Post by mhertz »

Yes, but the label plugin works by you manually selecting the label you want by right-clicking each torrent and then you can have separate label-folders I believe(in regular label plugin). In the thread for labelplus, I have also posted a workaround for making labelplus work with magnets, by using a magnet2torrent converter utility. If you don't need automatic labeling and is OK by right-clicking each torrent manually, then labelplus works fine for magnets also.
hrip6
Member
Member
Posts: 10
Joined: Fri Jun 16, 2017 1:39 pm

Re: possible to sort files automatically after downloading?

Post by hrip6 »

mhertz wrote:Yes, but the label plugin works by you manually selecting the label you want by right-clicking each torrent and then you can have separate label-folders I believe(in regular label plugin). In the thread for labelplus, I have also posted a workaround for making labelplus work with magnets, by using a magnet2torrent converter utility. If you don't need automatic labeling and is OK by right-clicking each torrent manually, then labelplus works fine for magnets also.
I really interested with your script, could you please share it? Thanks a lot.
newdeluge wrote:Does label plugin work with magnet torrents?
The LabelPlus works on current torrents no matter it is magnet or not. And for new magnet torrent, you have to right click and assign a label for it. If the magnet has the info of file in the header, then LabelPlus will automatically add label for it (rarely happens).
Image Patreon: http://patreon.com/deluge_cas
Image Contact me: http://forum.deluge-torrent.org/ucp.php?i=pm&mode=compose&u=129152
mhertz
Moderator
Moderator
Posts: 2195
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: possible to sort files automatically after downloading?

Post by mhertz »

Of course I can share my scripts, but sorry what is it you're after specifically? From your quote you sound interested in the magnet2torrent converter script which isn't made by me, and I made instructions in the labelplus thread's last post on how to use. Or was the quote just the wrong one, and you want the post-processing script I mentioned earlier in this thread I used with qbittorrent-nox for labelplus match-file-alike functionality?
hrip6
Member
Member
Posts: 10
Joined: Fri Jun 16, 2017 1:39 pm

Re: possible to sort files automatically after downloading?

Post by hrip6 »

mhertz wrote:... Or was the quote just the wrong one, and you want the post-processing script I mentioned earlier in this thread I used with qbittorrent-nox for labelplus match-file-alike functionality?
Oops did I? Yes, I did quote the wrong ones, how fool I am :o . I meant this quote:
mhertz wrote:... I have made such a script for when I use qbittorrent-nox, as a labelplus(match-file) replacement(though for my simple use, I only had it set to move video files into my video folder and get subs from opensubtitles if available and remove non-video crap like samples/nfo's and also the parent-folder.)
I really interested with the get subs and remove unnecessary files apart from the video :twisted:
Image Patreon: http://patreon.com/deluge_cas
Image Contact me: http://forum.deluge-torrent.org/ucp.php?i=pm&mode=compose&u=129152
mhertz
Moderator
Moderator
Posts: 2195
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: possible to sort files automatically after downloading?

Post by mhertz »

As i've changed over to deluge, and like my script more than using labelplus(with magnet2torrent workround), because of the added cleanup and subchecks, then I've migrated the script over to use deluge's parameters, as they differ from qbittorrent-nox's.

The script removes crap by deleting possible "*SAMPLE*" files and copying rest video files over to my video folder and getting subs there if available and deleting the parent folder if available.

I don't have a very big video folder, since I don't keep things i've already seen and so prefer not having e.g. different episodes in both folders and single files, which fucks up sorting in video players and easy overview. It is very easy to change the script to not remove the possible parent folder and issue some extra rm commands to nfo's, txt's etc, to further cleanup.

Lastly, the subchecker I use is a single small python file with no extra needed deps to install, and to be placed somewhere under PATH + 'chmod +x' it, and is checking opensubtitles for matches from a checksum so 100% exact(but optionally falls back to filename matching if no matches, which is enabled by default). I also change a setting in the file itself from auto to off, so downloaded subs always are named after the video and not gets a language suffix. I use '-l eng -l swe -l dan' instead of the more usual -l dan,swe,eng', because the later sometimes doesn't respect the language order(if only one language has a hash provided it's always taken no matter if last in order), and I instead want my native language(s) preferably, with english only as fallback, no matter if there isn't a hash provided for my native language(s), and the previous mentioned setting disabled, makes each sub language downloaded to just overwrite the previous sub, hence the opposite order there. You can also set username/password for opensubtitles as options in the file itself if wanted, but that's optional and I don't bother(you're then restricted to max 200 subs a day and a very short 2 sec add, in the beginning possibly, which the free registering at opensubtitles removes). Here's the link(you only need the py file): https://github.com/emericg/OpenSubtitlesDownload

You could also use periscope, which is another python subchecker supporting more providers than opensubtitles and just have 1 extra python dependency, though opensubtitles is so big(biggest I believe) and so I thought if it wasen't there then it probably wasen't available anyway. Also, periscope didn't work for me in that it didn't download subs in my selected language for some reason in my brief tests with it. There's others too, like subliminal etc.

postproc: (It's not very elegant, and could be written much better :) )

Code: Select all

#!/bin/bash
shopt -s extglob globstar
if [ -d "$3/$2" ]; then
	if [[ $(ls "$3/$2"/**/*(*.mkv|*.mp4|*.avi|*.MKV|*.MP4|*.AVI)) ]]; then
		rm "$3/$2"/**/*sample*
		rm "$3/$2"/**/*SAMPLE*
		rm "$3/$2"/**/*Sample*
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "$3/$2"/**/*
		mv "$3/$2"/**/*(*.mkv|*.mp4|*.avi|*.MKV|*.MP4|*.AVI) video
		mv "$3/$2"/**/*(*.srt|*.SRT) video
		rm -rf "$3/$2"
	fi
else
	if [ ${2: -4} == ".mkv" ]; then
		mv "$3/$2" video
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "video/$2"
	elif [ ${2: -4} == ".mp4" ]; then
		mv "$3/$2" video
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "video/$2"
	elif [ ${2: -4} == ".avi" ]; then
		mv "$3/$2" video
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "video/$2"
	elif [ ${2: -4} == ".MKV" ]; then
		mv "$3/$2" video
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "video/$2"
	elif [ ${2: -4} == ".MP4" ]; then
		mv "$3/$2" video
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "video/$2"
	elif [ ${2: -4} == ".AVI" ]; then
		mv "$3/$2" video
		OpenSubtitlesDownload.py -a -l eng -l swe -l dan "video/$2"
	fi
fi
Edit: I have also defined my core.conf to let deluge remove downloads when they finish downloading, hence I can mv the files instead of cp'ing them. I'm using public trackers and upload during download, though am leery about seeding afterwards on public trackers, despite using "protection", but if libtorrent gets a bug regarding it's force_proxy setting, or if the provider was sued and logs restored somehow - I know the latter is pretty much an impossible scenario to unravel, but nonetheless, that's my reasoning...

Btw, I use this script as handler for magnets and torrents, so when clicking a magnet or torrent in my browser, then this deluge-run script is run in the background: (and I check progress if needed with 'deluge-console info' from a terminal, though a sound is played anyway when all downloads are finished) I made it because deluge don't support stopping the daemon after downloads finish(not from plugins either), which I liked from qbittorrent-nox:

Code: Select all

#!/bin/bash
pgrep deluged || deluged
sleep 2
deluge-console add $1
pgrep deluge-down && exit
echo "#!/bin/bash" > /tmp/deluge-down
echo 'DL=$(deluge-console info | grep Downloading)' >> /tmp/deluge-down
echo 'while [ "$DL" != "" ]; do' >> /tmp/deluge-down
echo 'DL=$(deluge-console info | grep Downloading)' >> /tmp/deluge-down
echo "sleep 30" >> /tmp/deluge-down
echo "done" >> /tmp/deluge-down
echo "pkill -9 deluged" >> /tmp/deluge-down
echo "rm ~/Downloads/*.torrent" >> /tmp/deluge-down
echo "mpv /usr/share/sounds/alsa/Noise.wav" >> /tmp/deluge-down
echo "rm /tmp/deluge-down" >> /tmp/deluge-down
chmod +x /tmp/deluge-down
/tmp/deluge-down&
Post Reply