From 83abd2a5cd8601da6080ca25ca77682084b88998 Mon Sep 17 00:00:00 2001 From: HummyPkg Date: Mon, 12 Mar 2018 23:41:25 +0000 Subject: [PATCH] De-couple mux database --- CONTROL/control | 4 ++-- webif/cgi-bin/opkg.jim | 2 ++ webif/html/diag/mux.jim | 32 ++++++++++---------------------- webif/lib/pkg.class | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index 5f7694cc..57a24fba 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -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/ diff --git a/webif/cgi-bin/opkg.jim b/webif/cgi-bin/opkg.jim index 2d925a33..ca776d0a 100755 --- a/webif/cgi-bin/opkg.jim +++ b/webif/cgi-bin/opkg.jim @@ -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." diff --git a/webif/html/diag/mux.jim b/webif/html/diag/mux.jim index d3135767..05ad46c9 100755 --- a/webif/html/diag/mux.jim +++ b/webif/html/diag/mux.jim @@ -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 "
@@ -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&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 "$mux" diff --git a/webif/lib/pkg.class b/webif/lib/pkg.class index 0a69ae8a..edd5e98d 100755 --- a/webif/lib/pkg.class +++ b/webif/lib/pkg.class @@ -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 }