Sabnzbd naming option

Want something added? Ask for it here.
onlyalex
Newbie
Newbie
Posts: 10
Joined: October 12th, 2010, 6:05 am

Sabnzbd naming option

Post by onlyalex »

Hi thanks for the best usenet downloading software :)

I would like to see an extra naming option in sabnzbd
Replace spaces with dots

I am using and the renaming function and have my library named like ex:
Movie.Name.2011.720P-Group.mkv

Most nzbs will get named this way but some contains spaces instead in there folder names. Sab will then replace the spaces with underscore if checked, i would like it to replace it with dots instead to keep my naming standard.

Hope to see this added sometime. Keep upp the good work
Best regards
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Sabnzbd naming option

Post by shypike »

Work-around:
First select the option "Replace spaces with underscores".
Put the following in a file called makedots.cmd and put it in the scripts folder.
Then select the script for the default category.

Code: Select all

@echo off
cd %1
cd ..
set newname=%3
set newname=%newname:_=.%
if not %3 == %newname% ren %3 %newname%
onlyalex
Newbie
Newbie
Posts: 10
Joined: October 12th, 2010, 6:05 am

Re: Sabnzbd naming option

Post by onlyalex »

Hi shypike thanks for helping.

I tried your script but i get an warning and it does not seem to work im afraid.
Im running sabnzbd on my nas device linux based. When the extension is .cmd i can see it in the dropdown list but clicking save does not save the selected script. I renamed it with .py extension since the other scripts are named that way. Then i can save the selected script in my movie catagory but when an movie is done and script is executed i get an error:
Cannot run script /share/MD0_DATA/.qpkg/SickBeard/autoProcessTV/makedots.py
Im also using sickbeard thats why the default script dir is pointing to sickbeard folder.
After checking the faq i found here http://wiki.sabnzbd.org/user-scripts
The script will receive these parameters. Use %1 in Windows scripts and $1 in Unix scripts.
I tried changing to $1 in the start of the script since im on linux but it did not help. Seems im stucked :(
Any help is mutch appriciated.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Sabnzbd naming option

Post by shypike »

It would have helped if you told me what operating system you are using.
Usually only Windows users think that there are no other OSses in the world.

The worst thing you can do is name it .py, because it's not a Python script.
This is a Python script to accomplish the same thing

Code: Select all

import sys
import os
os.chdir(sys.argv[1])
os.chdir('..')
os.rename(sys.argv[3], sys.argv[3].replace('_', '.'))
onlyalex
Newbie
Newbie
Posts: 10
Joined: October 12th, 2010, 6:05 am

Re: Sabnzbd naming option

Post by onlyalex »

Hi sorry my bad beeing unclear on that.

I am running sabnzbd 0.6.0 on my Qnap nas.
I renamed the file to "makedots.py" and chmod +x the script containing

Code: Select all

import sys
import os
os.chdir(sys.argv[1])
os.chdir('..')
os.rename(sys.argv[3], sys.argv[3].replace('_', '.'))
I moved the script catalog to be sure to "/share/MD0_DATA/.qpkg/SABnzbdplus"
I can select the script for my movies catagory and save. When an movie is done i still get an error
Cannot run script /share/MD0_DATA/.qpkg/SABnzbdplus/makedots.py

When i check i see even do the script has an failed status the movie get extraced to an dir and got "." dots instead of "_" but it got one extra folder and the .avi filename does contain spaces.
Movie.Name.2011.720P-GRP/grpdirname-moviename720p/Movie Name 2011 720P GRP.avi

So the first dir does look correct but the second level dir should not be there. The movie should be direct in the root of the first folder and also have it's spaces removed.
Movie.Name.2011.720P-GRP/Movie.Name.2011.720P-GRP.avi

Since i dont know anything about python scripting i cant fix it myself. But now it atleast run even do reported with errors.
Your help is mutch appriciated.

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

Re: Sabnzbd naming option

Post by shypike »

Right. I forgot one important thing.
The script must start with:
!/usr/bin/python

That is assuming that Python is actually in /usr/bin, you may want to check that.

The script only replaces stuff in the folder name.
If you want more, refer to the Sorting options, which contain some more options in that area.
I'm not going to write your script for you.
onlyalex
Newbie
Newbie
Posts: 10
Joined: October 12th, 2010, 6:05 am

Re: Sabnzbd naming option

Post by onlyalex »

The script works it renames the folder correct :D

Now my only problem is to be able to run it without getting an the error message in sabnzbd evertime, even do it works. Will try my way from here.
Thanks for your help, hat of for you mate.

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

Re: Sabnzbd naming option

Post by shypike »

onlyalex wrote:without getting an the error message in sabnzbd evertime, even do it works.
What kind of error message?
onlyalex
Newbie
Newbie
Posts: 10
Joined: October 12th, 2010, 6:05 am

Re: Sabnzbd naming option

Post by onlyalex »

Hi sorry for late reply

Il get this error message
Cannot run script /share/MD0_DATA/.qpkg/SABnzbdplus/rename_folder2.py
The script still runs do, the folder is renamed as it should but i see the error message on the right side of the main download window.

My python directory differs from your example and i have this in the start of the script
!/share/MD0_DATA/.qpkg/Python
Is there any loggin i can access maby to see why it says it fails even do it dont :S
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Sabnzbd naming option

Post by shypike »

Does it actually run or not?
If it does and you still get an error message, it may be that the script doesn't return
an exit code of 0 as nice script are supposed to do.
End your script with an "exit 0" line.
sl1000
Newbie
Newbie
Posts: 29
Joined: August 7th, 2010, 4:16 am

Re: Sabnzbd naming option

Post by sl1000 »

shypike wrote:Right. I forgot one important thing.
The script must start with:
!/usr/bin/python

That is assuming that Python is actually in /usr/bin, you may want to check that.

The script only replaces stuff in the folder name.
If you want more, refer to the Sorting options, which contain some more options in that area.
I'm not going to write your script for you.
Python is an ipkg in this case. So it lives in /opt/bin, and as we are using python2.6, without renaming or symlinking it to python (as other qpkg's tend to use other versions of python) the line should read:
!/opt/bin/python2.6

cheers ;)
onlyalex
Newbie
Newbie
Posts: 10
Joined: October 12th, 2010, 6:05 am

Re: Sabnzbd naming option

Post by onlyalex »

Hi i take this upp again since i have not manage to get it working. Sometime i managed to get the namin fuction work, i thought but i realised i used another .nzb file where the naming was already right.

I have redone my test with a valid .nzb file. Adding it to the que will for sure download an movie with Movie_Name etc.
I edited the script accordingly but did not make this work.

Code: Select all

!/opt/bin/python2.6
import sys
import os
os.chdir(sys.argv[1])
os.chdir('..')
os.rename(sys.argv[3], sys.argv[3].replace('_', '.'))
exit 0
The script does not rename the output folder and exits with an error code as stated before. Im giving up on this and thank you all for your help.
Im hoping this feature can be implemented in sabnzbd webinterface as an option in a near future.

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

Re: Sabnzbd naming option

Post by shypike »

Did you test the script separately, so that you can see the actual error message?
kaabob
Newbie
Newbie
Posts: 1
Joined: January 19th, 2012, 5:46 pm

Re: Sabnzbd naming option

Post by kaabob »

I'm running Mac OS X Lion and would love to know the script code for renaming the underscores into decimals/dots also. Thanks in advance!
kevinjose356
Newbie
Newbie
Posts: 1
Joined: December 6th, 2011, 4:30 am

Re: Sabnzbd naming option

Post by kevinjose356 »

oh man, I'm also looking for that same script code, If someone out there has that code please share here or PM me as soon as possible.
Post Reply