deluge-postprocess.sh processed entire folder

Support for Ubuntu and other Desktop Linux distributions
Post Reply
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

deluge-postprocess.sh processed entire folder

Post by 0b1001 »

Hey rednoah, great piece of work and I hope you've benefited from it as much as we have.

I've got a minor annoyance that I'd like to correct if I could. I'm using a slight variant of your Github sh script posted here https://github.com/filebot/plugins/blob ... process.sh. Variant is symlink vs duplicate.

I've noticed, when deluge passes the torrent arguments to the filebot script, it processes the entire download folder instead of just the single file/folder passed. I know it creates the excludes file, but it causes some complications in my case and I'd like to save the cpu cycles if I could. I've searched, but filebot is so vast and flexible I haven't found any info to help. Any ideas?

Specs are: Linuxmint 18, filebot 4.7.7 Groovy 2.4.7

Thanks!
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: deluge-postprocess.sh processed entire folder

Post by rednoah »

If you can figure out why this is happening, then maybe I can fix it. I'd start by collecting logs.
:idea: Please read the FAQ and How to Request Help.
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

Hey Rednoah. Thanks for the reply.
I didn't include log files because there really isn't anything relevant in them.

Here's what I did. I ran a test rig with filebot. I've got my download folder with many movies and TV shows in it. I want deluge-postprocess.sh to only process the single file passed to it (ARG_NAME), but it processes all the file/folders in ARG_PATH instead of just the single file passed. Yes, if the files are listed in the 'exclude' file it gets passed over, but what's the point of the excludes to me if I only want the one file processed?

I found what seems to be a working solution by changing ut_dir to

Code: Select all

ut_dir="$ARG_PATH/$ARG_NAME"
This now only processes the single file passed to it. Easy peazy.

Here's my modified deluge-postprocess.sh

Code: Select all

#!/bin/sh

# Input Parameters
ARG_PATH="$3"
ARG_NAME="$2"
ARG_LABEL="$1"

# Configuration
CONFIG_OUTPUT="/path/to/media" # if this script is called by the deluge user, then $HOME will NOT refer to YOUR user home, but paths such as /var/lib/deluge instead

filebot -script fn:amc --output "$CONFIG_OUTPUT" --action symlink --conflict skip -non-strict --log-file amc.log --def unsorted=y music=y artwork=y ut_dir="$ARG_PATH/$ARG_NAME" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL"
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: deluge-postprocess.sh processed entire folder

Post by rednoah »

ARG_PATH is supposed to be the folder path multi-file torrents and a file path for single-file torrents.
:idea: Please read the FAQ and How to Request Help.
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

ARG_PATH="$3" is the base folder Deluge saves to. I had a look at the transmission-postprocess.sh and it appears to be accounted for with essentially what I deduced earlier:

Code: Select all

# Input Parameters
ARG_PATH="$TR_TORRENT_DIR/$TR_TORRENT_NAME"
ARG_NAME="$TR_TORRENT_NAME"
ARG_LABEL="N/A"
I think deluge-postprocess.sh should possibly be changed to:

Code: Select all

# Input Parameters
ARG_PATH="$3/$2"
ARG_NAME="$2"
ARG_LABEL="N/A"
Instead of:

Code: Select all

# Input Parameters
ARG_PATH="$3"
ARG_NAME="$2"
ARG_LABEL="N/A"
It's up to you. No one else seems to be complaining.... ;)

Thanks again!
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: deluge-postprocess.sh processed entire folder

Post by rednoah »

Deluge is not necessarily the same as Transmission. ;)

If you find some Deluge documentation that specifies what Argument 1, 2 and 3 are supposed to be in the case of single-file and multi-file torrents then I'll consider changing the script accordingly.

e.g. if $3 is the folder path and $2 the file name when dealing with single-file torrents. Is $3 the root folder or the torrent folder and is $2 empty for multi-file torrents? That's what the logs would have told me. ;)
:idea: Please read the FAQ and How to Request Help.
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

I never found documentation on the outputs of Deluge although I didn't look that hard. I simply had Deluge execute a script that echoed the outputs to a text file for me. I've used both Transmission and then switched to Deluged for it's plugins so I'm quite familiar with both.

$1 Passes the hash for the torrent in question.

$2 Is the name of the torrent. Either it be a folder or single file. It's just the name, not an absolute path. It's the exact equivalent to $TR_TORRENT_NAME

$3 Is the base (root) folder that has been set in Deluge to save downloads to. It's the exact equivalent to $TR_TORRENT_DIR

If you want my scripts, log files or terminal output that wouldn't be a problem, but I'd prefer to send them directly to you if I could. No need for the entire interwebs to know I download a soap opera! :D
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

I just had a Google of Deluge execute output.
http://dev.deluge-torrent.org/wiki/Plugins/Execute

Relevant info:

Code: Select all

#!/bin/bash
torrentid=$1
torrentname=$2
torrentpath=$3
echo "Torrent Details: " $torrentname $torrentpath $torrentid  >> /tmp/execute_script.log
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: deluge-postprocess.sh processed entire folder

Post by rednoah »

Alright, I guess the execute plugin finally behaves properly then:
https://github.com/filebot/plugins/comm ... b3f52f1f80

Please make sure that it works for BOTH single-file and multi-file torrents and report back. Cheers!
:idea: Please read the FAQ and How to Request Help.
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

I can confirm on two different machines with Filebot 4.7.7/Deluge 1.3.13 that the updated script works for both single file and muti-file(folder) to give the desired effect of only processing the single torrent passed to filebot.

Thanks for your time.
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

Before change ran from terminal:

Code: Select all

john@john-Latitude-E6420 ~/.scripts $ sh -x ./deluge-postprocess.sh "n/a" "Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER" "/home/john/Torrent_download"
+ ARG_PATH=/home/john/Torrent_download
+ ARG_NAME=Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER
+ ARG_LABEL=N/A
+ CONFIG_OUTPUT=/home/john/TV Shows
+ filebot -script fn:amc --output /home/john/TV Shows --action symlink --conflict skip -non-strict --log-file amc.log --def unsorted=y music=n artwork=n excludeList=.excludes ut_dir=/home/john/Torrent_download ut_kind=multi ut_title=Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER ut_label=N/A
Locking /home/john/.filebot/logs/amc.log
Run script [fn:amc] at [Fri Feb 03 17:41:48 EST 2017]
Parameter: unsorted = y
Parameter: music = n
Parameter: artwork = n
Parameter: excludeList = .excludes
Parameter: ut_dir = /home/john/Torrent_download
Parameter: ut_kind = multi
Parameter: ut_title = Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER
Parameter: ut_label = N/A
Use excludes: /home/john/TV Shows/.excludes
Input: /home/john/Torrent_download/Pawn.Stars.S12E39.REAL.HDTV.x264-TURBO/Pawn.Stars.S12E39.REAL.HDTV.x264-TURBO.mkv
Input: /home/john/Torrent_download/Pawn.Stars.S13E17.720p.HDTV.x264-KILLERS/Pawn Stars-None.mkv
Input: /home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER/Schitt's Creek-S02E08.mkv
Input: /home/john/Torrent_download/The Grand Tour-S01E06.mp4
xattr: [Pawn.Stars.S12E39.REAL.HDTV.x264-TURBO.mkv] => [Pawn Stars - 2010x39 - Ready, Set, Pawn]
xattr: [Pawn Stars-None.mkv] => [Pawn Stars - 2016x17 - G.I. Pawn]
xattr: [Schitt's Creek-S02E08.mkv] => [Schitt's Creek - 2x08 - Milk Money]
xattr: [The Grand Tour-S01E06.mp4] => [The Grand Tour (2016) - 1x06 - Happy Finnish Christmas]
Group: [tvs:pawn stars] => [Pawn.Stars.S12E39.REAL.HDTV.x264-TURBO.mkv, Pawn Stars-None.mkv]
Group: [tvs:schitts creek] => [Schitt's Creek-S02E08.mkv]
Group: [tvs:the grand tour 2016] => [The Grand Tour-S01E06.mp4]
Rename episodes using [TheTVDB]
Auto-detected query: [Pawn Stars]
Fetching episode data for [Pawn Stars]
Fetching episode data for [Pawn Stars (SA)]
Fetching episode data for [Pawn Stars UK]
Fetching episode data for [Cajun Pawn Stars]
Fetching episode data for [Pawn Stars Australia]
[SYMLINK] Rename [/home/john/Torrent_download/Pawn.Stars.S12E39.REAL.HDTV.x264-TURBO/Pawn.Stars.S12E39.REAL.HDTV.x264-TURBO.mkv] to [/home/john/TV Shows/TV Shows/Pawn Stars/Season 2010/Pawn Stars - S2010E39 - Ready, Set, Pawn.mkv]
[SYMLINK] Rename [/home/john/Torrent_download/Pawn.Stars.S13E17.720p.HDTV.x264-KILLERS/Pawn Stars-None.mkv] to [/home/john/TV Shows/TV Shows/Pawn Stars/Season 2016/Pawn Stars - S2016E17 - G.I. Pawn.mkv]
Processed 2 files
Rename episodes using [TheTVDB]
Auto-detected query: [Schitt's Creek]
Fetching episode data for [Schitt's Creek]
[SYMLINK] Rename [/home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER/Schitt's Creek-S02E08.mkv] to [/home/john/TV Shows/TV Shows/Schitt's Creek/Season 02/Schitt's Creek - S02E08 - Milk Money.mkv]
Processed 1 files
Rename episodes using [TheTVDB]
Auto-detected query: [The Grand Tour (2016)]
Fetching episode data for [The Grand Tour (2016)]
Fetching episode data for [The Grand Tour]
Fetching episode data for [The Grand (1997)]
[SYMLINK] Rename [/home/john/Torrent_download/The Grand Tour-S01E06.mp4] to [/home/john/TV Shows/TV Shows/The Grand Tour (2016)/Season 01/The Grand Tour (2016) - S01E06 - Happy Finnish Christmas.mp4]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
After change:

Code: Select all

john@john-Latitude-E6420 ~/.scripts $ sh -x ./deluge-postprocess.sh "n/a" "Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER" "/home/john/Torrent_download"
+ ARG_PATH=/home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER
+ ARG_NAME=Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER
+ ARG_LABEL=N/A
+ CONFIG_OUTPUT=/home/john/TV Shows
+ filebot -script fn:amc --output /home/john/TV Shows --action symlink --conflict skip -non-strict --log-file amc.log --def unsorted=y music=n artwork=n excludeList=.excludes ut_dir=/home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER ut_kind=multi ut_title=Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER ut_label=N/A
Locking /home/john/.filebot/logs/amc.log
Run script [fn:amc] at [Fri Feb 03 17:40:57 EST 2017]
Parameter: unsorted = y
Parameter: music = n
Parameter: artwork = n
Parameter: excludeList = .excludes
Parameter: ut_dir = /home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER
Parameter: ut_kind = multi
Parameter: ut_title = Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER
Parameter: ut_label = N/A
Use excludes: /home/john/TV Shows/.excludes
Input: /home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER/Schitt's Creek-S02E08.mkv
xattr: [Schitt's Creek-S02E08.mkv] => [Schitt's Creek - 2x08 - Milk Money]
Group: [tvs:schitts creek] => [Schitt's Creek-S02E08.mkv]
Rename episodes using [TheTVDB]
Auto-detected query: [Schitt's Creek]
Fetching episode data for [Schitt's Creek]
[SYMLINK] Rename [/home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER/Schitt's Creek-S02E08.mkv] to [/home/john/TV Shows/TV Shows/Schitt's Creek/Season 02/Schitt's Creek - S02E08 - Milk Money.mkv]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
0b1001
Posts: 8
Joined: 02 Feb 2017, 17:40

Re: deluge-postprocess.sh processed entire folder

Post by 0b1001 »

And here's a single file:

Code: Select all

john@john-Latitude-E6420 ~/.scripts $ sh -x ./deluge-postprocess.sh "n/a" "The Grand Tour-S01E06.mp4" "/home/john/Torrent_download"
+ ARG_PATH=/home/john/Torrent_download/The Grand Tour-S01E06.mp4
+ ARG_NAME=The Grand Tour-S01E06.mp4
+ ARG_LABEL=N/A
+ CONFIG_OUTPUT=/home/john/TV Shows
+ filebot -script fn:amc --output /home/john/TV Shows --action symlink --conflict skip -non-strict --log-file amc.log --def unsorted=y music=n artwork=n excludeList=.excludes ut_dir=/home/john/Torrent_download/The Grand Tour-S01E06.mp4 ut_kind=multi ut_title=The Grand Tour-S01E06.mp4 ut_label=N/A
Locking /home/john/.filebot/logs/amc.log
Run script [fn:amc] at [Fri Feb 03 17:54:40 EST 2017]
Parameter: unsorted = y
Parameter: music = n
Parameter: artwork = n
Parameter: excludeList = .excludes
Parameter: ut_dir = /home/john/Torrent_download/The Grand Tour-S01E06.mp4
Parameter: ut_kind = multi
Parameter: ut_title = The Grand Tour-S01E06.mp4
Parameter: ut_label = N/A
Use excludes: /home/john/TV Shows/.excludes
Input: /home/john/Torrent_download/The Grand Tour-S01E06.mp4
xattr: [The Grand Tour-S01E06.mp4] => [The Grand Tour (2016) - 1x06 - Happy Finnish Christmas]
Group: [tvs:the grand tour 2016] => [The Grand Tour-S01E06.mp4]
Rename episodes using [TheTVDB]
Auto-detected query: [The Grand Tour (2016)]
Fetching episode data for [The Grand Tour (2016)]
Fetching episode data for [The Grand Tour]
Fetching episode data for [The Grand (1997)]
[SYMLINK] Rename [/home/john/Torrent_download/The Grand Tour-S01E06.mp4] to [/home/john/TV Shows/TV Shows/The Grand Tour (2016)/Season 01/The Grand Tour (2016) - S01E06 - Happy Finnish Christmas.mp4]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: deluge-postprocess.sh processed entire folder

Post by rednoah »

Alright, I was just worried that deluge would pass in /home/john/Torrent_download/Schitts.Creek.S02E08.DVDRip.x264-SPRiNTER as $3. I'm fairly sure that's what it did in the past. Glad they finally fixed it.
:idea: Please read the FAQ and How to Request Help.
Post Reply