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&