3 Commits

Author SHA1 Message Date
Derek Christensen
42845b8265 Changed default hb_args to match old hardcoded arguments 2017-01-10 23:27:33 -08:00
Derek Christensen
07080fdd9b disable sc2086 2017-01-10 23:21:39 -08:00
Derek Christensen
cf48fec50f Added HB_ARGS for user configurable HandBrake arguments 2017-01-10 23:17:07 -08:00
5 changed files with 20 additions and 166 deletions

View File

@@ -1,123 +0,0 @@
#!/usr/bin/python3
import sys
import argparse
import os
# import re
import subprocess
import logging
import pprint
import time
def entry():
""" Entry to program, parses arguments"""
parser = argparse.ArgumentParser(description='Get type of dvd--movie or tv series')
parser.add_argument('-d', '--devpath', help='Devpath', required=True)
parser.add_argument('-m', '--minlength', help='Minimum Length', default=0, type=int)
parser.add_argument('-x', '--maxlength', help='Maximum Length', default=0, type=int)
parser.add_argument('-a', '--armpath', help='ArmPath', required=True)
parser.add_argument('-r', '--rawpath', help='Rawpath', required=True)
parser.add_argument('-e', '--label', help='Label', required=True)
parser.add_argument('-b', '--handbrakecli', help='HandbrakeCLI', default="HandBrakeCLI")
parser.add_argument('-p', '--hb_preset', help='Handbrake Preset', required=True)
parser.add_argument('-g', '--hb_args', help='Handbrake Arguements', default='')
parser.add_argument('-l', '--logfile', help='Logfile (path/logname)', required=True)
return parser.parse_args()
def log_params():
"""log all entry parameters"""
logging.info("Logging tv_dvd parameters")
logging.info("**** Start tv_dvd.py paramaters *** ")
logging.info("devpath: " + args.devpath)
logging.info("minlength: " + str(args.minlength))
logging.info("maxlength: " + str(args.maxlength))
logging.info("armpath: " + args.armpath)
logging.info("rawpath: " + args.rawpath)
logging.info("handbrakecli: " + args.handbrakecli)
logging.info("hb_preset: " + args.hb_preset)
logging.info("logfile: " + args.logfile)
logging.info("hb_args: " + args.hb_args)
logging.info("*** End of tv_dvd.py parameters ***")
def main():
"""main tv processing function"""
logging.info("Starting TV_DVD processing")
try:
d = subprocess.check_output(["lsdvd", '-Oy', args.devpath]).decode("utf-8")
except subprocess.CalledProcessError as derror:
print("Call to lsdvd failed with code: " + str(derror.returncode), derror.output)
err = "Aborting. Call to lsdvd failed with code: " + str(derror.returncode), derror.output
sys.exit(err)
data = d.replace("lsdvd = ", "", 1)
info = eval(data, {})
# print(info['track'])
#get filesystem in order
ts = round(time.time() * 100)
basepath = os.path.join(args.armpath, args.label + "_" + str(ts))
if not os.path.exists(basepath):
try:
os.makedirs(basepath)
except:
logging.error("Couldn't create the base file path: " + basepath + " Probably a permissions error")
err = "Couldn't create the base file path: " + basepath + " Probably a permissions error"
sys.exit(err)
total = 0
for index, item in enumerate(info['track']):
if item['ix'] > total:
total = item['ix']
logging.info("Found " + str(total) + " tracks.")
for index, item in enumerate(info['track']):
if item['length'] < args.minlength:
#too short
logging.info("Track #" + str(item['ix']) + " of " + str(total) + ". Length (" + str(item['length']) + \
") is less than minimum length (" + str(args.minlength) + "). Skipping")
elif item['length'] > args.maxlength:
#too long
logging.info("Track #" + str(item['ix']) +" of " + str(total) + ". Length (" + str(item['length']) + \
") is greater than maximum length (" + str(args.maxlength) + "). Skipping")
else:
#just right
logging.info("Processing track #" + str(item['ix']) + " of " + str(total) + ". Length is " + str(item['length']) + " seconds.")
filename = os.path.join(basepath, "title_" + str(item['ix']) + ".mkv")
cmd = 'nice {0} -i "{1}" -o "{2}" --preset "{3}" -t {4} {5}>> {6}'.format(
args.handbrakecli,
args.devpath,
filename,
args.hb_preset,
str(item['ix']),
args.hb_args,
args.logfile
)
logging.debug("Sending command: %s", (cmd))
try:
hb = subprocess.check_output(
cmd,
shell=True
).decode("utf-8")
except subprocess.CalledProcessError as hb_error:
err = "Call to hadnbrake failed with code: " + str(hb_error.returncode) + "(" + str(hb_error.output) + ")"
logging.error(err)
sys.exit(err)
args = entry()
#set up logging
logging.basicConfig(filename=args.logfile, format='[%(asctime)s] ARM: %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', \
level=logging.INFO)
log_params()
main()

View File

@@ -16,9 +16,6 @@ GET_VIDEO_TITLE=true
# Note: RIPMETHOD must be set to "mkv" for this feature to work
SKIP_TRANSCODE=false
# Default Video Type. Use this to give ARM a way to handle dvds/bds that aren't identifiable.
# DEFAULT_VIDEOTYPE="series"
#####################
## Directory setup ##
#####################
@@ -49,9 +46,6 @@ LOGLIFE=1
# Minimum length of track for MakeMKV rip (in seconds)
MINLENGTH="600"
# Maximum length of track for MakeMKV rip (in seconds). Set to 0 to disable
MAXLENGTH="0"
# Method of MakeMKV to use for Blu Ray discs. Options are "mkv" or "backup".
# mkv is the normal method of ripping mkv files directly from the DVD
# backup decrypts the dvd and then copies it to the hard drive. This allows HandBrake to apply some of it's
@@ -60,11 +54,6 @@ MAXLENGTH="0"
# DVD's will always default back to the "mkv" mode. If this is set to "backup" then you must also set HandBrake's MAINFEATURE to true.
RIPMETHOD="mkv"
# Additional HandBrake arguments. '--subtitle scan -F --subtitle-burned' will scan for forced foreign language
# audio and burn them into the video
# HB_ARGS="--subtitle scan -F --subtitle-burned"
HB_ARGS="--subtitle scan -F --subtitle-burned"
##########################
## HandBrake Parameters ##
##########################
@@ -87,6 +76,9 @@ HANDBRAKE_CLI=HandBrakeCLI
# However, it does not handle tv shows well at all. You will likely want this value to be false when ripping tv shows.
MAINFEATURE=false
# Additional HandBrake arguments.
HB_ARGS="--subtitle scan -F"
#####################
## Emby Parameters ##
#####################

View File

@@ -26,7 +26,7 @@ def getdvdtype():
except:
year = ""
else:
year = re.sub('[()]', '', year)
year = re.sub('[()]','', year)
try:
dvd_title = dvd_title[0:(dvd_title.rindex('('))].strip()
@@ -49,22 +49,22 @@ def getdvdtype():
dvd_type = callwebservice(dvd_title_clean, "")
# print (dvd_type)
if dvd_type != "fail":
#that means the year is wrong.
if (dvd_type != "fail"):
#that means the year is wrong.
needs_new_year = "true"
if dvd_type == "fail":
if (dvd_type == "fail"):
# second see if there is a hyphen and split it
if dvd_title.find("-") > -1:
if (dvd_title.find("-") > -1):
dvd_title_slice = dvd_title[:dvd_title.find("-")]
dvd_title_slice = cleanupstring(dvd_title_slice)
dvd_title_slice =cleanupstring(dvd_title_slice)
dvd_type = callwebservice(dvd_title_slice)
# if still fail, then try slicing off the last word in a loop
while dvd_type == "fail" and dvd_title_clean.count('+') > 0:
dvd_title_clean = dvd_title_clean.rsplit('+', 1)[0]
dvd_type = callwebservice(dvd_title_clean)
if needs_new_year == "true":
#pass the new year back to bash to handle
global new_year

View File

@@ -84,7 +84,6 @@ if [ "$ID_FS_TYPE" == "udf" ]; then
fi
else
VIDEO_TYPE="unknown"
fi
echo "got to here"
@@ -93,24 +92,7 @@ if [ "$ID_FS_TYPE" == "udf" ]; then
echo "video type is ${VIDEO_TYPE}"
umount "/mnt/$DEVNAME"
if [ $VIDEO_TYPE = "series" ] && [ "$ID_CDROM_MEDIA_DVD" = "1" ]; then
echo "Processing TV series. Calling tv_dvd.py" >> "$LOG"
STR="/opt/arm/arm/tv_dvd.py -d "\"${DEVNAME}\"" -m ${MINLENGTH} -x ${MAXLENGTH} -a "\"${ARMPATH}\"" -r "\"${RAWPATH}\"" -e "\"${ID_FS_LABEL}\"" -b "\"${HANDBRAKE_CLI}\"" -p "\"${HB_PRESET}\"" -g "\"${HB_ARGS}\"" -l "\"${LOG}\"""
echo "Sending command ${STR}"
eval "${STR}" 2>> "$LOG"
eject "$DEVNAME"
elif
[ "$VIDEO_TYPE" = "unknown" ] && [ "$DEFAULT_VIDEOTYPE" == "series" ] && [ "$ID_CDROM_MEDIA_DVD" = "1" ]; then
echo "Video type is 'unknown' and default video type is series. Processing TV series. Calling tv_dvd.py" >> "$LOG"
STR="/opt/arm/arm/tv_dvd.py -d "\"${DEVNAME}\"" -m ${MINLENGTH} -x ${MAXLENGTH} -a "\"${ARMPATH}\"" -r "\"${RAWPATH}\"" -e "\"${ID_FS_LABEL}\"" -b "\"${HANDBRAKE_CLI}\"" -p "\"${HB_PRESET}\"" -g "\"${HB_ARGS}\"" -l "\"${LOG}\"""
echo "Sending command ${STR}"
eval "${STR}" 2>> "$LOG"
eject "$DEVNAME"
else
echo "Sending to video_rip queue" >> "$LOG"
/opt/arm/video_rip.sh "$VIDEO_TITLE" "$HAS_NICE_TITLE" "$VIDEO_TYPE" "$LOG"
fi
/opt/arm/video_rip.sh "$VIDEO_TITLE" "$HAS_NICE_TITLE" "$VIDEO_TYPE" "$LOG"
else
umount "/mnt/$DEVNAME"
echo "identified udf as data" >> "$LOG"
@@ -120,7 +102,6 @@ if [ "$ID_FS_TYPE" == "udf" ]; then
fi
else
echo "ARM_CHECK_UDF is false, assuming udf is video" >> "$LOG"
/opt/arm/video_rip.sh "$LOG"
fi

View File

@@ -36,7 +36,8 @@ TIMESTAMP=$5
mv "$SRC"/* "$DEST"/ >> "$LOG"
elif [ "$RIPMETHOD" = "backup" ] && [ "$MAINFEATURE" = true ] && [ "$ID_CDROM_MEDIA_BD" = "1" ]; then
echo "Transcoding BluRay main feature only." >> "$LOG"
$HANDBRAKE_CLI -i "$SRC" -o "$DEST/$LABEL.$DEST_EXT" --main-feature --preset="$HB_PRESET" --subtitle scan -F 2>> "$LOG"
# shellcheck disable=SC2086
$HANDBRAKE_CLI -i "$SRC" -o "$DEST/$LABEL.$DEST_EXT" --main-feature --preset="$HB_PRESET" $HB_ARGS 2>> "$LOG"
rmdir "$SRC"
elif [ "$RIPMETHOD" = "backup" ] && [ "$MAINFEATURE" = false ] && [ "$ID_CDROM_MEDIA_BD" = "1" ]; then
echo "Transcoding BluRay all titles above minlength." >> "$LOG"
@@ -58,7 +59,8 @@ TIMESTAMP=$5
echo "Title length is $SEC seconds." >> "$LOG"
if [ $SEC -gt "$MINLENGTH" ]; then
echo "HandBraking title $TITLE"
$HANDBRAKE_CLI -i "$SRC" -o "$DEST/$LABEL-$TITLE.$DEST_EXT" --min-duration="$MINLENGTH" -t "$TITLE" --preset="$HB_PRESET" --subtitle scan -F 2 >> "$LOG"
# shellcheck disable=SC2086
$HANDBRAKE_CLI -i "$SRC" -o "$DEST/$LABEL-$TITLE.$DEST_EXT" --min-duration="$MINLENGTH" -t "$TITLE" --preset="$HB_PRESET" $HB_ARGS 2 >> "$LOG"
# Check for main title and rename
if [ "$MAINTITLENO" = "$TITLE" ] && [ "$HAS_NICE_TITLE" = true ]; then
@@ -73,7 +75,8 @@ TIMESTAMP=$5
elif [ "$MAINFEATURE" = true ] && [ "$ID_CDROM_MEDIA_DVD" = "1" ]; then
echo "Transcoding DVD main feature only." >> "$LOG"
# echo "$HANDBRAKE_CLI -i $DEVNAME -o \"${DEST}/${LABEL}.${DEST_EXT}\" --main-feature --preset="${HB_PRESET}" --subtitle scan -F 2" >> $LOG
$HANDBRAKE_CLI -i "$DEVNAME" -o "${DEST}/${LABEL}.${DEST_EXT}" --main-feature --preset="${HB_PRESET}" --subtitle scan -F 2>> "$LOG"
# shellcheck disable=SC2086
$HANDBRAKE_CLI -i "$DEVNAME" -o "${DEST}/${LABEL}.${DEST_EXT}" --main-feature --preset="${HB_PRESET}" $HB_ARGS 2>> "$LOG"
eject "$DEVNAME"
else
echo "Transcoding all files." >> "$LOG"
@@ -86,7 +89,8 @@ TIMESTAMP=$5
filename=${filename%.*}
echo "Transcoding file $FILE" >> "$LOG"
$HANDBRAKE_CLI -i "$SRC/$FILE" -o "$DEST/$filename.$DEST_EXT" --preset="$HB_PRESET" --subtitle scan -F 2>> "$LOG"
# shellcheck disable=SC2086
$HANDBRAKE_CLI -i "$SRC/$FILE" -o "$DEST/$filename.$DEST_EXT" --preset="$HB_PRESET" $HB_ARGS 2>> "$LOG"
rm "$SRC/$FILE"
done
rmdir "$SRC"