[GetScripts] Various Scripts

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
Post Reply
clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

[GetScripts] Various Scripts

Post by clintonhall » 22 Nov 2014, 03:15

Hi All,

A number of features available in nzbToMedia have been requested as stand-alone scripts.
I have made these available in https://github.com/clinton-hall/GetScripts

A Collection of NZBGet Post-Process Scripts

1. flatten.py

- This will remove subdirectories and put all downloaded files into the root download directory.
- You can specify a unique directory and append category sub directory if wanted.

2. passwordList.py

- This will attempt to extract archives using a list of possible passwords.

3. ResetDateTime.py

- This will reset the file dates on downloaded/extracted files, replacing the dates set from within the archive.

4. DeleteSamples.py

- This will delete "sample" files from Video Downloads.

5. SafeRename.py

- This will parse the download for any "rename.sh" or "rename.bat" scripts and then determine the correct file renaming to be applied.
- This removes the danger of running any downloaded .sh/.bat files.

fifaworld
Posts: 3
Joined: 10 Dec 2014, 02:33
Contact:

Re: [GetScripts] Various Scripts

Post by fifaworld » 13 Dec 2014, 00:59

This will attempt to extract archives using a list of possible passwords. :( :(







----------------------------------------
fifa 15 coins ps4 fifa 15 coins

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: [GetScripts] Various Scripts

Post by clintonhall » 13 Dec 2014, 21:07

fifaworld wrote:This will attempt to extract archives using a list of possible passwords. :( :(
Can you please state your concern?
This addresses a specific request that was made since some providers/trackers use a list of known passwords.
At the end of the day, this is just a PPscripts that is optional. You don't need to use it if you don't like it.

GeddyLee
Posts: 3
Joined: 31 Dec 2014, 09:06

Re: [GetScripts] Various Scripts

Post by GeddyLee » 31 Dec 2014, 09:23

Hi Clinton,

Could the DeleteSamples script be altered to remove any file below a certain size? Your script removes samples perfectly but i would love to have all files except the main movie file te be deleted. I'm using NZBGet on a Synolgy NAS and I have to do a manual cleanup after a download. Files like these: .par2, .sfv, _brokenlog.txt, .nfo, .url, .txt, .png, .bmp, .jpg, .nzb, .exe, .nzb, .gif mainly found in subfolders. So flatten doesn't flatten the subfolders because these are not empty.

NZBGet has a onboard cleanup but it doesn't cleanup in subfolders.

Thanks in advance!

GeddyLee
Attachments
flatten.png

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: [GetScripts] Various Scripts

Post by clintonhall » 01 Jan 2015, 03:14

it's in my to-do list... https://github.com/clinton-hall/GetScripts/issues/2

just need to find some time.

GeddyLee
Posts: 3
Joined: 31 Dec 2014, 09:06

Re: [GetScripts] Various Scripts

Post by GeddyLee » 01 Jan 2015, 07:15

Here it is .. requires .* in MediaExtensions. Thanks to Ben(V) from the Dutch Synology Forum!

The order I use is delete "samples", then flatten and then reverse name, which leaves a single file with the name reversed and no other file in a single folder. Great! no more manual stuff to do :D

Code: Select all

#!/usr/bin/env python
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT                                          ###

# Delete ".sample" files.
#
# This script removed sample files from the download directory.
#
# NOTE: This script requires Python to be installed on your system.

##############################################################################
### OPTIONS                                                                ###

# Media Extensions
#
# This is a list of media extensions that may be deleted if a Sample_id is in the filename.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso

# maxSampleSize
#
# This is the maximum size (in MiB) to be be considered as sample file.
#maxSampleSize=200

# SampleIDs
#
# This is a list of identifiers used for samples. e.g sample,-s. Use 'SizeOnly' to delete all media files less than maxSampleSize.
#SampleIDs=sample,-s. 

### NZBGET POST-PROCESSING SCRIPT                                          ###
##############################################################################
import os
import sys

# NZBGet Exit Codes
NZBGET_POSTPROCESS_PARCHECK = 92
NZBGET_POSTPROCESS_SUCCESS = 93
NZBGET_POSTPROCESS_ERROR = 94
NZBGET_POSTPROCESS_NONE = 95

def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
    # 200 MB in bytes
    SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
    if os.path.getsize(filePath) < SIZE_CUTOFF:
        if 'SizeOnly' in SampleIDs:
            return True
        # Ignore 'sample' in files unless 'sample' in Torrent Name
        for ident in SampleIDs:
            if ident.lower() in filePath.lower() and not ident.lower() in inputName.lower(): 
                return True
    # Return False if none of these were met.
    return False
  
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
    print "This script can only be called from NZBGet (11.0 or later)."
    sys.exit(0)

if os.environ['NZBOP_VERSION'][0:5] < '11.0':
    print "NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION']))
    sys.exit(0)

print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION']))
status = 0
if os.environ.has_key('NZBPP_TOTALSTATUS'):
    if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
        print "Download failed with status %s." % (os.environ['NZBPP_STATUS'])
        status = 1

else:
    # Check par status
    if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
        print "Par-repair failed, setting status \"failed\"."
        status = 1

    # Check unpack status
    if os.environ['NZBPP_UNPACKSTATUS'] == '1':
        print "Unpack failed, setting status \"failed\"."
        status = 1

    if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
        # Unpack was skipped due to nzb-file properties or due to errors during par-check

        if os.environ['NZBPP_HEALTH'] < 1000:
            print "Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"."
            print "Please check your Par-check/repair settings for future downloads."
            status = 1

        else:
            print "Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful."
            print "Please check your Par-check/repair settings for future downloads."

# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
    print "Nothing to post-process: destination directory", os.environ['NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\"."
    status = 1

# All checks done, now launching the script.
if status == 1:
    sys.exit(NZBGET_POSTPROCESS_NONE)

mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
    for file in filenames:
        filePath = os.path.join(dirpath, file)
        fileName, fileExtension = os.path.splitext(file)
        if fileExtension in mediaContainer or ".*" in mediaContainer :  # If the file is a video file
            if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs):  # Ignore samples
                print "Deleting sample file: ", filePath
                try:
                    os.unlink(filePath)
                except:
                    print "Error: unable to delete file", filePath
                    sys.exit(NZBGET_POSTPROCESS_ERROR)
sys.exit(NZBGET_POSTPROCESS_SUCCESS)
Attachments
mediaextensions.png
mediaextensions.png (5.71 KiB) Viewed 14002 times

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: [GetScripts] Various Scripts

Post by clintonhall » 01 Jan 2015, 08:24

added to my github version... thanks.

GeddyLee
Posts: 3
Joined: 31 Dec 2014, 09:06

Re: [GetScripts] Various Scripts

Post by GeddyLee » 01 Jan 2015, 08:59

Thank you for making the script! It works really great.

patommel
Posts: 1
Joined: 08 Jan 2015, 06:55

Re: [GetScripts] Various Scripts

Post by patommel » 08 Jan 2015, 07:02

Edit: Never mind, problem solved. Thanks for the scripts!

manrax
Posts: 4
Joined: 16 Mar 2015, 09:50

Re: [GetScripts] Various Scripts

Post by manrax » 16 Mar 2015, 09:57

Tried to get the PasswordList Script working but I get this Error all the time

Code: Select all

NFO	2015-03-16 10:54:46	passwordList: Script triggered from NZBGet Version 13.0.
INFO	2015-03-16 10:54:46	passwordList: Download failed with status FAILURE/UNPACK.
INFO	2015-03-16 10:54:46	passwordList: Traceback (most recent call last):
INFO	2015-03-16 10:54:46	passwordList:   File "/usr/local/share/nzbget/scripts/passwordList.py", line 134, in <module>
INFO	2015-03-16 10:54:46	passwordList:     if call(['which', cmd], stdout=devnull, stderr=devnull):  #note, returns 0 if exists, or 1 if doesn't exist.
INFO	2015-03-16 10:54:46	passwordList:   File "/usr/local/modules/python27/lib/python2.7/subprocess.py", line 493, in call
INFO	2015-03-16 10:54:46	passwordList:     return Popen(*popenargs, **kwargs).wait()
INFO	2015-03-16 10:54:46	passwordList:   File "/usr/local/modules/python27/lib/python2.7/subprocess.py", line 679, in __init__
INFO	2015-03-16 10:54:46	passwordList:     errread, errwrite)
INFO	2015-03-16 10:54:46	passwordList:   File "/usr/local/modules/python27/lib/python2.7/subprocess.py", line 1249, in _execute_child
INFO	2015-03-16 10:54:46	passwordList:     raise child_exception
INFO	2015-03-16 10:54:46	passwordList: OSError: [Errno 2] No such file or directory
ERROR	2015-03-16 10:54:46	Post-process-script passwordList.py for Unbroken.WEBRiP.LD.GERMAN.x264-RELiABLE failed (terminated with unknown status)
NzbGet is running on my WD My Cloud NAS

Thanks for Help

Manrax

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests