diff options
author | root <root@noname.(none)> | 2012-10-01 00:08:52 +0200 |
---|---|---|
committer | root <root@noname.(none)> | 2012-10-01 00:08:52 +0200 |
commit | bae977a0c9e55356abd2cfbdc2759df0ceabcdf5 (patch) | |
tree | f932b4bbe67b6341069f05a922904cd4a8982601 | |
download | vdr-scripttools-bae977a0c9e55356abd2cfbdc2759df0ceabcdf5.tar.gz vdr-scripttools-bae977a0c9e55356abd2cfbdc2759df0ceabcdf5.tar.bz2 |
Initial import of croncheck, fskprotect, extrametadata and thumbnail
-rwxr-xr-x | recording-hooks/extrametadata/R10.extrametadata | 50 | ||||
-rwxr-xr-x | recording-hooks/fskprotect/R10.fskprotect | 124 | ||||
-rwxr-xr-x | recording-hooks/thumbnail/R10.thumbnail | 62 | ||||
-rwxr-xr-x | shutdown-hooks/croncheck/croncheck | 43 |
4 files changed, 279 insertions, 0 deletions
diff --git a/recording-hooks/extrametadata/R10.extrametadata b/recording-hooks/extrametadata/R10.extrametadata new file mode 100755 index 0000000..5a489f4 --- /dev/null +++ b/recording-hooks/extrametadata/R10.extrametadata @@ -0,0 +1,50 @@ +#!/bin/sh + +set -u +set -e + +LENGTH_FILE="length.vdr" +CRC_FILE="checksum.md5" + +do_length() { + + [ -e "${1}/index.vdr" ] && vdr-getlength "${1}" || true + [ -e "${1}/index" ] && vdr-getlength "${1}" || true + +} + +do_crc() { + + if [ -e "${1}/index.vdr" ]; then + echo "cd \"${1}\"; tmp=\"\$(tempfile)\"; nice -n 19 md5sum -b [0-9][0-9][0-9].vdr 2> /dev/null 1> \"\${tmp}\" && ([ -d \"${1}\" ] && cp \"\${tmp}\" \"${1}/${CRC_FILE}\" || echo \"directory ${1} moved\"; rm \"\${tmp}\")" | at now + fi + if [ -e "${1}/index" ]; then + echo "cd \"${1}\"; tmp=\"\$(tempfile)\"; nice -n 19 md5sum -b [0-9][0-9][0-9][0-9][0-9].ts 2> /dev/null 1> \"\${tmp}\" && ([ -d \"${1}\" ] && cp \"\${tmp}\" \"${1}/${CRC_FILE}\" || echo \"directory ${1} moved\"; rm \"\${tmp}\")" | at now + fi + +} + +do_move() { + + cp "${1}/${LENGTH_FILE}" "${2}/${LENGTH_FILE}" + cp "${1}/${CRC_FILE}" "${2}/${CRC_FILE}" + +} + + +case "${1}" in + + after|edited) + TARGET_RECORD_DIR="${2}" + do_length "${TARGET_RECORD_DIR}" + do_crc "${TARGET_RECORD_DIR}" + ;; + move) + SOURCE_RECORD_DIR="${2}" + TARGET_RECORD_DIR="${3}" + do_move "${SOURCE_RECORD_DIR}" "${TARGET_RECORD_DIR}" + ;; + +esac + +exit 0 diff --git a/recording-hooks/fskprotect/R10.fskprotect b/recording-hooks/fskprotect/R10.fskprotect new file mode 100755 index 0000000..365344b --- /dev/null +++ b/recording-hooks/fskprotect/R10.fskprotect @@ -0,0 +1,124 @@ +#!/bin/sh + +set -u +set -e + +#set this to your VDR video directory +#BASE_DIR=/srv/video.00 +BASE_DIR=/srv/VDR_VIDEO + +# record hook script to handle the protection.fsk record protection in case of +# the edited|move events +# +# there are two modes for the protection.fsk protection +# 1. the recording are direct protected with an protection.fsk flag file in the +# recording directory +# 2. the recording are indirect protected because an upper directory are +# protected with the protection.fsk +# this script will handle this as follow +# - if the record itself are protected the target record will also protected in +# the same way +# - if the record are protected because an upper directory are protected +# (indirect protection) then +# - the target record will not be direct protected if an upper directory of +# the target are protected, so the record keep its indirect protection status +# - the target record will be direct protected if none of the upper directory +# are protected +# +# ATTENTION! For "edited" this Script need the name of the original recording as +# the third Parameter. +# This is the case if you use vdr >= 1.7.28, but Plugins that call the recording +# "edited" hook need to support this also. +# +# If you found a bug please send me an message + +#Copyright 2012 Keine_Ahnung@vdr-portal.de + +#This script is free software: you can redistribute it and/or modify it under the +#terms of the GNU General Public License as published by the Free Software +#Foundation, either version 3 of the License, or (at your option) any later version. + +#This sCript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +#without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +#PURPOSE. See the GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License along with this script. +#If not, see http://www.gnu.org/licenses/. +################################################################################ +PROTECTION_FILE="protection.fsk" +FSK_NOT=1 +FSK_DIRECT=2 +FSK_INDIRECT=3 + +check_protection() { + + testdir="${1}" + + # direct protection + [ -e "${testdir}/${PROTECTION_FILE}" ] && return ${FSK_DIRECT} + + # indirect protection, "protection.fsk" in upper level directory + testdir="$(dirname "${testdir}")" + while [ "${testdir}" != "${BASE_DIR}" ]; do + [ -e "${testdir}/${PROTECTION_FILE}" ] && return ${FSK_INDIRECT} + testdir="$(dirname "${testdir}")" + # to be sure to not get in endless loop + if [ "${#testdir}" -lt "2" ]; then + printf "Something goes really wrong!\n" 1>&2 + exit 1 + fi + done + # no direct or indirect protection + return ${FSK_NOT} + +} + +do_protection() { + + ret=0 + check_protection "${SOURCE_RECORD_DIR}" || ret=$? + case "${ret}" in + ${FSK_DIRECT}) + # source protection are direct, so set direct protection again + if [ -d "${TARGET_RECORD_DIR}" ]; then + touch "${TARGET_RECORD_DIR}/${PROTECTION_FILE}" + else + printf "Target directory (\"%s\") not found!\n" "${TARGET_RECORD_DIR}" 1>&2 + exit 1 + fi + ;; + ${FSK_INDIRECT}) + ret=0 + check_protection "${TARGET_RECORD_DIR}" || ret=$? + if [ "${ret}" -ne "${FSK_INDIRECT}" ]; then + # source protection are indirect but no indirect protection in target + # dir, so change mode to direct protection + if [ -d "${TARGET_RECORD_DIR}" ]; then + touch "${TARGET_RECORD_DIR}/${PROTECTION_FILE}" + else + printf "Target directory (\"%s\") not found!\n" "${TARGET_RECORD_DIR}" 1>&2 + exit 1 + fi + fi + ;; + esac + +} + + +case "${1}" in + + edited) + SOURCE_RECORD_DIR="${3}" + TARGET_RECORD_DIR="${2}" + do_protection + ;; + move) + SOURCE_RECORD_DIR="${2}" + TARGET_RECORD_DIR="${3}" + do_protection + ;; + +esac + +exit 0 diff --git a/recording-hooks/thumbnail/R10.thumbnail b/recording-hooks/thumbnail/R10.thumbnail new file mode 100755 index 0000000..f9847d4 --- /dev/null +++ b/recording-hooks/thumbnail/R10.thumbnail @@ -0,0 +1,62 @@ +#!/bin/sh + +set -u +set -e + +EPGIMAGESPATH="/var/cache/vdr/epgimages" +EPGIMAGESFORMAT="jpg" +RECORDINGIMAGENAME="thumbnail" + +do_after() { + + if [ -e "${TARGET_RECORD_DIR}/index.vdr" ]; then + INFO="info.vdr" + elif [ -e "${TARGET_RECORD_DIR}/index" ]; then + INFO="info.vdr" + else + return 0 + fi + + EVENTID="$(cat "${TARGET_RECORD_DIR}/${INFO}" | egrep "^E " | cut -d " " -f 2)" + CHANNELID="$(cat "${TARGET_RECORD_DIR}/${INFO}" | egrep "^C " | cut -d " " -f 2)" + + if [ -e "${EPGIMAGESPATH}/${CHANNELID}_${EVENTID}.${EPGIMAGESFORMAT}" ]; then + cp "${EPGIMAGESPATH}/${CHANNELID}_${EVENTID}.${EPGIMAGESFORMAT}" "${TARGET_RECORD_DIR}/${RECORDINGIMAGENAME}.${EPGIMAGESFORMAT}" + fi + + COUNTER=1 + while [ -e "${EPGIMAGESPATH}/${CHANNELID}_${EVENTID}_${COUNTER}.${EPGIMAGESFORMAT}" ]; do + cp "${EPGIMAGESPATH}/${CHANNELID}_${EVENTID}_${COUNTER}.${EPGIMAGESFORMAT}" "${TARGET_RECORD_DIR}/${RECORDINGIMAGENAME}_${COUNTER}.${EPGIMAGESFORMAT}" + COUNTER=$(expr ${COUNTER} + 1) + done + +} + + + +do_edit() { + find "${SOURCE_RECORD_DIR}/" -maxdepth 1 \( -name "${RECORDINGIMAGENAME}.${EPGIMAGESFORMAT}" -o -name "${RECORDINGIMAGENAME}_*.${EPGIMAGESFORMAT}" \) -print0 | xargs -0r cp -t "${TARGET_RECORD_DIR}" +} + + + +case "${1}" in + + after) + TARGET_RECORD_DIR="${2}" + do_after + ;; + edited) + SOURCE_RECORD_DIR="${3}" + TARGET_RECORD_DIR="${2}" + do_edit + ;; + move) + SOURCE_RECORD_DIR="${2}" + TARGET_RECORD_DIR="${3}" + do_edit + ;; + +esac + +exit 0 diff --git a/shutdown-hooks/croncheck/croncheck b/shutdown-hooks/croncheck/croncheck new file mode 100755 index 0000000..f7f9607 --- /dev/null +++ b/shutdown-hooks/croncheck/croncheck @@ -0,0 +1,43 @@ +#!/bin/sh + +SPOOLDIR="/var/spool/cronceck" +TIMEFRAME=60 + + +F="$(basename "$0")" + +# We are /etc/cron.*/00000_croncheck +if [ "$(basename "$0")" = "00000_croncheck" ]; then + crontype="$(basename "$(dirname "$0")")" + mkdir -p "${SPOOLDIR}" + echo "${crontype}" > "${SPOOLDIR}/parts_${crontype}.run" +# We are /etc/cron.*/zzzzz_croncheck +elif [ "$(basename "$0")" = "zzzzz_croncheck" ]; then + crontype="$(basename "$(dirname "$0")")" + mkdir -p "${SPOOLDIR}" + rm -f "${SPOOLDIR}/parts_${crontype}.run" +# We are /usr/sbin/croncheck +elif [ "$(basename "$0")" = "croncheck" ]; then + crontype="$2" + mkdir -p "${SPOOLDIR}" + case "$1" in + start) + echo "${crontype}" > "${SPOOLDIR}/crontab_${crontype}.run" + ;; + stop) + rm -f "${SPOOLDIR}/crontab_${crontype}.run" + ;; + esac +# We are /etc/vdr/shutdown-hooks\S[\d][\d].croncheck +elif [ "${F#*.}" = "croncheck" ]; then + if [ -d "${SPOOLDIR}" ]; then + oldifs=$IFS + IFS=' +' + for file in $(find "${SPOOLDIR}" \( -type f -and -cmin -${TIMEFRAME} \) ); do + echo "ABORT_MESSAGE=\"cron '$(cat $file)' running\"" + exit 1 + done + IFS=$oldifs + fi +fi |