diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/README | 28 | ||||
-rwxr-xr-x | scripts/extract_vdr_chan_ids.pl | 38 | ||||
-rwxr-xr-x | scripts/makeequiv.sh | 56 |
3 files changed, 122 insertions, 0 deletions
diff --git a/scripts/README b/scripts/README new file mode 100644 index 0000000..22e2835 --- /dev/null +++ b/scripts/README @@ -0,0 +1,28 @@ +extract_vdr_chan_ids.pl +The script extract_vdr_chan_ids.pl can be used along with grep to extract the IDs +of required channel i.e.: + +USAGE: + extract_vdr_chan_ids.pl [/path/to/channels.conf] + +EXAMPES: + extract_vdr_chan_ids.pl /path/to/channels.conf | grep -i Chanel Name + +makeequiv.sh thanks to VDR User +The makeequiv.sh bash script can be used to generate an eepg.equiv +file based on SID matching. You may optionally require channel name +matching as well. + +USAGE: + makeequiv.sh [channels.conf] [listsources|source to map epg from] <matchname> + +EXAMPES: + makequiv.sh /video/channels.conf listsources + * shows a list of all available sources in channels.conf + + makeequiv.sh /video/channels.conf S72.7W + * map epg from S72.7W channels based on SID match + + makeequiv.sh /video/channels.conf S72.7W matchname + * map epg from S72.7W channels based on SID and channel name match + diff --git a/scripts/extract_vdr_chan_ids.pl b/scripts/extract_vdr_chan_ids.pl new file mode 100755 index 0000000..e40bbb9 --- /dev/null +++ b/scripts/extract_vdr_chan_ids.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w +# +# extract VDR channel ID's from channels conf +# + +use strict; +use File::Path; + +my $channelsConf = "../channels.conf"; +my $Usage = qq{ +Usage: $0 (default: ../channels.conf) + $0 /path/to/channels.conf +}; + +$channelsConf = "@ARGV" if @ARGV; + +#my $file; +open(MYINPUTFILE, "<$channelsConf") or die("Could not open $channelsConf" . $Usage); + +foreach (<MYINPUTFILE>) +{ + chomp; + if ( /^:.*/ ) + { + print $_ . "\n"; + next; + } + + my($line) = $_; + + my(@tokens) = split(":"); + + my($chanID) = "$tokens[3]-$tokens[10]-$tokens[11]-$tokens[9] $tokens[0]"; + + print $chanID . "\n" + +} + 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)." |