mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
Merge pull request #2514 from vpeter4/hdhomerun
hdhomerun: get tuner id with command 'hdhomerun_config discover'
This commit is contained in:
commit
621e3f2e46
@ -1,3 +1,6 @@
|
|||||||
|
3.1.5
|
||||||
|
get tuner id with command 'hdhomerun_config discover' and
|
||||||
|
set number of tuners manually
|
||||||
3.1.4
|
3.1.4
|
||||||
get tuner id from /var/log/messages
|
get tuner id from /var/log/messages
|
||||||
3.1.3
|
3.1.3
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
PKG_NAME="hdhomerun"
|
PKG_NAME="hdhomerun"
|
||||||
PKG_VERSION="3.2"
|
PKG_VERSION="3.2"
|
||||||
PKG_REV="4"
|
PKG_REV="5"
|
||||||
PKG_ARCH="any"
|
PKG_ARCH="any"
|
||||||
PKG_LICENSE="GPL"
|
PKG_LICENSE="GPL"
|
||||||
PKG_SITE="http://www.silicondust.com/products/hdhomerun/dvbt/"
|
PKG_SITE="http://www.silicondust.com/products/hdhomerun/dvbt/"
|
||||||
PKG_URL=""
|
PKG_URL=""
|
||||||
PKG_DEPENDS=""
|
PKG_DEPENDS=""
|
||||||
PKG_BUILD_DEPENDS="toolchain"
|
PKG_BUILD_DEPENDS=""
|
||||||
PKG_PRIORITY="optional"
|
PKG_PRIORITY="optional"
|
||||||
PKG_SECTION="driver/dvb"
|
PKG_SECTION="driver/dvb"
|
||||||
PKG_SHORTDESC="A linux DVB driver for the HDHomeRun (http://www.silicondust.com)."
|
PKG_SHORTDESC="A linux DVB driver for the HDHomeRun (http://www.silicondust.com)."
|
||||||
|
@ -63,39 +63,46 @@ if [ -z "$(pidof userhdhomerun)" ]; then
|
|||||||
cp $HDHR_ADDON_HOME/dvbhdhomerun.conf $DVBHDHOMERUN_CONF_TMP
|
cp $HDHR_ADDON_HOME/dvbhdhomerun.conf $DVBHDHOMERUN_CONF_TMP
|
||||||
|
|
||||||
# get tuner serial numbers
|
# get tuner serial numbers
|
||||||
SERIALS=$(cat /var/config/hdhomerun-addon.conf | sed -n 's|^ATTACHED_TUNER_\(.*\)_\(.*\)_DVBMODE=.*|\1-\2|gp' | sort | uniq)
|
SERIALS=$(cat /var/config/hdhomerun-addon.conf | sed -n 's|^ATTACHED_TUNER_\(.*\)_DVBMODE=.*|\1|gp' | sort | uniq)
|
||||||
. /var/config/hdhomerun-addon.conf
|
. /var/config/hdhomerun-addon.conf
|
||||||
|
|
||||||
for SERIAL in $SERIALS; do
|
for SERIAL_UNIQ in $SERIALS; do
|
||||||
SERIAL_VAR=$(echo $SERIAL | sed 's|-|_|')
|
DVBMODE=$(eval echo \$ATTACHED_TUNER_${SERIAL_UNIQ}_DVBMODE)
|
||||||
DVBMODE=$(eval echo \$ATTACHED_TUNER_${SERIAL_VAR}_DVBMODE)
|
FULLNAME=$(eval echo \$ATTACHED_TUNER_${SERIAL_UNIQ}_FULLNAME)
|
||||||
FULLNAME=$(eval echo \$ATTACHED_TUNER_${SERIAL_VAR}_FULLNAME)
|
DISABLE=$(eval echo \$ATTACHED_TUNER_${SERIAL_UNIQ}_DISABLE)
|
||||||
DISABLE=$(eval echo \$ATTACHED_TUNER_${SERIAL_VAR}_DISABLE)
|
NUMBERS=$(eval echo \$ATTACHED_TUNER_${SERIAL_UNIQ}_NUMBERS)
|
||||||
|
|
||||||
[ "$DVBMODE" = "auto" ] && DVBMODE=""
|
NUMBERS=$(( $NUMBERS -1 ))
|
||||||
|
NUMBERS=$(( $NUMBERS *1 ))
|
||||||
|
|
||||||
# remove setttings for this tuner
|
for i in $(seq 0 $NUMBERS); do
|
||||||
awk -v val="[$SERIAL]" '$0 == val {flag=1; next} /^tuner_type=|^use_full_name=|^disable=|^#|^$/{if (flag==1) next} /.*/{flag=0; print}' $DVBHDHOMERUN_CONF_TMP >${DVBHDHOMERUN_CONF_TMP}-types
|
SERIAL="$SERIAL_UNIQ-$i"
|
||||||
mv ${DVBHDHOMERUN_CONF_TMP}-types $DVBHDHOMERUN_CONF_TMP
|
|
||||||
echo "" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
# remove empty lines at the end of file
|
|
||||||
sed -i -e ':a' -e '/^\n*$/{$d;N;};/\n$/ba' $DVBHDHOMERUN_CONF_TMP
|
|
||||||
|
|
||||||
ADDNEW=true
|
[ "$DVBMODE" = "auto" ] && DVBMODE=""
|
||||||
if [ -n "$DVBMODE" ]; then
|
|
||||||
[ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
echo "tuner_type=$DVBMODE" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
fi
|
|
||||||
if [ "$FULLNAME" = "true" ]; then
|
|
||||||
[ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
echo "use_full_name=true" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
fi
|
|
||||||
if [ "$DISABLE" = "true" ]; then
|
|
||||||
[ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
echo "disable=true" >>$DVBHDHOMERUN_CONF_TMP
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "" >>$DVBHDHOMERUN_CONF_TMP
|
# remove setttings for this tuner
|
||||||
|
awk -v val="[$SERIAL]" '$0 == val {flag=1; next} /^tuner_type=|^use_full_name=|^disable=|^#|^$/{if (flag==1) next} /.*/{flag=0; print}' $DVBHDHOMERUN_CONF_TMP >${DVBHDHOMERUN_CONF_TMP}-types
|
||||||
|
mv ${DVBHDHOMERUN_CONF_TMP}-types $DVBHDHOMERUN_CONF_TMP
|
||||||
|
echo "" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
# remove empty lines at the end of file
|
||||||
|
sed -i -e ':a' -e '/^\n*$/{$d;N;};/\n$/ba' $DVBHDHOMERUN_CONF_TMP
|
||||||
|
|
||||||
|
ADDNEW=true
|
||||||
|
if [ -n "$DVBMODE" ]; then
|
||||||
|
[ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
echo "tuner_type=$DVBMODE" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
fi
|
||||||
|
if [ "$FULLNAME" = "true" ]; then
|
||||||
|
[ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
echo "use_full_name=true" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
fi
|
||||||
|
if [ "$DISABLE" = "true" ]; then
|
||||||
|
[ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
echo "disable=true" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >>$DVBHDHOMERUN_CONF_TMP
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove logging from libhdhomerun library
|
# remove logging from libhdhomerun library
|
||||||
|
@ -27,10 +27,8 @@ __cwd__ = __settings__.getAddonInfo('path')
|
|||||||
__resources_lib__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib'))
|
__resources_lib__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib'))
|
||||||
__settings_xml__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'settings.xml'))
|
__settings_xml__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'settings.xml'))
|
||||||
|
|
||||||
__hdhomerun_log__ = '/var/log/dvbhdhomerun.log'
|
|
||||||
|
|
||||||
if __name__ == "__main__" and len(sys.argv) == 2 and sys.argv[1] == 'refresh_tuners':
|
if __name__ == "__main__" and len(sys.argv) == 2 and sys.argv[1] == 'refresh_tuners':
|
||||||
sys.path.append(__resources_lib__)
|
sys.path.append(__resources_lib__)
|
||||||
from functions import refresh_hdhomerun_tuners
|
from functions import refresh_hdhomerun_tuners
|
||||||
refresh_hdhomerun_tuners(__settings_xml__, __hdhomerun_log__)
|
refresh_hdhomerun_tuners(__settings_xml__)
|
||||||
__settings__.openSettings()
|
__settings__.openSettings()
|
||||||
|
@ -11,5 +11,6 @@
|
|||||||
<string id="9005">Enable modifying settings</string>
|
<string id="9005">Enable modifying settings</string>
|
||||||
<string id="9010">Refresh tuners... (press me)</string>
|
<string id="9010">Refresh tuners... (press me)</string>
|
||||||
<string id="9020"> use full name</string>
|
<string id="9020"> use full name</string>
|
||||||
|
<string id="9025"> number of tuners</string>
|
||||||
<string id="9030"> disabled</string>
|
<string id="9030"> disabled</string>
|
||||||
</strings>
|
</strings>
|
||||||
|
@ -46,25 +46,28 @@ def settings_restore(settings_xml):
|
|||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
# get hdhomerun supported devices on a system (only name like 101ADD2B-0)
|
# get hdhomerun supported devices on a system (only name like 101ADD2B-0)
|
||||||
def get_devices_hdhomerun(hdhomerun_log):
|
def get_devices_hdhomerun():
|
||||||
tuners = []
|
tuners = []
|
||||||
try:
|
try:
|
||||||
for line in open('/var/log/messages', 'r'):
|
p = os.popen("hdhomerun_config discover", "r")
|
||||||
if line.find('HDHomeRun'):
|
while 1:
|
||||||
line = line.strip()
|
line = p.readline()
|
||||||
#Jul 17 19:22:46 user user.info kernel: [ 10.587811] HDHomeRun HDHomeRun.0: DVB: registering adapter 0 frontend 0 (HDHomeRun DVB-C 12345678-0)...
|
if not line:
|
||||||
match = re.search(r'.*\[.+\] HDHomeRun .+ registering adapter .+ \(HDHomeRun .+ (.+)\).+', line)
|
break
|
||||||
|
else:
|
||||||
|
str = line.strip()
|
||||||
|
match = re.search(r'hdhomerun device (.+) found at .+', line)
|
||||||
if match:
|
if match:
|
||||||
name = match.group(1)
|
name = match.group(1)
|
||||||
tuners.append(name)
|
print name
|
||||||
|
tuners.append(name)
|
||||||
except IOError:
|
except IOError:
|
||||||
print 'Error reading hdhomerun log file /var/log/messages'
|
print 'Error getting hdhomerun tuners info'
|
||||||
return tuners
|
return tuners
|
||||||
|
|
||||||
"""
|
"""
|
||||||
root ~ # grep HDHomeRun /var/log/messages
|
openelec:~ # hdhomerun_config discover
|
||||||
Jul 17 19:22:46 user user.info kernel: [ 10.587811] HDHomeRun HDHomeRun.0: DVB: registering adapter 0 frontend 0 (HDHomeRun DVB-C 12345678-0)...
|
hdhomerun device 12345678 found at 192.168.0.3
|
||||||
Jul 17 19:22:46 user user.info kernel: [ 10.588602] HDHomeRun HDHomeRun.1: DVB: registering adapter 1 frontend 0 (HDHomeRun DVB-C 12345678-1)...
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
@ -154,11 +157,13 @@ def remove_old_tuners(xmldoc):
|
|||||||
# add new hdhomerun tuners
|
# add new hdhomerun tuners
|
||||||
def add_hdhomerun(xmldoc, node_cat, tuners):
|
def add_hdhomerun(xmldoc, node_cat, tuners):
|
||||||
for ix, tuner in enumerate(tuners):
|
for ix, tuner in enumerate(tuners):
|
||||||
tuner_var = tuner.replace('-', '_')
|
#tuner_var = tuner.replace('-', '_')
|
||||||
|
tuner_var = tuner
|
||||||
|
print tuner
|
||||||
|
|
||||||
node1 = xmldoc.createElement("setting")
|
node1 = xmldoc.createElement("setting")
|
||||||
node1.setAttribute("id", 'ATTACHED_TUNER_' + tuner_var + '_DVBMODE')
|
node1.setAttribute("id", 'ATTACHED_TUNER_' + tuner_var + '_DVBMODE')
|
||||||
node1.setAttribute("label", tuner)
|
node1.setAttribute("label", "tuner serial " + tuner_var)
|
||||||
node1.setAttribute("type", 'labelenum')
|
node1.setAttribute("type", 'labelenum')
|
||||||
node1.setAttribute("default", 'auto')
|
node1.setAttribute("default", 'auto')
|
||||||
node1.setAttribute("values", 'auto|ATSC|DVB-C|DVB-T')
|
node1.setAttribute("values", 'auto|ATSC|DVB-C|DVB-T')
|
||||||
@ -172,12 +177,20 @@ def add_hdhomerun(xmldoc, node_cat, tuners):
|
|||||||
node_cat.appendChild(node2)
|
node_cat.appendChild(node2)
|
||||||
|
|
||||||
node3 = xmldoc.createElement("setting")
|
node3 = xmldoc.createElement("setting")
|
||||||
node3.setAttribute("id", 'ATTACHED_TUNER_' + tuner_var + '_DISABLE')
|
node3.setAttribute("id", 'ATTACHED_TUNER_' + tuner_var + '_NUMBERS')
|
||||||
node3.setAttribute("label", '9030')
|
node3.setAttribute("label", '9025')
|
||||||
node3.setAttribute("type", 'bool')
|
node3.setAttribute("type", 'labelenum')
|
||||||
node3.setAttribute("default", 'false')
|
node3.setAttribute("default", '2')
|
||||||
|
node3.setAttribute("values", '1|2|3|4|5|6|7|8')
|
||||||
node_cat.appendChild(node3)
|
node_cat.appendChild(node3)
|
||||||
|
|
||||||
|
node4 = xmldoc.createElement("setting")
|
||||||
|
node4.setAttribute("id", 'ATTACHED_TUNER_' + tuner_var + '_DISABLE')
|
||||||
|
node4.setAttribute("label", '9030')
|
||||||
|
node4.setAttribute("type", 'bool')
|
||||||
|
node4.setAttribute("default", 'false')
|
||||||
|
node_cat.appendChild(node4)
|
||||||
|
|
||||||
# for tuner
|
# for tuner
|
||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
@ -249,9 +262,9 @@ def save_settings(settings_xml, xmldoc):
|
|||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
# refresh hdhomerun tuners in settings.xml file
|
# refresh hdhomerun tuners in settings.xml file
|
||||||
def refresh_hdhomerun_tuners(settings_xml, hdhomerun_log):
|
def refresh_hdhomerun_tuners(settings_xml):
|
||||||
settings_backup(settings_xml)
|
settings_backup(settings_xml)
|
||||||
tuners = get_devices_hdhomerun(hdhomerun_log)
|
tuners = get_devices_hdhomerun()
|
||||||
xmldoc = parse_settings(settings_xml)
|
xmldoc = parse_settings(settings_xml)
|
||||||
if xmldoc == None:
|
if xmldoc == None:
|
||||||
print 'No hdhomerun tuners found'
|
print 'No hdhomerun tuners found'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user