BUNDLES-yes += data/conf
BUNDLES-${CONFIG_DVBSCAN} += data/dvb-scan
BUNDLES = $(BUNDLES-yes)
+ALL-$(CONFIG_DVBSCAN) += check_dvb_scan
#
# Add-on modules
#
# Default
-all: ${PROG}
+all: $(ALL-yes) ${PROG}
# Special
.PHONY: clean distclean check_config reconfigure
$(BUILDDIR)/bundle.c:
@mkdir -p $(dir $@)
$(MKBUNDLE) -o $@ -d ${BUILDDIR}/bundle.d $(BUNDLE_FLAGS) $(BUNDLES:%=$(ROOTDIR)/%)
+
+# linuxdvb git tree
+$(ROOTDIR)/data/dvb-scan/.stamp:
+ @echo "Receiving data/dvb-scan/dvb-t from http://linuxtv.org/git/dtv-scan-tables.git"
+ @rm -rf $(ROOTDIR)/data/dvb-scan/*
+ @$(ROOTDIR)/support/getmuxlist $(ROOTDIR)/data/dvb-scan
+ @touch $(ROOTDIR)/data/dvb-scan/.stamp
+
+.PHONY: check_dvb_scan
+check_dvb_scan: $(ROOTDIR)/data/dvb-scan/.stamp
+
+# dvb-s / enigma2 / satellites.xml
+$(ROOTDIR)/data/dvb-scan/dvb-s/.stamp: $(ROOTDIR)/data/satellites.xml \
+ $(ROOTDIR)/data/dvb-scan/.stamp
+ @echo "Generating data/dvb-scan/dvb-s from data/satellites.xml"
+ @if ! test -s $(ROOTDIR)/data/satellites.xml ; then echo "Put your satellites.xml file to $(ROOTDIR)/data/satellites.xml"; exit 1; fi
+ @if ! test -d $(ROOTDIR)/data/dvb-scan/dvb-s ; then mkdir $(ROOTDIR)/data/dvb-scan/dvb-s ; fi
+ @rm -rf $(ROOTDIR)/data/dvb-scan/dvb-s/*
+ @$(ROOTDIR)/support/sat_xml_scan.py \
+ $(ROOTDIR)/data/satellites.xml $(ROOTDIR)/data/dvb-scan/dvb-s
+ @touch $(ROOTDIR)/data/dvb-scan/dvb-s/.stamp
+
+.PHONY: satellites_xml
+satellites_xml: $(ROOTDIR)/data/dvb-scan/dvb-s/.stamp
# Update
if [ -d "${DIR}/.git" ]; then
- (cd "${DIR}"; git pull) &> /dev/null
-
+ LAST=$(pwd)
+ cd "${DIR}" || exit 1
+ git pull &> /dev/null || exit 1
+ git reset --hard &> /dev/null || exit 1
+ cd "${LAST}" || exit 1
# Fetch
elif [ ! -d "${DIR}" ]; then
URL=http://linuxtv.org/git/dtv-scan-tables.git
- git clone $URL "${DIR}" &> /dev/null
+ git clone $URL "${DIR}" &> /dev/null || exit 1
fi
# Note: will not update existing set (if not .git)
--- /dev/null
+#!/usr/bin/env python
+#
+# Convert XML files from http://satellites-xml.eu/ to scanfile format
+#
+
+import os
+import sys
+import xml.etree.ElementTree as ET
+import re, unicodedata
+
+FLAG_NETWORK_SCAN = 1
+FLAG_USE_BAT = 2
+FLAG_USE_ONOT = 4
+FLAG_SKIP_NIT = 8
+
+POLARIZATION = {
+ '0': 'H',
+ '1': 'V',
+ '2': 'L',
+ '3': 'R'
+}
+
+FEC = {
+ '0': 'AUTO',
+ '1': '1/2',
+ '2': '2/3',
+ '3': '3/4',
+ '4': '5/6',
+ '5': '7/8',
+ '6': '8/9',
+ '7': '3/5',
+ '8': '4/5',
+ '9': '9/10',
+ '15': 'NONE'
+}
+
+MODULATION = {
+ '0': 'AUTO',
+ '1': 'QPSK',
+ '2': '8PSK'
+}
+
+SYSTEM = {
+ '0': 'S',
+ '1': 'S2'
+}
+
+def inspect(node):
+ print(' tag=%s attrib=%s' % (repr(node.tag), repr(node.attrib)))
+
+def asciize(str):
+ if type(str) != type(u''):
+ str = unicode(str, 'UTF-8')
+ str = unicodedata.normalize('NFKD', str).encode('ascii', 'ignore')
+ str = re.sub('\s\s+', ' ', str)
+ str = str.strip().replace(' ', '-')
+ return str
+
+def parse_sat(node):
+
+ position = node.attrib['position']
+ flags = node.attrib['flags']
+ name = node.attrib['name']
+
+ assert(flags == '0')
+
+ filename = name.replace('(', '').replace(')', '').replace('/', '+')
+ filename = DIR + '/' + asciize(filename)
+
+ fp = open(filename, "w+")
+ fp.write('# Generated by tvheadend from satellites.xml\n')
+
+ for child in node:
+ if child.tag == 'transponder':
+ polarization = POLARIZATION[child.attrib['polarization']]
+ fec = FEC[child.attrib['fec_inner']]
+ freq = child.attrib['frequency']
+ rate = child.attrib['symbol_rate']
+ modulation = MODULATION[child.attrib['modulation']]
+ system = SYSTEM[child.attrib['system']]
+ if system == 'S' and modulation == 'QPSK':
+ fp.write('%s %s %s %s %s\n' %
+ (system, freq, polarization, rate, fec))
+ else:
+ fp.write('%s %s %s %s %s %s %s\n' %
+ (system, freq, polarization, rate, fec, 'AUTO', modulation))
+
+ fp.close()
+
+if len(sys.argv) < 3:
+ print('Usage: %s satellite.xml /output/directory/path')
+ sys.exit(0)
+
+DIR = sys.argv[2]
+if not os.path.isdir(DIR):
+ raise ValueError, "Second argument must be the output directory"
+tree = ET.parse(sys.argv[1])
+root = tree.getroot()
+if root.tag == 'satellites':
+ for child in root:
+ if child.tag == 'sat':
+ parse_sat(child)