De-couple mux database

This commit is contained in:
HummyPkg 2018-03-12 23:41:25 +00:00
parent db273a8502
commit 83abd2a5cd
4 changed files with 34 additions and 24 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.4.2-14
Version: 1.4.2-15
Architecture: mipsel
Maintainer: af123@hpkg.tv
Depends: tcpfix,webif-channelicons(>=1.1.25),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.8),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.11),webif-charts(>=1.2-1),stripts(>=1.3.1),tmenu(>=1.21-2),ffmpeg(>=2.8),id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1),jim-xconv
Depends: tcpfix,webif-channelicons(>=1.1.26),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.8),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.11),webif-charts(>=1.2-1),stripts(>=1.3.1),tmenu(>=1.21-2),ffmpeg(>=2.8),id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1),jim-xconv
Suggests:
Description: An evolving web interface for the Humax.
Tags: https://hummy.tv/forum/threads/7712/

View File

@ -70,6 +70,8 @@ if {$cmd eq "update" || $cmd eq "upgrade"} {
putsf ""
putsf "Updating diagnostic meta information"
pkg fetchdiagmeta
putsf "Updating MUX database"
pkg fetchmuxdb
}
putsf "Done."

View File

@ -3,20 +3,22 @@
package require cgi
package require sqlite3
source /mod/webif/lib/setup
require altrow progressbar epg.class system.class
require altrow progressbar epg.class system.class pkg.class
header
proc f2c {frequency} {
set ch int($((($frequency / 1000) - 303.25) / 8))
return [expr int($ch)]
}
if {[catch {set db [sqlite3.open /var/lib/humaxtv/channel.db]} msg]} {
puts "Error opening channel database: $msg"
exit
}
pkg loadmuxdb
proc f2c {frequency} {
set ch int($((($frequency / 1000) - 303.25) / 8))
return [expr int($ch)]
}
puts "
<div class=va>
<img class=va src=/img/aerials.png height=50>
@ -75,22 +77,8 @@ foreach tw [$db query {
lassign $chan x lcn x name
set name [system strip $name]
if {$lcn >= 800} { incr ehs }
switch -glob -- $name {
"BBC NEWS" -
"BBC FOUR" { set mux "PSB1/BBC A" }
"Channel 5" -
"ITV2" { set mux "PSB2/D3&amp;4" }
"Channel 4 HD" -
"BBC ONE HD" { set mux "PSB3/BBC B" }
"5 USA" -
"ITV3" { set mux "COM4/SDN" }
"Really" -
"Dave" { set mux "COM5/ARQ A" }
"4Music" -
"Yesterday" { set mux "COM6/ARQ B" }
"BBC NEWS HD" { set mux "COM7/ARQ C" }
"5STAR+1" -
"QVC + 1 HD" { set mux "COM8/ARQ D" }
if {[dict exists $::muxdb $name]} {
set mux $::muxdb($name)
}
}
puts "<td>$mux</td>"

View File

@ -13,6 +13,7 @@ class pkg {
set ::pkgmeta {}
set ::diagmeta {}
set ::muxdb {}
pkg method _load {nm} {
set name $nm
@ -259,6 +260,25 @@ proc {pkg fetchdiagmeta} {} {
$ff close
}
proc {pkg loadmuxdb} {} {
if {[llength $::muxdb]} { return }
if {![file exists "/mod/var/mux.db"]} {
catch {pkg fetchmuxdb}
} else {
set meta [open "/mod/var/mux.db" r]
set ::muxdb [read $meta]
$meta close
}
}
proc {pkg fetchmuxdb} {} {
set ::muxdb [pkg fetchfile mux.db]
set ff [open "/mod/var/mux.db" w]
puts $ff $::muxdb
$ff close
}
proc {pkg update} {} {
exec /bin/opkg update
}