diff options
author | Dimitar Petrovski <dimeptr@gmail.com> | 2012-10-30 11:40:27 +0100 |
---|---|---|
committer | Dimitar Petrovski <dimeptr@gmail.com> | 2012-10-30 11:40:27 +0100 |
commit | f1717857da8db98772c7a807befe2426ff2ed133 (patch) | |
tree | cacafe715187e1f1074ac7ba9be4847dc29c2b2d /scripts/makeequiv.sh | |
parent | d723bdc772b60190af39a256bffc33c27cfb9575 (diff) | |
download | vdr-plugin-eepg-f1717857da8db98772c7a807befe2426ff2ed133.tar.gz vdr-plugin-eepg-f1717857da8db98772c7a807befe2426ff2ed133.tar.bz2 |
added helper scripts for generation of eepg.equiv
updated documentation
Diffstat (limited to 'scripts/makeequiv.sh')
-rwxr-xr-x | scripts/makeequiv.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/makeequiv.sh b/scripts/makeequiv.sh new file mode 100755 index 0000000..1be3e80 --- /dev/null +++ b/scripts/makeequiv.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +equiv_file="eepg.equiv" + +usage() { + echo + [[ "$@" ]] && echo -e "ABORTED! $@\n" + echo -e "usage: ${0##*/} [channels.conf] [listsources|source to map epg from] <matchname>" + echo -e " * the 3rd argument is optional. if its \"matchname\", channel name matching is required for a positive match.\n" + exit +} + +getsources() { awk -F: '{print $4}' "$1" |sort -V |uniq; } +listsources() { getsources "$1"; exit; } + +(($# < 2)) && usage +[[ -e "$1" ]] || usage "$1 not found" +[[ "$2" == "listsources" ]] && listsources "$1" +[[ $(getsources "$1" |grep "$2$") ]] || usage "$2 is not a source in $1" +[[ "$3" == "matchname" ]] && match_name=1 || match_name=0 +[[ -e "$equiv_file" ]] && rm "$equiv_file" +echo +tput sc +OLDIFS=$IFS; IFS=$'\n' +for i in $(awk -F: -v var="$2" '$4==var' "$1"); do + matched=0 + mapto_name=" ${i%%:*}" + mapto_sid=$(awk -F: '{print $10}' <<<"$i") + mapto_line=$(awk -F: '{print $4"-"$11"-"$12"-"$10"-"$13}' <<<"$i") + mapto_source=$(awk -F: '{print $4}' <<<"$i") + for j in $(awk -F: -v var1="$2" -v var2="$mapto_sid" '$4!=var1 && $10==var2' "$1"); do + mapfrom_source=$(awk -F: '{print $4}' <<<"$j") + mapfrom_line=$(awk -F: '{print $4"-"$11"-"$12"-"$10"-"$13}' <<<"$j") + matched=1 + (($match_name)) && { + [[ " ${j%%:*}" == "$mapto_name" ]] || matched=0 + } || unset mapto_name + done + (($matched)) && { + ((matchcount++)) + outline="$mapfrom_line $mapto_line$mapto_name" + echo "$outline" >>"$equiv_file" + } || { + ((unmatchcount++)) + array+=( "$i" ) + unset outline + } + tput rc + tput el + echo "$outline" + echo -n "matched: $matchcount - unmatched: $unmatchcount" +done +IFS=$OLDIFS +echo -e "\n" +((${#array[@]} > 0)) && for i in "${array[@]}"; do echo "NO MATCH: $i"; done +echo "wrote $equiv_file ($matchcount entries)." |