[Python] rescepy - automated ReScene reconstruction.

Come up with a useful post-processing script? Share it here!
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Oh. The way it's set atm you'll need the codec in NZB name. (eg. Movie.Name.x264.BluRay-sweetie)

lines 526-530

Code: Select all

if echo "$CWD" | grep -qie "xvid\|divx\|x264\|h264\|wmv\|mp4"; then
if echo "$CWD" | grep -qie "sample*fix\|sub*fix\|dir*fix"; then ##temporary needs propering,
echo_error ""$CWD" is not compatible release format. Exiting."; exit
else release_info; fi; echo_process "Processing: "$CWD".."
else echo_error ""$CWD" is not compatible release format. Exiting."; exit; fi
change to:

Code: Select all

release_info; echo_process "Processing: "$CWD".."
Also, for ReScene error, set the 'SRREXE' path at top of script to a location you have write access to. (can be /tmp/srr.exe), it should offer to update if not found. (answer 'y') - leave 'srr.exe' on the end.
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

##default file locations
SRREXE="/tmp/srr.exe"
SRSEXE="/tmp/srs.exe"
BADCRC="/mnt/head/.sabnzbd/downloads/failed/bad.crc"
LOCALDB="../.rescene"

still get @@ ReScene(srr.exe) is out of date, upgrade before continuing.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Oh flip. Sorry. I just realised that the file location variable is $2 in the script. SAB passes out "$2" as NZB name.

Do this. (and it will work, I promise.)

Call it externally with another script, like so:

Code: Select all

#!/bin/bash

cd "$1"

if [ "$5" = "x264-tv" ]; then
bash "/mnt/head/.sabnzbd/scripts/scenesort.sh" -m; fi

if [ "$5" = "xvid-tv" ]; then
bash "/mnt/head/.sabnzbd/scripts/scenesort.sh" -bj; fi
Paste the above into an empty file,
chmod -c +x filename.sh,
set the above as SAB post-processing.
Change paths to scenesort.sh (fileame doesn't matter) accordingly. Leave the -m option on the end.
Switch "x264-tv" to the name of your x264 category.
(you'll also need to create custom categories if still using default - one for x264 another for xvid.)


edit: I changed the way ReScene version check works, so download latest script version before running.


You'll have to set WGET_PREFIX as "" if torsocks is not installed, that'll explain why it didn't auto update.


That was my fault, sorry.
Last edited by sweetie on November 25th, 2009, 5:36 am, edited 1 time in total.
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

Switch "x264-tv" to the name of your x264 category.
(you'll also need to create custom categories if still using default - one for x264 another for xvid.)


i am abit confused atm. im not sure if that'll work for me, i use alot of different categories for tv shows like the show names and so. I have like like 30 different categories.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Well I updated again. For the time being, you could simply have:

Code: Select all

#!/bin/bash
cd "$1"
bash /path/to/script.sh -m
Set the above as post-processor. and set it in SAB for all MKV downloads. (unless it's possible to set switches in SAB, not sure if it is.)

edit: updated again. Should run without any mods now.
Last edited by sweetie on November 25th, 2009, 11:47 am, edited 1 time in total.
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

crc@slavebox:~/NZB/Scripts$ bash mkv.sh
: command not foundts/mkv2m2ts.sh: line 2:
: command not foundts/mkv2m2ts.sh: line 3:
: command not foundts/mkv2m2ts.sh: line 9:
: command not foundts/mkv2m2ts.sh: line 10:
: command not foundts/mkv2m2ts.sh: line 16:
: command not foundts/mkv2m2ts.sh: line 17:
: command not foundts/mkv2m2ts.sh: line 19:
: command not foundts/mkv2m2ts.sh: line 22:
: command not foundts/mkv2m2ts.sh: line 26:
: command not foundts/mkv2m2ts.sh: line 43:
: command not foundts/mkv2m2ts.sh: line 44:
: command not foundts/mkv2m2ts.sh: line 50:
: command not foundts/mkv2m2ts.sh: line 52:
: command not foundts/mkv2m2ts.sh: line 53:
/home/crc/NZB/Scripts/mkv2m2ts.sh: line 63: syntax error near unexpected token `'
'home/crc/NZB/Scripts/mkv2m2ts.sh: line 63: `which_all () {

seems like al the errors are on blank lines
what am i doing wrong now?
Last edited by stabu on November 25th, 2009, 12:00 pm, edited 1 time in total.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Type:

Code: Select all

which which
in terminal. Seems it didn't install correctly.


Also is Ubuntu up to date? Could be an issue with bash.
Last edited by sweetie on November 25th, 2009, 12:11 pm, edited 1 time in total.
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

crc@slavebox:~$ which which
/usr/local/bin/which

yeah everythign is updated.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Are both scripts executable? (chmod +x filename.sh)
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

yup
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Well. I have no idea.

This is the remux function seperated from original:

Can run it directly from SAB. (in mkv.sh)

Code: Select all

#!/bin/bash

echo_process () { echo -e "\e[1;33m##\e[0;39;49m" "$1"; }
echo_prompt () { echo -e "\e[1;34m??\e[0;39;49m" "$1"; }
echo_success () { echo -e "\e[1;32m>>\e[0;39;49m" "$1"; }
echo_error () { echo -e "\e[1;31m@@\e[0;39;49m" "$1"; }

CWD="${PWD##*/}"
SAVE_MUX_INPUT="0"

subfont="/usr/share/fonts/TTF/DejaVuSans.ttf"
if [ ! -f "$subfont" ]; then echo_error "Font '"$subfont"' not found. Exiting."; exit; fi

allmkv=`find -type f -name "*.mkv" | wc -l`

inputcount="0"
for input in *.mkv; do
if [ -f "$input" ]; then

((inputcount++))
inputfs=`stat -c %s "$input"`

inputbase="${input%.*}"
if [ "$inputfs" -gt "104857600" -a "$allmkv" -le "1" ]; then output="$CWD.m2ts"
elif [ "$inputfs" -lt "104857600" ]; then output="$CWD-Sample-$inputfs.m2ts"
elif [ "$inputfs" -gt "104857600" -a "$allmkv" -ge "2" ]; then output="$CWD-$inputcount.m2ts"; fi

mkvinfo "$input" > "mkvinfo.log"

lang=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -ie "Language: \(und\|eng\|fre\|ger\|jpn\)" | head -n 1 | cut -d' ' -f5`

mpeg4_track=`grep -i "Codec ID: V_MPEG4/ISO/AVC" -B10 "mkvinfo.log" | grep -i "Track number:" | cut -d' ' -f6`

audio_codec=`grep -i "Track type: audio" -B2 -C9 "mkvinfo.log" | grep -ie "A_AC3\|A_DTS\|A_AAC\|A_MP3" | head -n 1 | cut -d' ' -f6`
audio_track=`grep -i "Codec ID: $audio_codec" -B10 -C3 "mkvinfo.log" | grep -i "Language: $lang" -B13 | grep -i "Track number:" | cut -d' ' -f6`

subs_track=`grep -i "S_TEXT/UTF8" -B10 -C3 "mkvinfo.log" | grep -i "Language: $lang" -B13  | grep -i "Track number:" | cut -d' ' -f6`


if [ "$mpeg4_track" -gt "0" ]; then echo "MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr" >> "$inputbase.meta"
echo "V_MPEG4/ISO/AVC, $input, level=4.1, insertSEI, contSPS, track=$mpeg4_track, lang=$lang" >> "$inputbase.meta"
else echo "Incompatible video codec found. Exiting."; exit; fi

 
if [ "$audio_codec" = "A_AC3" -o "$audio_codec" = "A_AAC" -o "$audio_codec" = "A_MP3" ]; then
	echo "$audio_codec, $input, track=$audio_track, lang=$lang" >> "$inputbase.meta"
elif [ "$audio_codec" = "A_DTS" ]; then
	mkvextract tracks "$input" "$audio_track":"$inputbase.dts"
	dcadec -o wavall "$inputbase.dts" | aften -v 0 -readtoeof 1 - "$inputbase.ac3"
	echo "A_AC3, $inputbase.ac3, track=$audio_track, lang=$lang" >> "$inputbase.meta"
else echo_error "Incomptible audio codec found. Exiting."; exit; fi

if [ "$subs_track" != "" ]; then if [ "$mpeg4_track" -lt "$audio_track" ]; then
fps=`grep "Frame rate" "mkvinfo.log" | sed -n 1p | cut -d'(' -f2 | cut -d' ' -f1`; else
fps=`grep "Frame rate" "mkvinfo.log" | sed -n 2p | cut -d'(' -f2 | cut -d' ' -f1`; fi
if [ "$fps" = "" ]; then fps="23.976"; fi ##this isn't ideal, though few releases contain fps field.
width=`grep "Pixel width:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
height=`grep "Pixel height:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
echo "S_TEXT/UTF8, "$input", font-name="$subfont", font-size="65", font-color="0x00ffffff", bottom-offset="24", font-border="2", text-align="center", video-width="$width", video-height="$height", fps="$fps", track="$subs_track", lang="$subs_lang"" >> "$inputbase.meta"
fi
	echo_process "Attempting to mux: $input"
	tsMuxeR "$inputbase.meta" "$output" > "tsMuxeR.log"

	if grep -q "Mux successful complete." "tsMuxeR.log"; then echo_success "Mux successful complete."
	else echo_error "Error muxing: "$input""; exit; fi

	if [ "$SAVE_MUX_INPUT" = "0" ]; then rm -f "$input"; fi

	for tmp in "mkvinfo.log" "tsMuxeR.log" "$inputbase.meta" "$inputbase.dts" "$inputbase.ac3"; do
	[ -f "$tmp" ] || continue
	rm -f "$tmp"; done

else echo_error "No MKVs found. Unrared?"; fi

done

Let me know how it goes.
Last edited by sweetie on November 25th, 2009, 1:13 pm, edited 1 time in total.
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

Stage Unrar
  [DEL-INFO] the.middle.s01e08.720p.hdtv.x264-2hd => Deleted 12 file(s)
  [RAR-INFO] the.middle.s01e08.720p.hdtv.x264-2hd => Unpacked 1 files/folders in 21.4s
Stage UserScript
  [USER-SCRIPT] => Running user script /home/crc/NZB/Scripts/test.sh

External processing by /home/crc/NZB/Scripts/test.sh:
-e \e[1;31m@@\e[0;39;49m No MKVs found. Unrared?
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Flippin' flip.

Try:

edit: see below.

(also might be a good idea to remove the filenames from your post. - bannable offence.)
Last edited by sweetie on November 25th, 2009, 1:58 pm, edited 1 time in total.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by sweetie »

Actually: (needed: cd "$1", the first script)

Code: Select all

#!/bin/bash

cd "$1"

echo_process () { echo -e "\e[1;33m##\e[0;39;49m" "$1"; }
echo_prompt () { echo -e "\e[1;34m??\e[0;39;49m" "$1"; }
echo_success () { echo -e "\e[1;32m>>\e[0;39;49m" "$1"; }
echo_error () { echo -e "\e[1;31m@@\e[0;39;49m" "$1"; }

CWD="${PWD##*/}"
SAVE_MUX_INPUT="0"

subfont="/usr/share/fonts/TTF/DejaVuSans.ttf"
if [ ! -f "$subfont" ]; then echo_error "Font '"$subfont"' not found. Exiting."; exit; fi

allmkv=`find -type f -name "*.mkv" | wc -l`

inputcount="0"
for input in *.mkv; do
if [ -f "$input" ]; then

((inputcount++))
inputfs=`stat -c %s "$input"`

inputbase="${input%.*}"
if [ "$inputfs" -gt "104857600" -a "$allmkv" -le "1" ]; then output="$CWD.m2ts"
elif [ "$inputfs" -lt "104857600" ]; then output="$CWD-Sample-$inputfs.m2ts"
elif [ "$inputfs" -gt "104857600" -a "$allmkv" -ge "2" ]; then output="$CWD-$inputcount.m2ts"; fi

mkvinfo "$input" > "mkvinfo.log"

lang=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -ie "Language: \(und\|eng\|fre\|ger\|jpn\)" | head -n 1 | cut -d' ' -f5`

mpeg4_track=`grep -i "Codec ID: V_MPEG4/ISO/AVC" -B10 "mkvinfo.log" | grep -i "Track number:" | cut -d' ' -f6`

audio_codec=`grep -i "Track type: audio" -B2 -C9 "mkvinfo.log" | grep -ie "A_AC3\|A_DTS\|A_AAC\|A_MP3" | head -n 1 | cut -d' ' -f6`
audio_track=`grep -i "Codec ID: $audio_codec" -B10 -C3 "mkvinfo.log" | grep -i "Language: $lang" -B13 | grep -i "Track number:" | cut -d' ' -f6`

subs_track=`grep -i "S_TEXT/UTF8" -B10 -C3 "mkvinfo.log" | grep -i "Language: $lang" -B13  | grep -i "Track number:" | cut -d' ' -f6`


if [ "$mpeg4_track" -gt "0" ]; then echo "MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr" >> "$inputbase.meta"
echo "V_MPEG4/ISO/AVC, $input, level=4.1, insertSEI, contSPS, track=$mpeg4_track, lang=$lang" >> "$inputbase.meta"
else echo "Incompatible video codec found. Exiting."; exit; fi

 
if [ "$audio_codec" = "A_AC3" -o "$audio_codec" = "A_AAC" -o "$audio_codec" = "A_MP3" ]; then
	echo "$audio_codec, $input, track=$audio_track, lang=$lang" >> "$inputbase.meta"
elif [ "$audio_codec" = "A_DTS" ]; then
	mkvextract tracks "$input" "$audio_track":"$inputbase.dts"
	dcadec -o wavall "$inputbase.dts" | aften -v 0 -readtoeof 1 - "$inputbase.ac3"
	echo "A_AC3, $inputbase.ac3, track=$audio_track, lang=$lang" >> "$inputbase.meta"
else echo_error "Incomptible audio codec found. Exiting."; exit; fi

if [ "$subs_track" != "" ]; then if [ "$mpeg4_track" -lt "$audio_track" ]; then
fps=`grep "Frame rate" "mkvinfo.log" | sed -n 1p | cut -d'(' -f2 | cut -d' ' -f1`; else
fps=`grep "Frame rate" "mkvinfo.log" | sed -n 2p | cut -d'(' -f2 | cut -d' ' -f1`; fi
if [ "$fps" = "" ]; then fps="23.976"; fi ##this isn't ideal, though few releases contain fps field.
width=`grep "Pixel width:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
height=`grep "Pixel height:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
echo "S_TEXT/UTF8, "$input", font-name="$subfont", font-size="65", font-color="0x00ffffff", bottom-offset="24", font-border="2", text-align="center", video-width="$width", video-height="$height", fps="$fps", track="$subs_track", lang="$subs_lang"" >> "$inputbase.meta"
fi
	echo_process "Attempting to mux: $input"
	tsMuxeR "$inputbase.meta" "$output" > "tsMuxeR.log"

	if grep -q "Mux successful complete." "tsMuxeR.log"; then echo_success "Mux successful complete."
	else echo_error "Error muxing: "$input""; exit; fi

	if [ "$SAVE_MUX_INPUT" = "0" ]; then rm -f "$input"; fi

	for tmp in "mkvinfo.log" "tsMuxeR.log" "$inputbase.meta" "$inputbase.dts" "$inputbase.ac3"; do
	[ -f "$tmp" ] || continue
	rm -f "$tmp"; done

else echo_error "No MKVs found. Unrared?"; fi

done
stabu
Jr. Member
Jr. Member
Posts: 64
Joined: December 10th, 2008, 10:02 pm

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Post by stabu »

lol almost there

External processing by /home/crc/NZB/Scripts/test.sh:
[1;33m## [0;39;49m Attempting to mux: the.middle.s01e08.720p.hdtv.x264-2hd.mkv
[1;31m@@ [0;39;49m Error muxing: the.middle.s01e08.720p.hdtv.x264-2hd.mkv

pretty sure remuxed is installed right.
Post Reply