Page 2 of 2

Re: [LINUX] Run rename.sh inside archive ?

Posted: February 11th, 2015, 10:11 am
by synci

Code: Select all

$ ls -al SafeRename.py
-rwxrwxrwx 1 sabnzbd users 1910 Feb 11 15:51 SafeRename.py
$ head -1 SafeRename.py
#!/usr/bin/env python
When i replace the first line with #!/usr/bin/python sab says:
Cannot run script /home/sabnzbd/.sabnzbd/scripts/SafeRename.py

Re: [LINUX] Run rename.sh inside archive ?

Posted: February 11th, 2015, 10:23 am
by sander
synci wrote:

Code: Select all

$ ls -al SafeRename.py
-rwxrwxrwx 1 sabnzbd users 1910 Feb 11 15:51 SafeRename.py
$ head -1 SafeRename.py
#!/usr/bin/env python
Size 1910 bytes? On my system and github 1858 bytes. Not good on your system.

Can you do this:

Code: Select all

cd /home/sabnzbd/.sabnzbd/scripts/
wget https://raw.githubusercontent.com/sanderjo/SAB-SafeRename/master/SAB-SafeRename.py
chmod +x SAB-SafeRename.py
ls -al SAB-SafeRename.py
./SAB-SafeRename.py BlaBla
Post result here.

Re: [LINUX] Run rename.sh inside archive ?

Posted: February 11th, 2015, 10:40 am
by synci
WTF it runs now ?!?
Ive copied the script 1:1, 4 times ..., never thought what can be wrong with this method.

Thank you so much sander !!!

Re: [LINUX] Run rename.sh inside archive ?

Posted: February 11th, 2015, 10:53 am
by sander
Good. Looking forward to your PM.

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 20th, 2015, 4:45 am
by synci
Hey sander,

im afraid but the script needs little modification :(
Now they pack(rar) our rename.sh/.bat file but gives us a new .sh file for that process.

a_Linux_2rename.sh:

Code: Select all

unrar x -p923613061 What.rar 
./What.sh
Inside that What.rar archive is our real rename.sh file.
NZB example sent via PM.

Any ideas ?

Thanks !!!

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 20th, 2015, 6:16 am
by sander
synci wrote: Any ideas ?
My ideas:

- What a mess! An executable creating a new executalbe, which you have to execute. Brrr
- What is the goal of the poster of suchs posts? I can only think of this: create a downloader's habit of randomly clicking on executables he/she downloaded (the last thing you should do), in order to create a path for introducing viruses, worms and other malware
- solving this in a program / SAB-pp-script is a rat race; the poster will always find new things you then have to solve in your program
- maybe running SABnzbd + pp-script in a sandbox (like a docker container) and then deleting the sandbox would be solution. Not an easy thing
- running the SAB-pp-script in a sandbox

And what are your ideas?

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 20th, 2015, 6:39 am
by synci
Dont know why they are doing this ...
Already mailed Clinton Hall for this and added an issue on github, he will look over this.

I thought its simple to just execute the new sh file if it contains a unpacking command.
Then do the same like before, parse the rename.sh file and rename the files :)

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 20th, 2015, 6:59 am
by sander
synci wrote:Dont know why they are doing this ...
Already mailed Clinton Hall for this and added an issue on github, he will look over this.
Clinton Hall has integrated my three fixes back into his script, so that it is now both NZBget and SABnzbd compatible.

synci wrote: I thought its simple to just execute the new sh file if it contains a unpacking command.
Then do the same like before, parse the rename.sh file and rename the files :)
OK, but do you realize that is part of the rat race? Having said that: what do you suggest as pseudo-code? My shot:

Code: Select all

find .sh -script, and parse it:
    mark this script as handled
    if line is a rename, find the parameters and do a safe python rename with those parameters
    if line is an unrar command, find the parameters, do a safe pyhton called unrar
if a new .sh-script is there, and parse it

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 20th, 2015, 7:06 am
by synci
Your shot sounds great :)
I know that it is a rat race but i think that they dont change it now for a while.

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 21st, 2015, 8:01 am
by sander
I see Clinton Hall has changed his code to support your request?

I have a completely different idea: just ignore all .sh/.bat scripts, and just give the extension based on the info that is given by the "file" command:

Code: Select all

$ file 19.02.2015.2
19.02.2015.2: Matroska data
"Matroska" so just add the extension ".mkv" at the end.

Code: Select all

$ file 20.02.2015.50
20.02.2015.50: JPEG image data, JFIF standard 1.02
JPEG, so just add ".jpg" at the end

The file name would stay the same.

Would that work for you?

EDIT: there's a python module for the 'file' command:

Code: Select all

$ sudo pip install python-magic

$ python
>>> import magic
>>> magic.from_file("19.02.2015.2")
'Matroska data'
>>> magic.from_file("19.02.2015.2", mime=True)
'video/x-matroska'


>>> import mimetypes
>>> mimetypes.guess_extension('video/x-matroska', strict=True)
'.mpv'
>>> mimetypes.guess_all_extensions('video/x-matroska', strict=True)
['.mpv', '.mkv']



Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 21st, 2015, 10:43 am
by synci
Yes Clinton Hall is on it, i think few short changes needed then it should work.

Your idea sounds really great because no changes in the script needed when the board will start another rat race.
But tbh, at the moment i prefer the other method with correct namings when possible.

For example, when SickRage downloads many episodes of different series, i have to change every episode name manual.
the episode dir namings are also crypted so i have to look into each nfo file for the correct episode/series name.

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: February 22nd, 2015, 5:44 am
by sander
And there is nothing in the job name, NZB name or directory name that reveals the name of the download? Because if so, it could be safely used to also rename the file.

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: September 11th, 2016, 11:25 am
by jkoopmann
Just hit the same issue. However the latest nzbToCouchpotatoe scripts do not seem to cover it. The latest SafeRename.py I found also did not look as if this was covered (looking for What.sh but not for a_Linux_2rename.sh like files). Have you guys ever solved this? Pretty annoying...

Re: [SOLVED][LINUX] Parse/run rename.sh inside archive ?

Posted: November 21st, 2016, 1:30 pm
by synci
This version works for me, just tested with brand new nzb and "a_Linux_2rename.sh" inside.
https://github.com/clinton-hall/GetScri ... eRename.py

Its also needed to disable recursive unpacking in Sabnzbd settings (https://sabnzbd.org/wiki/configuration/ ... tches#toc3)
Because Sabnzbd trys to unrar What.rar for a very long time when you use a passwordfile.