Merge pull request #850 from thatbritguy/master

Add `replace_for` script for SABnzbd and NZBGet
pull/833/head^2
TRaSH 2 years ago committed by GitHub
commit e4531751a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,6 +35,28 @@
[[% filter indent(width=4) %]][[% include 'Downloaders/NZBGet/scripts/HashRenamer/HashRenamer.py' %]][[% endfilter %]]
```
## replace_for
??? info "Replaces underscores with dots"
- Title: `replace_for.py`
- Author: miker
Replaces underscores with dots in downloaded filename to prevent download loops with poorly named releases on some indexers (often HONE releases).
Install Instructions:
1. Copy script to NZBGet's script folder
1. run: `sudo chmod +x replace_for.py`
1. in SABnzbd go to `Settings` => `Extension Scripts`
1. Enable `replace_for.py` in the `Extensions` setting.
??? example "Script"
```python
[[% filter indent(width=4) %]][[% include 'Downloaders/NZBGet/scripts/replace_for/replace_for.py' %]][[% endfilter %]]
```
## WtFnZb-Renamer
??? info "Renames hashed media files to match the source NZB"

@ -0,0 +1,40 @@
#!/usr/bin/env python3
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Replace underscore with dot.
#
# Author: miker
#
#
# Copy script to NZBGet's script folder.
# Run sudo chmod +x replace_for.py
#
#
# NOTE: This script requires Python to be installed on your system.
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
from __future__ import print_function
import os, re, sys
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_SKIP=95
directory = os.environ['NZBPP_DIRECTORY']
print('Directory used is: ',directory)
for path, currentDirectory, files in os.walk(directory):
for file in files:
if file.find("_") !=-1:
dst = file.replace('_', '.')
os.rename (os.path.join(path,file),os.path.join(path,dst) )
print('Result: ',file," renamed to ",dst)
sys.exit(POSTPROCESS_SUCCESS)

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

@ -26,3 +26,27 @@
```python
[[% filter indent(width=4) %]][[% include 'Downloaders/SABnzbd/scripts/Clean/Clean.py' %]][[% endfilter %]]
```
## replace_for
??? info "Replaces underscores with dots"
- Title: `replace_for.py`
- Author: miker
Replaces underscores with dots in downloaded filename to prevent download loops with poorly named releases on some indexers (often HONE releases).
Install Instructions:
1. Copy script to sabnzbd's script folder
1. run: `sudo chmod +x replace_for.py`
1. in SABnzbd go to `Settings` => `Categories`
1. Change script for required categories and select: `replace_for.py`
![!Enable replace_for.py](/Downloaders/SABnzbd/images/sabnzbd-categories-replace_for.png)
??? example "Script"
```python
[[% filter indent(width=4) %]][[% include 'Downloaders/SABnzbd/scripts/replace_for/replace_for.py' %]][[% endfilter %]]
```

@ -0,0 +1,42 @@
#!/usr/bin/python3 -OO
##################################################################
### SABnzbd - Replace underscores with dots ##
##################################################################
## ##
## NOTE: This script requires Python 3 ##
## ##
## Author: miker ##
## ##
## Install: ##
## 1. Copy script to sabnzbd's script folder ##
## 2. run: sudo chmod +x replace_for.py ##
## 3. in SABnzbd go to Config > Categories ##
## 4. Assign replace_for.py to the required category ##
##################################################################
import sys
import os
import os.path
try:
(scriptname, directory, orgnzbname, jobname, reportnumber, category, group, postprocstatus, url) = sys.argv
except:
print("No commandline parameters found")
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script
files = os.listdir(directory)
for src in files:
if src.find("_") !=-1:
dst = src.replace('_', '.')
os.rename (os.path.join(directory,src),os.path.join(directory,dst) )
print(src, "renamed to ",dst)
print()
print()
print()
print()
# 0 means OK
sys.exit(0)
Loading…
Cancel
Save