Hi *,
keine Ahnung wieder mal, ob Jemand das brauchen kann, aber ich habe mein Script noch weiter getuned, das bei Verwendung in der epgsearchuservars.conf Benutzer definierte Variablen berechnet.
Verbesserungs- oder Erweiterungsvorschläge nehme ich gerne!
Code
%rec_template%=system(/etc/vdr/plugins/epgsearch/epgsearch_mkrecording_user,--title=%title% --subtitle=%subtitle% --year=%year% --season_no=%nummer der staffel% --episode_no=%nummer der episode% --episode_name=%name der episode% --season_no_tvsp=%staffel tvsp% --episode_no_tvsp=%folge tvsp% --episode_name_tvsp=%episode%)
%rec_template_notitle%=system(/etc/vdr/plugins/epgsearch/epgsearch_mkrecording_user_notitle,--subtitle=%subtitle% --year=%year% --season_no=%nummer der staffel% --episode_no=%nummer der episode% --episode_name=%name der episode% --season_no_tvsp=%staffel tvsp% --episode_no_tvsp=%folge tvsp% --episode_name_tvsp=%episode%)
Bash
#!/bin/bash
# ======================================================================
#
# script to create epgsearch user variables
# for use in epgsearchuservars.conf
#
# rev. 0.01 - 15.08.2024 - Michael Hirmke (development@mike.franken.de)
# - first public version
#
# rev. 0.02 - 19.08.2024 - Michael Hirmke (development@mike.franken.de)
# - restructured building of subtitle_out
#
# ======================================================================
# epgsearch_mkrecording
# Usage:
# --title=%title%
# --subtitle=%subtitle%
# --year=%year%
# --season_no=%nummer der staffel%
# --episode_no=%nummer der episode%
# --episode_name=%name der episode%
# --season_no_tvsp=%staffel tvsp%
# --episode_no_tvsp=%folge tvsp%
# --episode_name_tvsp=%episode%
# set -x
function mangle() {
in="$1"
echo "$in" \
| sed -r \
-e "s/[\"\'\%\?]//g" \
-e "s/[:\/]+/_-_/g" \
-e "s/\s+/_/g" \
-e "s/_+/_/g"
} # // end function mangle( .. )
PARMS=$( /usr/bin/getopt --options '' --longoptions ' \
title:,
subtitle:,
year:,
season_no:,
episode_no:,
episode_name:,
season_no_tvsp:,
episode_no_tvsp:,
episode_name_tvsp:
' \
-- "$@" \
)
[ $? -eq 0 ] || {
echo "Incorrect options provided"
exit 1
}
eval set -- "$PARMS"
unset PARMS
while true; do
case "$1" in
'--title') title="$2"; shift 2 ;;
'--subtitle') subtitle="$2"; shift 2 ;;
'--year') year="$2"; shift 2 ;;
'--season_no') season_no="$2"; shift 2 ;;
'--episode_no') episode_no="$2"; shift 2 ;;
'--episode_name') episode_name="$2"; shift 2 ;;
'--season_no_tvsp') season_no_tvsp="$2"; shift 2 ;;
'--episode_no_tvsp') episode_no_tvsp="$2"; shift 2 ;;
'--episode_name_tvsp') episode_name_tvsp="$2"; shift 2 ;;
'--') shift; break ;;
esac
done
template_type=$( \
basename "$0" \
| sed -r -e "s/^epgsearch_mkrecording_(.+)$/\1/" \
)
# build episode string
_season_no="$season_no"
test -z "$_season_no" && _season_no="$season_no_tvsp"
test -z "$_season_no" && _season_no="$year"
_episode_no="$episode_no"
test -z "$_episode_no" && _episode_no="$episode_no_tvsp"
# build subtitle for output
_season_no="$season_no"
test -z "$_season_no" && _season_no="$season_no_tvsp"
test -z "$_season_no" && _season_no="$year"
_episode_no="$episode_no"
test -z "$_episode_no" && _episode_no="$episode_no_tvsp"
subtitle_out="$subtitle" # may be empty
if test -n "$_season_no" -a -n "$_episode_no"; then # {
_episode_name="$episode_name_tvsp"
test -z "$_episode_name" && _episode_name="$episode_name"
test -z "$_episode_name" && _episode_name="$subtitle_out"
subtitle_out=$( \
printf "%02dx%02d_-_%s" "$_season_no" "$_episode_no" "$_episode_name" \
)
fi # }
subtitle_out=${subtitle_out:0:70}
subtitle_out=$( mangle "$subtitle_out" )
recording_out=""
case "$template_type" in
user)
# build title for output
# (only for this case, where title should be added)
title_out=""
test -n "$title" \
&& title_out=$( mangle "$title" )
# concat recording string for output
test -n "$title_out" \
&& recording_out="$title_out"
_to=$( echo "$title_out" | sed -r -e "s/[^a-z0-9]+//ig" )
_sto=$( echo "$subtitle_out" | sed -r -e "s/[^a-z0-9]+//ig" )
subadd=0
if test -n "$_to" -a -n "$_sto"; then # {
case "$_to" in
*${_sto}|*${_sto}*|${_sto}*) ;;
*)
case "$_sto" in
*${_to}|*${_to}*|${_to}*) ;;
*) subadd=1 ;; # only if they are not partially identical
esac
;;
esac
fi # }
test $subadd -eq 1 \
&& recording_out="${recording_out}_-_${subtitle_out}"
;;
user_notitle)
# set recording string for output
recording_out="$subtitle_out"
;;
esac
echo "$recording_out";
Display More
Ciao.
Michael.