User script parameter request - Full path of TV file

Want something added? Ask for it here.
Post Reply
dr0pknutz
Newbie
Newbie
Posts: 7
Joined: May 6th, 2008, 8:42 pm

User script parameter request - Full path of TV file

Post by dr0pknutz »

After the TV sorting script has done its post processing is it possible to get a full path of the video file (AVI, MKV) sent as a parameter to the post processing scripts. I'm writing a script which creates a shortcut to the video file and places it inside a "Recent" folder. This then lets me quickly see the newest TV shows which have been downloaded and I can just open them from there.

Thanks.
Camelot
Jr. Member
Jr. Member
Posts: 64
Joined: August 18th, 2008, 6:23 am

Re: User script parameter request - Full path of TV file

Post by Camelot »

I have not checked, but my scripts seem to work fine, and I am pretty sure they would choke if they DIDN'T get a full path. Are you sure they are passed a relative path?
dr0pknutz
Newbie
Newbie
Posts: 7
Joined: May 6th, 2008, 8:42 pm

Re: User script parameter request - Full path of TV file

Post by dr0pknutz »

What I'm looking for is the name of the AVI file after the TV processing script has finished renaming it. These are the current parameters I can get:

Code: Select all

%1 = C:\Storage\Usenet\Complete\TV-XVID\Weeds
%2 = Weeds.S02E08.DVDRip.XviD-TOPAZ.nzb
%3 = Weeds.S02E08.DVDRip.XviD-TOPAZ
What I want is the name of the AVI. E.g: Weeds - 2x08.avi.

Thanks.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: User script parameter request - Full path of TV file

Post by shypike »

Yeah, I see what you mean.
Unfortunately we already have a ridiculous amount of parameters.
I'll discuss it with the team.
Camelot
Jr. Member
Jr. Member
Posts: 64
Joined: August 18th, 2008, 6:23 am

Re: User script parameter request - Full path of TV file

Post by Camelot »

One of the advantages of passing just a folder, is that sabnzbd does not have to make any assumptions regarding which of the multiple files in the resulting directory is the one that you want passed as a parameter. Yes, if you are downloading a tv show, then it is usually the avi/mp4/m4v/mkv file you are really interested in. But is this really an assumption/choice we want some smarts in sabnzbd to decide for us?
What I do now, is my post processing scripts take $1 and search for any movie file extensions, and then performs the script on those. Unfortunately, if there is a sample file, that will get picked up as well, but I can live with that.

Only option I can see for sabnzbd to do this foolproof, would be to pass ALL the files in the resulting directory as parameters.
nurriz
Newbie
Newbie
Posts: 1
Joined: March 16th, 2009, 6:19 pm

Re: User script parameter request - Full path of TV file

Post by nurriz »

This would be really helpful for doing conversion tasks on downloads. Even though you can concatenate the parameters passed to the user script, it falls apart as soon as you set up TV sorting to your liking. It would be nice for at least the final filename (after tv sorting) to be passed as a parameter. Having the clean version for the job name only helps if you don't rename with TV sorting.
belfbri
Newbie
Newbie
Posts: 5
Joined: September 2nd, 2008, 1:16 pm

Re: User script parameter request - Full path of TV file

Post by belfbri »

I was going to request the same feature. I'd like to be able to have a script to do some conversion on the resulting renamed file. I dont need the full path, just the renamed file with or without the extension.
Laat
Newbie
Newbie
Posts: 9
Joined: March 12th, 2009, 9:40 pm

Re: User script parameter request - Full path of TV file

Post by Laat »

This can be done in a postscript already though, for instance with this "post processing script" on a Linux machine.

Code: Select all

#!/bin/bash
find "$1" -cmin -1 -name *.avi | grep -iv sample
this finds all avi-files changed/created/moved less than 1 minute ago, except file names containing 'sample'

EDIT:
I didn't test this properly before answering, because this seem to only work with one episode pr folder. All files already in the destination folder get's the same changed time-stamp when a download is finished...
Last edited by Laat on April 10th, 2009, 3:28 pm, edited 1 time in total.
Laat
Newbie
Newbie
Posts: 9
Joined: March 12th, 2009, 9:40 pm

Re: User script parameter request - Full path of TV file

Post by Laat »

On linux, the method perm_script() chmod's all files in the destination folder, marking all the files already in the destination folder as changed. This makes it impossible for me to distinguish newly downloaded episodes/files from other episodes in the same folder.

To solve this I changed the postproc.py to only chmod the files if it does not already have the correct right's.

Code: Select all

--- a/sabnzbd/postproc.py
+++ b/sabnzbd/postproc.py
@@ -316,7 +316,9 @@ def perm_script(wdir, umask):
             logging.error('[%s] Cannot change permissions of %s', __NAME__, root)
         for name in files:
             try:
-                os.chmod(join(root, name), umask_file)
+                stat = os.stat(join(root, name))
+                if ((stat.st_mode & 0777) != umask_file):
+                    os.chmod(join(root, name), umask_file)
             except:
                 logging.error('[%s] Cannot change permissions of %s', __NAME__, join(root, name))
The simple find in my previous post works, and something similar should work on windows.
Last edited by Laat on April 12th, 2009, 3:31 pm, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: User script parameter request - Full path of TV file

Post by shypike »

dr0pknutz wrote: After the TV sorting script has done its post processing is it possible to get a full path of the video file (AVI, MKV) sent as a parameter to the post processing scripts. I'm writing a script which creates a shortcut to the video file and places it inside a "Recent" folder. This then lets me quickly see the newest TV shows which have been downloaded and I can just open them from there.

Thanks.
Request filed as https://trac2.assembla.com/SABnzbd/ticket/262
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: User script parameter request - Full path of TV file

Post by doubledrat »

I don't understand why you can't just search using your own script, like this -

Code: Select all

set dirname=%1
set dirname=%dirname:"=%
set name=%3
set name=%name:"=%

REM convert to iphone format
for /R "%dirname%" %%f in (*.mkv) do call :iphoneit %%~sf
for /R "%dirname%" %%f in (*.wmv) do call :iphoneit %%~sf
for /R "%dirname%" %%f in (*.avi) do call :iphoneit %%~sf
for /R "%dirname%" %%f in (*.mov) do call :iphoneit %%~sf
for /R "%dirname%" %%f in (*.mpg) do call :iphoneit %%~sf
Post Reply