clinton-hall / getscripts Goto Github PK
View Code? Open in Web Editor NEWA Collection of NZBGet Post-Process Scripts
License: GNU General Public License v2.0
A Collection of NZBGet Post-Process Scripts
License: GNU General Public License v2.0
Hello,
Lately i've been getting a lot of rename.sh files like this:
#!/bin/bash
mkdir Marvels.Agents.of.S.H.I.E.L.D.S01E03.The.Asset.GERMAN.DL.DUBBED.1080p.WebHD.x264-TVP
mv 02.07.2014.1 Marvels.Agents.of.S.H.I.E.L.D.S01E03.The.Asset.GERMAN.DL.DUBBED.1080p.WebHD.x264-TVP/tvp-shield-s01e03-1080p.mkv
Is there any way we could execute the mkdir command to? Or even better ignore it and remove it's folder from the mv string?
Greetings
Josh
With pyton2 EOL not all scripts are python3 compatible.
Seems like someone forked and made all scripts python3.
CKanKan@f048830
This is the SABnzbd postprocessing script I created based on your NZBget script: https://github.com/sanderjo/SAB-SafeRename
I think it would be technically possible to have just one script usable for NZBget and SABnzbd; something along the lines of:
import os, sys, re, shlex
def rename_script(dirname):
# current function definition
if os.environ.has_key('NZBOP_SCRIPTDIR'):
do_all_NZBget_environment_checks()
rename_script(os.path.normpath(os.environ['NZBPP_DIRECTORY'])
sys.exit(NZBGET_POSTPROCESS_SUCCESS)
else:
# Assume a call from SABnzbd
do_SAB_stuff() # among which: (scriptname,directory,orgnzbname,jobname,reportnumber,category,group,postprocstatus,url) = sys.argv
rename_script(directory)
If this is acceptable for NZBget style and you (Clinton Hall), it would create one source ... easier to maintain
Shebang #!/usr/bin/env python
results in Python 3 being used on my system. I suggest #!/usr/bin/env python2
.
With latest testing release NZBGet 21
Post-process-script ResetDateTime.py for REDACTED.FILE.NAME.2018.LiMiTED.1080p.BluRay.x264-CADAVER failed (terminated with unknown status) INFO
Sun Oct 07 2018 22:27:04 ResetDateTime: /usr/bin/env: 'python\r': No such file or directory
First of all thanks for all the hard work on the scripts you have made. But unfortunately the Safe Rename scripts are not working on my side. Using a SABNZBD + COUCHPOTATO + SONAAR Combo here. Well the thing is, most of the German content is now structured like this, which makes it very hard to run the a_Linux_2rename.sh for every single movie I download.
I did put the script at the correct place.
And this is where your script is located.
And I did disable Post-Process Only Verified Jobs.
I cant figure out why isnt the script working.
Here is the file structure.
Your help on this, would be deeply appreciated. Please take a look if you have time on your hands.
Unfortunately I get the following error when using SafeRename with Sabnzbd:
Script triggered from SABnzbd
[INFO] Extracting file /share/Downloads/complete/tv/xxxx/win_click2rename.bat with command UnRAR.exe x -p339124433 Click.rar
Traceback (most recent call last):
File "/usr/share/sabnzbdplus/sabnzbd/SafeRename.py", line 160, in
rename_script(dirname)
File "/usr/share/sabnzbdplus/sabnzbd/SafeRename.py", line 117, in rename_script
p = Popen(cmd, stdout=devnull, stderr=devnull) # should extract files fine.
File "/usr/lib/python2.7/subprocess.py", line 679, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Edit:
(Reason: Tried NZBget - same error)
ERROR Sat Aug 13 2016 10:57:51 Post-process-script SafeRename.py for xxxxx failed (terminated with unknown status)
INFO Sat Aug 13 2016 10:57:51 SafeRename: OSError: [Errno 2] No such file or directory
INFO Sat Aug 13 2016 10:57:51 SafeRename: raise child_exception
INFO Sat Aug 13 2016 10:57:51 SafeRename: File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
INFO Sat Aug 13 2016 10:57:51 SafeRename: errread, errwrite)
INFO Sat Aug 13 2016 10:57:51 SafeRename: File "/usr/lib/python2.7/subprocess.py", line 679, in init
INFO Sat Aug 13 2016 10:57:51 SafeRename: p = Popen(cmd, stdout=devnull, stderr=devnull) # should extract files fine.
INFO Sat Aug 13 2016 10:57:51 SafeRename: File "/opt/nzbget/scripts/SafeRename.py", line 117, in rename_script
INFO Sat Aug 13 2016 10:57:51 SafeRename: rename_script(dirname)
Hi Clinton,
thanks for the great work! Unfortunately I am running into problems with the scripts. I use SafeRename and DeleteSamples. When I try to postprocess them they log the error:
SafeRename: env: python: No such file or directory
My env is: PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
ls -l /usr/local/bin | grep python
:
lrwxr-xr-x 1 root wheel 7 Jun 29 03:24 python -> python2
lrwxr-xr-x 1 root wheel 14 Jun 29 03:24 python-config -> python2-config
lrwxr-xr-x 1 root wheel 9 Jun 29 03:19 python2 -> python2.7
lrwxr-xr-x 1 root wheel 16 Jun 29 03:19 python2-config -> python2.7-config
-r-xr-xr-x 1 root wheel 5432 Jun 29 03:18 python2.7
-r-xr-xr-x 1 root wheel 1769 Jun 29 03:18 python2.7-config
I tried to change the shebang to #!/usr/local/bin/python
, but then the script had problems to find the unpack commands further down the script. I didn't want to change every single appearance of these commands.
Any suggestions?
Thx,
Phil
Hi,
using NZBGet, I see the follow PP error:
Post-process-script GetScripts/DeleteSamples.py for _nzb_name_ failed (terminated with unknown status)
Is there a way for me to give you more diagnostics data?
python --version
Python 2.7.12
I would like to thank you for great nzbget scripts here and would ask for an upgrade of flatten script.
A lot of downloaded files come with subtitles that are rared inside original rar.
Is it possible for your flatten script to check for those and unrar them as well.
IMHO it seems lines like
mv 02.01.2015.9 "[blabla] - 2010-12-07 - bla & bla - bla & bla 2/061.jpg"
are not handled correctly by
cmd = filter(None, re.split('(?:mv|Move)\s+(\S+)\s+(\S+)',line))
as double quotes are ignored. I used shlex to solve that.
Proof-of-concept script:
import re
import shlex
line = 'mv 02.01.2015.36 "[ZEMANI] - 2010-12-07 - bla & bla - bla & bla 2/032.jpg"'
print line
cmd = filter(None, re.split('(?:mv|Move)\s+(\S+)\s+(\S+)',line))
print cmd
if re.search('^(mv|Move)', line, re.IGNORECASE):
cmd = shlex.split(line)[1:]
print cmd
Result:
$ python kul-splitter.py
mv 02.01.2015.36 "[ZEMANI] - 2010-12-07 - bla & bla - bla & bla 2/032.jpg"
['02.01.2015.36', '"[ZEMANI]', ' - 2010-12-07 - bla & bla - bla & bla 2/032.jpg"']
['02.01.2015.36', '[ZEMANI] - 2010-12-07 - bla & bla - bla & bla 2/032.jpg']
Code change in SafeRename.py
# cmd = filter(None, re.split('(?:mv|Move)\s+(\S+)\s+(\S+)',line))
if re.search('^(mv|Move)', line, re.IGNORECASE):
cmd = shlex.split(line)[1:]
print cmd
else:
continue
I'll NOT send a github pull request; I'm not using your code in NZBget, so I find it a bit dangerous to change it without testing it in NZBget itselft.
Hey,
Just found the ResetDateTime script and love it as exactly what I needed, however running the latest NZBGet/etc (ArchLinux latest/uptodate) it is unable to process successfully. See error below, any ideas? Running NZBGet 15.0-1 from the AUR, maybe because python? I have both 2 and 3, although the default python command defaults to 3? Again error below, thanks!
INFO Tue Jul 14 2015 20:32:38 Collection yadayada(tt2039393) added to history
ERROR Tue Jul 14 2015 20:32:37 Post-process-script ResetDateTime.py for yadayada(tt2039393) failed (terminated with unknown status)
INFO Tue Jul 14 2015 20:32:37 ResetDateTime: SyntaxError: invalid syntax
INFO Tue Jul 14 2015 20:32:37 ResetDateTime: ^
INFO Tue Jul 14 2015 20:32:37 ResetDateTime: print "This script can only be called from NZBGet (11.0 or later)."
INFO Tue Jul 14 2015 20:32:37 ResetDateTime: File "/usr/share/nzbget/scripts/ResetDateTime.py", line 25
INFO Tue Jul 14 2015 20:32:37 Executing post-process-script ResetDateTime.py for yadayada(tt2039393)
INFO Tue Jul 14 2015 20:32:37 Queueing yadayada(tt2039393) for post-processing
INFO Tue Jul 14 2015 20:32:37 yadayada(tt2039393) returned from history back to download queue
INFO Tue Jul 14 2015 20:24:25 Collection yadayada(tt2039393) added to history
Some boards are packing the rename.sh file now-
within a password protected rar archive named What.rar
There is a โa_Linux_2rename.shโ file in main dir now containing this:
unrar x -p73522169 What.rar
./What.sh
Now that What.sh file is our rename script containing our known move commands.
As requested at #6
chmod 775 all files and dirs after successfull rename ? (Add a user defined chmod)
And maybe also a cleanup of all .sh, .rar, .zip, .bat files ? (user defined)
i sometimes get the error from sabnzbd:
NameError: global name 'SEVENZIP' is not defined
7zip is installed, do i have to add a system variable?
Hey Clinton,
can you please check the nzb i just mailed you when you get some time ?
Maybe its my fault but it would be nice if you can just try this nzb on your side.
Thanks a lot !
I thought it already worked with this one but after many minutes ill get this output:
Traceback (most recent call last): File "/var/opt/sabnzbd/scripts/SafeRename.py", line 211, in <module> rename_script(dirname) File "/var/opt/sabnzbd/scripts/SafeRename.py", line 112, in rename_script cmd = extract_command(shlex.split(line), dirname) File "/var/opt/sabnzbd/scripts/SafeRename.py", line 162, in extract_command if platform.system() == 'Windows': NameError: global name 'platform' is not defined
Minor / cosmetic thing:
Current code:
if re.search('(rename\S*\.(sh|bat))',file):
will also find rename.sh.old. It will not find rename.BAT
I changed it to:
if re.search('(rename\S*\.(sh|bat)$)',file,re.IGNORECASE):
HTH
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.