nzbToMedia for NZBGet V11+

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.
prinz2311
Posts: 466
Joined: 08 Dec 2012, 00:03

Re: nzbToMedia for NZBGet V11+

Post by prinz2311 » 20 Apr 2013, 21:46

The sample deletion got lost with this change.

I added the line:

Code: Select all

find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1
to the Cleanup.sh on my setup.

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

Re: nzbToMedia for NZBGet V11+

Post by clintonhall » 21 Apr 2013, 00:10

ah... fair call...

I might look at adding "sample deletion" as a separate script that can be added, along with WOL and transcoder.

That is the beauty now.. you can add as many as you want ;)

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

Re: nzbToMedia for NZBGet V11+

Post by clintonhall » 21 Apr 2013, 01:57

I have added a DeleteSamples.py script to my repo...

this should be used before any of my nzbTo* scripts.

No logging in this. it is just a straight forward delete of any "media" file (extensions are able to be modified in options) that contains ".sample" (unless ".sample" is in the nzbname) in the filename and is less than the define maximum sample file size (modified in options)

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: nzbToMedia for NZBGet V11+

Post by hugbug » 21 Apr 2013, 11:31

prinz2311 wrote:I added the line:

Code: Select all

find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1
to the Cleanup.sh on my setup.
I wanted actually to add this to default Cleanup.sh but didn't have time yet for this. If you have a little free time may be you could help?
This is how I see it:
  1. Option DeleteSamples. May be with option MaxSampleSize. I'm not sure if it is needed.
    Important: when deleting samples the script should check if there are other bigger files with the same extension. It should not delete sample if they are the only media files in the directory.
  2. Make an option to choose what extensions (case insensitive) to delete. Currently the script has hardcoded:

    Code: Select all

    rm *.[pP][aA][rR]2 >/dev/null 2>&1
    rm *.nzb >/dev/null 2>&1
    rm *.sfv >/dev/null 2>&1
    rm *.url >/dev/null 2>&1
    
    I would like to have an option CleanupExt instead:

    Code: Select all

    CleanupExt=par2,nzb,sfv,url
    If a space or other character as separator makes things easier it's OK.
Clinton, sorry to flood in your thread.

prinz2311
Posts: 466
Joined: 08 Dec 2012, 00:03

Re: nzbToMedia for NZBGet V11+

Post by prinz2311 » 21 Apr 2013, 11:55

clintonhall has added a new Script DeleteSamples.py now.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: nzbToMedia for NZBGet V11+

Post by hugbug » 21 Apr 2013, 12:01

prinz2311 wrote:clintonhall has added a new Script DeleteSamples.py now.
I need a sh-script with mentioned features. Cleanup-script is important and I want keep it bash because python is not everywhere available.

prinz2311
Posts: 466
Joined: 08 Dec 2012, 00:03

Re: nzbToMedia for NZBGet V11+

Post by prinz2311 » 21 Apr 2013, 13:55

OK will take a look at the sh script this week.

I personally would say it's the other way around. The python script works on all OS and the sh script doesn't work on windows.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: nzbToMedia for NZBGet V11+

Post by hugbug » 21 Apr 2013, 18:41

On one side I need to support devices where python is not available. On the other side the program works on windows and the only thing not woking there is the cleanup-script.

Considering how simple the script become after removing unpack-part I think the better way is to integrate the CleanupExt-Feature into the main program and remove the Cleanup-script from distribution at all. Anyone wanting deletion of samples is welcome to use Clintons DeleteSamples.py.

As for deleting of par-leftovers (*.1) this code needs to be integrate into par-checker anyway to correctly process renamed files (since in this case par-check doesn't create *.1 files).

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

Re: nzbToMedia for NZBGet V11+

Post by clintonhall » 22 Apr 2013, 04:28

In my older scripts I did replace the clean-up section with a for loop where a list of extensions to be deleted was defined. This itself is not hard to implement...

Code: Select all

# Clean up list. space separated, in single quotes, default '*.nzb *.sfv *.1'
FileCleanUp='*.nzb *.sfv *.1'

Code: Select all

# Clean up list, space separated array from GUI
for word in $FileCleanUp ; do rm $word >/dev/null 2>&1 ; done
Now, I don't believe this is case insensitive... perhaps we just make the user specify the case in-sensitive input?

Code: Select all

FileCleanUp='*.[nN][zZ][bB] *.[sS][fF][vV] *.1'
Personally, I agree with the approach to move the cleanup into the main program (with some options to be specified). As stated, that will remove the last of the .sh scripts from the ppscripts. Then it comes down to the script maintainers to try and support multi-platform where possible.

The delete sample script I have is pretty basic really... the only thing I think I might need to look at is the suggestion you made that it should only delete the ".sample" if another media file exists.... I think I'll change my script to build and array of media files in the for loop (not delete the .sample like it does now) and then parse the array to create an array of ".sample" media files. If the size of the sample media files array is less than the size of the media files array, we delete all in the sample media files array. I'll still keep the check that it only looks for sample when sample is NOT in the nzbname (in case there was a TV episode with "sample" in the name.. e.g. http://www.thetvdb.com/?tab=episode&ser ... 6092&lid=7 ). In this case, this might let through a ".sample" file, but I would prefer this to deleting the episode).

Obviously, if sample deletion was made as an option for the main program, then this script wont do anything and ultimately I'll just drop it from my repo ;)

prinz2311
Posts: 466
Joined: 08 Dec 2012, 00:03

Re: nzbToMedia for NZBGet V11+

Post by prinz2311 » 22 Apr 2013, 08:08

clintonhall wrote:the only thing I think I might need to look at is the suggestion you made that it should only delete the ".sample" if another media file exists....
The problem with this is the bug in Sickbeard, the main reason this deletion was integrated in the first place. If only a sample File is in the dir for whatever reason, Sickbeard will in many cases overwrite an existing non sample file with the sample file. The probability that a real file has sample in his his name and is below 200 MB is almost zero.

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests