summaryrefslogtreecommitdiff
path: root/contrib/vdr-getcountryfrominfo.sh
blob: ae4d3d0c739b9288404a0080165943c24c547505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

# old info file
infofile="$1/info.vdr"

# use new info file if available
if [ -e "$1/info" ]; then
  infofile="$1/info"
fi

# try "Land: XXX 2010" first
country=`cat "${infofile}" | grep '|Land:' | sed -e 's/.*|Land: \([^ ]*\).*/\1/g'`
#echo "country1:>${country}<"

if [ "$country" == "" ]; then
  country=`cat ${infofile} | grep '|Country:' | sed -e 's/.*|Country: \([^|]*\).*/\1/g'`
  #echo "country2:>${country}<"
fi

if [ "$country" == "" ]; then
  country=`cat ${infofile} | grep -e '^D .*' | sed -e 's/^D [^, ]*[, ]*\([A-Z/]*\).*/\1/g'`
  #echo "country3:>${country}<"
fi

if [ ! "$country" == "" ]; then
  echo "${country}" > "$1/country.vdr"
  echo "${country}"
fi