Compare commits

..

13 Commits

Author SHA1 Message Date
df
11e010ed3b Merge branch 'master' into df-commandcheck-patch 2020-12-31 00:01:31 +00:00
df
5f29ab2f4d exists -proc -> exists -command
Test was failing for `sqlite3.open`, `xconv`.
2020-12-14 14:36:20 +00:00
df
954ddf6d8b exists -proc -> exists -command 2020-12-14 14:33:53 +00:00
df
1d008a1bce exists -proc -> exists -command
Test was failing for `sqlite3.open`.
2020-12-14 14:32:51 +00:00
df
9779b82bd1 exists -proc -> exists -command
Test was failing for `sqlite3.open`.
2020-12-14 14:30:02 +00:00
df
0f678564b8 exists -proc -> exists -command
Test was failing for `sqlite3.open`.
2020-12-14 14:27:41 +00:00
df
6ac4216d44 exists -proc -> exists -command
Test was failing for `sqlite3.open`.
2020-12-14 14:22:56 +00:00
df
1c5698388c exists -proc -> exists -command
Test was failing for `sqlite3.open`.
2020-12-14 14:15:47 +00:00
df
6fc0acf22f exists -proc -> exists -command
Test was failing for `sqlite3.open`
2020-12-14 14:14:03 +00:00
df
397d383051 exists -proc -> exists -command
`sqlite3.open` is currently a command, so the test for it as a proc fails, presumably not what was intended.
2020-12-14 14:12:32 +00:00
df
23483c8fa5 exists -proc -> exists -command 2020-12-14 14:09:32 +00:00
df
b59bead2a2 exists -proc -> exists -command 2020-12-14 14:08:28 +00:00
df
b780b3dda8 exists -proc -> exists -command
`exists -command` subsumes `exists -proc`

This test is generally checking whether the command exists, rather than some proc that is overriding it.

Currently `class` is a proc but this may not always be so.
2020-12-14 14:06:48 +00:00
168 changed files with 1385 additions and 2951 deletions

View File

@@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.5.4-4
Version: 1.4.8-11
Architecture: mipsel
Maintainer: prpr
Depends: tcpfix,webif-channelicons(>=1.2.4),lighttpd(>=1.4.39-1),jim(>=0.82-5),jim-cgi(>=0.7-2),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.3.0-1),hmt(>=2.0.12),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.13),webif-charts(>=1.2-1),stripts(>=1.4.2),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.98),sqlite3(>=3.15.1),jim-xconv,zip(>=3.0-1),wget
Maintainer: af123@hpkg.tv
Depends: tcpfix,webif-channelicons(>=1.1.27),lighttpd(>=1.4.39-1),jim(>=0.79),jim-pack(>=0.79),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-2),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.13),webif-charts(>=1.2-1),stripts(>=1.4.2),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.98),sqlite3(>=3.15.1),jim-xconv,zip(>=3.0-1),wget
Suggests:
Description: An evolving web interface for the Humax.
Tags: https://hummy.tv/forum/threads/10760/
Tags: https://hummy.tv/forum/threads/7712/

View File

@@ -1,31 +1,26 @@
#!/bin/sh
# At daemon doesn't work properly with 700
[ -d /mod/var ] && chmod 755 /mod/var
# Relocate any stray files in /mod/var/mongoose
if [ -d /mod/var/mongoose ] && [ ! -h /mod/var/mongoose ]; then
if [ -d /mod/var/mongoose -a ! -h /mod/var/mongoose ]; then
(
cd /mod/var/mongoose || exit 1
cd /mod/var/mongoose
find . | cpio -pmud /mod/webif
)
(
cd /mod/var || exit 1
cd /mod/var
rm -rf mongoose
ln -s ../webif mongoose
)
fi
tmpfile=/tmp/cronf.$$
export tmpf=/tmp/cronf.$$
# Add cron jobs
crontab=${PKG_ROOT}bin/crontab
if [ -x "$crontab" ]; then
"$crontab" -l | grep -v webif/lib/bin/auto \
| grep -v webif/lib/auto > $tmpfile
cat $tmpfile - << EOM | "$crontab" -
crontab=$PKG_ROOT/bin/crontab
if [ -x $crontab ]; then
$crontab -l | grep -v webif/lib/bin/auto \
| grep -v webif/lib/auto > $tmpf
cat $tmpf - << EOM | $crontab -
* * * * * /mod/webif/lib/auto/scan >/dev/null 2>>/mod/tmp/auto.log
* * * * * /mod/webif/lib/auto/deq >/dev/null 2>>/mod/tmp/auto.log
EOM
@@ -33,29 +28,21 @@ fi
# Add anacron jobs
ana=${PKG_ROOT}etc/anacrontab
grep -vE 'backup/backup.jim|bin/(diskattrs|resetnew)' "$ana" > $tmpfile
cat $tmpfile - << EOM > "$ana"
1 4 diskattrs /mod/webif/lib/bin/diskattrs
1 7 resetnew /mod/webif/lib/bin/resetnew
ana=$PKG_ROOT/etc/anacrontab
egrep -v 'backup/backup.jim|bin/diskattrs' $ana > $tmpf
cat $tmpf - << EOM > $ana
1 8 sched_backup /mod/webif/html/sched/backup/backup.jim
1 5 diskattrs /mod/webif/lib/bin/diskattrs
EOM
"$PKG_ROOT"etc/init.d/S02anacron start >/dev/null 2>&1 <&1 &
$PKG_ROOT/etc/init.d/S02anacron start < /dev/null > /dev/null 2>&1 &
[ -f /tmp/webif_auto.log ] && rm -f /tmp/webif_auto.log
[ -f /mod/webif/.strip-updated ] && rm -f /mod/webif/.strip-updated
# Run in full environment as Jim shell doesn't work otherwise
if [ -f /mod/.env ]; then
(
. /mod/.env
/mod/webif/lib/auto/upgrade
/mod/webif/lib/bin/diskattrs
/mod/webif/lib/bin/resetnew
/mod/webif/lib/bin/fixepisodes
) >/dev/null 2>&1 <&1 &
fi
/mod/webif/lib/bin/diskattrs
/mod/webif/lib/auto/upgrade
#/mod/webif/lib/bin/resetnew
# Remove hook script placed by the legacy rt3070 package which does not work
# with CFW >= 3.00
@@ -67,19 +54,14 @@ hook=/mod/boot/xinit.d/rt3070
# Migrate record log to new name.
(
cd /mod/tmp || exit 1
if [ -f record.log ]; then
if [ -f activity.log ]; then
rm record.log
else
mv record.log activity.log
fi
fi
cd /mod/tmp
[ -f record.log -a ! -f activity.log ] && mv record.log activity.log
)
[ -f $tmpfile ] && rm -f $tmpfile
[ -f $tmpf ] && rm -f $tmpf
# Remove empty directories
find /mod/webif/ -type d -exec rmdir {} \; 2>/dev/null
exit 0

View File

@@ -2,18 +2,17 @@
# Handle moving the legacy /var/mongoose directory to /webif..
if [ -h /mod/webif ] && [ -d /mod/var/mongoose ] && [ ! -h /mod/var/mongoose ]; then
(
if [ -h /mod/webif -a -d /mod/var/mongoose -a ! -h /mod/var/mongoose ]; then
echo "Relocating web interface files..."
cd /mod || exit 1
cd /mod
rm webif || exit 1
mv var/mongoose webif || exit 1
cd var || exit 1
cd var
ln -s ../webif mongoose
)
fi
if [ ! -f /mod/webif/.pfixpkg ] && [ -x /mod/bin/at ]; then
if [ ! -f /mod/webif/.pfixpkg -a -x /mod/bin/at ]; then
/mod/bin/at now + 1 minute << EOM
diag fixpkg
touch /mod/webif/.pfixpkg
@@ -21,3 +20,4 @@ EOM
fi
exit 0

View File

@@ -1,20 +1,19 @@
#!/bin/sh
tmpfile=/tmp/cronf.$$
export tmpf=/tmp/cronf.$$
crontab=${PKG_ROOT}bin/crontab
if [ -x "$crontab" ]; then
"$crontab" -l | grep -v webif/lib/bin/auto \
| grep -v webif/lib/auto > $tmpfile
if [ -s $tmpfile ]; then
"$crontab" $tmpfile
else
$crontab -r
fi
crontab=$PKG_ROOT/bin/crontab
if [ -x $crontab ]; then
$crontab -l | grep -v webif/lib/bin/auto \
| grep -v webif/lib/auto > $tmpf
[ -s $tmpf ] && $crontab $tmpf || $crontab -r
fi
ana=${PKG_ROOT}etc/anacrontab
grep -vE 'backup/backup.jim|bin/(diskattrs|resetnew)' "$ana" > $tmpfile
mv $tmpfile "$ana"
ana=/mod/etc/anacrontab
egrep -v 'backup/backup.jim|bin/diskattrs' $ana > $tmpf
cp $tmpf $ana
[ -f $tmpf ] && rm -f $tmpf
exit 0

Binary file not shown.

31
etc/init.d/S60parseepg Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
if [ "`cat /etc/model`" = HD ]; then
epg=/media/drive1/epgsavedata
epgdb=/media/drive1/epg.db
else
epg=/mnt/hd1/dvbepg/epg.dat
epgdb=/mnt/hd1/epg.db
fi
case "$1" in
start)
(
ulimit -c unlimited
while [ 1 ]; do
/mod/bin/epg -f $epg sqlitedumpd $epgdb \
> /tmp/epgd.log 2>&1
[ $? -eq 143 ] && break
done
)&
;;
stop)
killall -q epg
;;
*)
exit 1
;;
esac
exit 0

3
etc/modservice.d/epg Normal file
View File

@@ -0,0 +1,3 @@
key=/mod/bin/epg
rc=60parseepg
proc="/mod/bin/epg.*sqlitedumpd"

View File

@@ -13,10 +13,9 @@ set dir [file dirname $file]
if {[string match "$root*" $dir]} {
set dir [string range $dir $([string length $root] + 1) end]
}
set title [$ts get title]
set ep [$ts episode_name]
set dur [$ts duration]
set ch [$ts get channel_name]
set dur [$ts duration]
set title [$ts get title]
system plog activity "Recorded: $dir/$title ($dur minutes - $ch)"
system plog activity "Recorded: $dir/$title Episode: $ep ($dur minutes - $ch)"

View File

@@ -11,15 +11,9 @@ httpheader
set service [cgi_get service 0]
set event [cgi_get event 0]
if {![cgi_exists bare]} header else noheader
defer {
epg cleanup
if {![cgi_exists bare]} footer
}
set record [lindex [\
epg dbfetch dump -service $service -event $event -sort ""] 0]
if {$record == ""} exit
$record get_channel_info
set others [$record othertimes]
@@ -37,7 +31,7 @@ if {[$record get sched_type] < 1} {
[system tuners]]
if {[llength $conflicts]} {
puts {
<div class=warningbox style="width: auto; margin: 0.2em"><div>
<div class=warningbox style="width: 100%; margin: 0.2em"><div>
This event conflicts with the following items in your scheduled recording list.
<ul>
}
@@ -60,7 +54,7 @@ puts "
<td>[$record get text]</td>
</tr><tr>
<th>Start</th>
<td>[clock format [$record get start] -format {%a %b %e %R %Z}]
<td>[clock format [$record get start] -format {%c %Z}]
"
foreach o $others {
@@ -73,7 +67,7 @@ foreach o $others {
puts -nonewline "<a class=event href=# xs=[$o get service_id] "
puts -nonewline "xe=[$o get event_id] "
puts -nonewline "sch=[$o get sched_type] rec=$ro>"
puts -nonewline "[clock format [$o get start] -format {%a %b %e %R %Z}]"
puts -nonewline "[clock format [$o get start] -format {%c %Z}]"
puts -nonewline " on "
puts -nonewline [$o channel_icon 16]
puts -nonewline "[$o get channel_name] "
@@ -119,7 +113,7 @@ if {[$record get event_crid] != ""} {
puts "
<tr>
<th>CRID</th><td>
<a href=/cgi-bin/epg/search.jim?crid=[cgi_quote_url [$record get event_crid]]>
<a href=/cgi-bin/epg/search.jim?crid=[$record get event_crid]>
<img border=0 height=14
src=/images/421_1_00_CH_Title_2R_Arrow.png>
[$record get channel_crid][$record get event_crid]
@@ -133,7 +127,7 @@ if {[$record get series_crid] != ""} {
puts "
<tr>
<th nowrap>Series CRID</th><td>
<a href=/cgi-bin/epg/search.jim?scrid=[cgi_quote_url [$record get series_crid]]>
<a href=/cgi-bin/epg/search.jim?scrid=[$record get series_crid]>
<img border=0 height=14
src=/images/421_1_00_CH_Title_2R_Arrow.png>
[$record get channel_crid][$record get series_crid]
@@ -147,7 +141,7 @@ if {[$record get rec_crid] != ""} {
set rec [$record recommended]
if {$rec != ""} {
puts "<tr><th>Recommends</th><td>
<a href=/cgi-bin/epg/search.jim?crid=[cgi_quote_url [$rec get event_crid]]>
<a href=/cgi-bin/epg/search.jim?crid=[$rec get event_crid]>
<img border=0 height=14
src=/images/421_1_00_CH_Title_2R_Arrow.png>
[$rec get name]
@@ -178,3 +172,7 @@ puts "
Show raw EPG info
</a>
"
epg cleanup
if {![cgi_exists bare]} footer

View File

@@ -9,12 +9,12 @@ header
require totop
set ct [cgi_unquote_input [cgi_get ct ""]]
set crid [cgi_unquote_input [cgi_get crid ""]]
set scrid [cgi_unquote_input [cgi_get scrid ""]]
set ct [cgi_get ct 0]
set crid [cgi_get crid ""]
set scrid [cgi_get scrid ""]
if {[cgi_exists term]} {
set lterm [cgi_unquote_input [cgi_get term]]
set lterm [cgi_get term]
if {[string match {CRID:*} $lterm]} {
set crid [string range $lterm 5 end]
@@ -41,7 +41,7 @@ set cmd "search"
if {$searchfull} { set cmd "searchall" }
set dedup 0
if {$ct ne "" } {
if {$ct > 0 } {
set records [epg dbfetch dump -type $ct]
if {[[settings] genrededup]} { set dedup 1 }
} elseif {$crid ne ""} {

View File

@@ -2,7 +2,7 @@
package require cgi
source /mod/webif/lib/setup
require pkg.class system.class settings.class
require pkg.class system.class
cgi_input
#cgi_dump
@@ -61,11 +61,6 @@ if {$cmd eq "dependinfo"} {
}
if {$cmd eq "upgrade"} { opkg update }
if {$cmd eq "remove" && [[settings] noautoremove] ne "1"} {
append cmd " --autoremove"
}
opkg "$cmd $cmdargs"
if {$cmd eq "update" || $cmd eq "upgrade"} {
@@ -75,7 +70,8 @@ if {$cmd eq "update" || $cmd eq "upgrade"} {
putsf ""
putsf "Updating diagnostic meta information"
pkg fetchdiagmeta
pkg removemuxdb
putsf "Updating MUX database"
pkg fetchmuxdb
}
putsf "Done."

View File

@@ -7,7 +7,7 @@ require system.class epg.class rsv.class svc.class plugin
set runmode cli
if {[string match {*jim} $argv0]} { set runmode cgi }
set schedtime 1200
set schedtime 1200
switch $runmode {
cgi {
set type [cgi_get type "full"]
@@ -15,7 +15,8 @@ switch $runmode {
}
cli {
set type "full"
if {[lsearch -nocase $argv "-x"] >= 0} { set schedtime 7200 }
if {"-X" in $argv} { set schedtime 7200 }
if {"-x" in $argv} { set schedtime 7200 }
}
}
@@ -30,8 +31,7 @@ if {[catch {set pid [exec pgrep -n humaxtv]}]} {
exit
}
source /mod/webif/include/extensions.jim
set exts $include
set exts {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov .hmt .m4v .m4a}
set statusops {
decrypt { "Decrypting"
@@ -61,11 +61,11 @@ proc register_statusop {op name icon} {
eval_plugins status 1
proc get_data {} {
global pid exts stream tsr tsrcnt
global pid exts
set ret {}
if {[catch {set data \
[exec /mod/webif/lib/bin/lsof -Fnsa -p $pid]} msg]} {
[exec /mod/webif/lib/bin/lsof -X -Fns -p $pid]} msg]} {
debug "Error: $msg"
set ret {}
} else {
@@ -73,63 +73,35 @@ proc get_data {} {
foreach line [split $data "\n"] {
set typ [string index $line 0]
switch $typ {
a {
set access [string index $line 1]
}
s {
set size [string range $line 1 end]
}
n {
# strip initial n and trailing " (...)" if
# present
regsub -all -- {(^n)|( \([^\)]+\)$)} \
$line "" line
set file [subst -nocommands -novariables $line]
set ext [file extension $line]
# Note but skip TSR buffers
if {[file rootname $file] eq $tsr} {
if {$ext eq ".nts"} {
incr tsrcnt
}
if {[string first Video/ $line] == -1 && \
[string first /media/ $line] == -1} {
continue
}
if {[string first Video/ $line] >= 0 ||
[string first /media/ $line] >= 0} {
if {$ext ni $exts} {
continue
}
} elseif {[string first $line /] >= 0} {
# fast skip other files
continue
} elseif {[regexp -- {[A-Za-z0-9._-]+:([0-9]+)->([A-Za-z0-9._-]+):([0-9]+)} $line _ sprt host dprt]} {
if {$sprt == 9000} {
incr stream
continue
} elseif {$dprt == 9000} {
set file [\
format "DLNA from %s" $host]
set size 0
set ext ""
} else {
continue
}
} else {
regsub -- { \([^\)]+\)$} $line "" line
set ext [file extension $line]
if {$ext ni $exts} continue
set file [subst -nocommands -novariables \
[string range $line 1 end]]
# Skip HD-Fox TSR buffer
if {$file eq "/media/drive1/.tsr/0.ts"} {
continue
}
# Handle chase play (same file open twice
# and recently written)
if {[dict exists $ret $file] &&
if {[dict exists $ret $file] && \
$ext eq ".ts"} {
set age $([clock seconds] - [file mtime $file])
set age [expr [clock seconds] - \
[file mtime $file]]
if {$age < 60} {
set access [lindex \
[dict get $ret $file] 1]
set ret($file) [list -1 $access]
set ret($file) -1
}
} else {
debug "$file = $size,$access"
set ret($file) [list $size $access]
} else {
debug "$file = $size"
set ret($file) $size
}
}
}
@@ -137,9 +109,11 @@ proc get_data {} {
}
foreach file [dict keys $::ops] {
if {![dict exists $ret $file]} {
set sz 0
if {[file exists $file]} { set sz [file size $file] }
set ret($file) [list $sz u]
if {[file exists $file]} {
set ret($file) [file size $file]
} else {
set ret($file) 0
}
}
}
return $ret
@@ -152,7 +126,7 @@ proc add_output {icon mode name} {
if {[string first "/" $icon] == -1} {
set icon "/images/$icon"
}
lappend output [string cat \
lappend output [concat \
"<span class=\"va stitem\">\n" \
" <img class=va src=$icon>\n" \
" <span>$mode&nbsp;<i>$name</i></span>\n" \
@@ -165,12 +139,9 @@ proc add_output {icon mode name} {
set play 0
set rec 0
set stream 0
set output {}
set ops {}
set model [system model]
set tsr [file rootname [system tsr]]
set tsrcnt 0
foreach opfile [glob -nocomplain -directory /tmp -tails -- ".bgop.*"] {
set op [string range $opfile 6 end]
@@ -208,29 +179,27 @@ if {[llength $data]} {
debug " NDATA: ($ndata)"
set rr 0
}
set bnames [lsort [lmap x [array names data] { file tail $x }]]
foreach file [array names data] {
set bname [file tail $file]
set bname [file rootname [file tail $file]]
regexp {(^/(mnt/hd2/My Video|media/drive[1-9]+/Video)/)?(.*)(\.ts)?$}\
$file _ _ _ name
set name [string map {
"/mnt/hd2/My Video/" ""
"/media/drive1/Video/" ""
"/media/" ""
".ts" ""
} $file]
if {[lindex $data($file) 0] == -1} {
if {$data($file) == -1} {
set mode chase
} elseif {$rr} {
if {$file in $recs} {
set mode rec
} elseif {[llength [\
lsearch -all $bnames $bname]] == 2} {
# two different files having same file.ext open
set mode copy
} else {
set mode play
}
} else {
if {![dict exists $ndata $file]} continue
if {[lindex $ndata($file) 0] > \
[lindex $data($file) 0]} {
if {$ndata($file) > $data($file)} {
set mode rec
} else {
set mode play
@@ -246,7 +215,7 @@ if {[llength $data]} {
set mode $ops($file)
}
regexp -- {^([^0-9]+)} $mode _ mode
regexp -- {^([^0-9]+)} $mode x mode
switch $mode {
chase {
@@ -262,20 +231,8 @@ if {[llength $data]} {
}
play {
incr play
if {$play > $stream} {
set mode "Playing"
set icon "745_1_10_Video_2Live.png"
} else {
set mode "Streaming"
set icon "/img/dlna.png"
}
}
copy {
if {[lindex $data($file) 1] ne "r"} {
continue
}
set mode "Copying"
set icon "/img/dlna.png"
set mode "Playing"
set icon "745_1_10_Video_2Live.png"
}
default {
if {[dict exists $statusops $mode]} {
@@ -297,16 +254,13 @@ if {[llength $data]} {
if {![system instandby] && $play < 1} {
set hsvc [system param CUR_SVC Value USERCONFIG]
set ff {}
catch {
set ff [[rsv dbhandle] query "
select usSvcid as svcid, usLcn as lcn,
substr(szSvcName, 2) as name
from channel.TBL_SVC
where hSvc = $hsvc
limit 1
"]
}
set ff [[rsv dbhandle] query "
select usSvcid as svcid, usLcn as lcn,
substr(szSvcName, 2) as name
from channel.TBL_SVC
where hSvc = $hsvc
limit 1
"]
if {[llength $ff] == 1} {
lassign [lindex $ff 0] x svcid x lcn x name
@@ -318,33 +272,23 @@ if {![system instandby] && $play < 1} {
if {[llength $epgs] == 1} {
lassign $epgs epg
set prog "- [$epg get name] ("
append prog "[clock format [\
$epg get start] -format %H:%M] - "
append prog "[clock format $([$epg get start] \
+ [$epg get duration]) -format %H:%M]"
append prog "[clock format [$epg get start] -format %H:%M] - "
append prog "[clock format $([$epg get start] + [$epg get duration]) -format %H:%M]"
append prog ") \[[$epg percent]%\]"
}
# 0 => no TSR; >=2 => TSR
if {$tsrcnt == 0 || $tsrcnt == 2} {
set s "Watching"
} elseif {$tsrcnt == 3} {
set s "Watching (delayed)"
} else {
debug "tsrcnt=$tsrcnt"
set s "Not watching"
}
if {$runmode eq "cgi"} {
lappend output [format "
set s "
<span class=\"va stitem\">
[epg channelicon %s 30 \
[epg channelicon $name 30 \
{vertical-align: middle; padding: 0 4px 0 2px}]
<span>%s <i>%s: %s %s</i></span>
</span>
" $name $s $lcn $name $prog]
<span>Watching <i>$lcn: $name $prog</i></span>
"
append s "</span>"
lappend output $s
} else {
lappend output [format "%s %s: %s %s" \
$s $lcn $name $prog]
set s "Watching $lcn: $name $prog"
lappend output $s
}
}
}
@@ -370,7 +314,7 @@ if {[system instandby]} {
# Upcoming recordings
set events [rsv list tbl_reservation \
" where ersvtype = 3 and nsttime - [clock seconds] < $schedtime
" where ersvtype = 3 and nsttime - [clock seconds] < $schedtime
and nsttime > [clock seconds] "]
foreach event $events {
if {$runmode eq "cgi"} {

View File

@@ -55,6 +55,5 @@ if {[llength $usbdisks] > 0} {
puts -nonewline "]"
}
puts ""
puts "}"

View File

@@ -1,17 +0,0 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
package require json
require epg.class
if {[lindex $argv 0] ne "-i"} { httpheader {application/json} }
catch {
set i 0
foreach grp [[settings] channel_groups] {
incr i
lappend vars [list favourite $i name $grp]
}
puts [json::encode [list favourites $vars] {obj favourites {list obj favourite num}}]
}

View File

@@ -1,16 +0,0 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
package require json
if {[lindex $argv 0] ne "-i"} { httpheader {application/json} }
catch {
set time [clock milliseconds]
lappend vars \
isotime [system isotime $time] \
timestamp $time \
uptime [system uptime]
puts [json::encode $vars obj]
}

View File

@@ -1,15 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Page Redirection</title>
<meta http-equiv=refresh content="0; url=index.jim" />
<script>
window.location.href = "index.jim";
</script>
</head>
<body>
You are being redirected to <a href=index.jim>index.jim</a>
</body>
</html>

View File

@@ -1,45 +0,0 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
package require json
if {[lindex $argv 0] ne "-i"} { httpheader {application/json} }
catch {
set ds [system diskstats]
lappend vars \
bootreason [system lastbootreason] \
busy [system busy] \
connectivity [system connectivity] \
customencryptionkey [system customencryptionkey] \
diskfree [system diskfree] \
diskhours $ds(hours) \
diskpending $ds(pending) \
diskreallocated $ds(realloc) \
disktemp $ds(temp) \
diskuncorrectable $ds(uncorr) \
dlnastatus [system dlnastatus] \
encryptionkey [system encryptionkey] \
fhtcpversion [system fhtcpversion] \
hostname [::js::escape [system hostname]] \
idletime [system idletime] \
instandby [system instandby] \
kernelver [system kernelver] \
loaderver [system loaderver] \
macaddr [system macaddr] \
modbuild [system modbuild] \
model [system model] \
modversion [system modversion] \
nuggeted [system nuggeted] \
pkgver [system pkgver] \
restartpending [system isrestartpending] \
serialno [regsub -all -- {[[:space:]]+} [system serialno] ""] \
shutdown 0 \
smarttesting [system is_smarttesting] \
systemid [system systemid] \
timestamp [clock milliseconds] \
tuners [system tuners] \
uptime [system uptime]
puts [json::encode $vars obj]
}

View File

@@ -1,23 +0,0 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
package require json
require epg.class
if {[lindex $argv 0] ne "-i"} { httpheader {application/json} }
catch {
lmap i [$channeldb query "
select usTsId, usNetId, szNetName, (ulFrequency - 306000) / 8000, ucLevel, ucQuality, eSystem
from TBL_TS join TBL_NET where TBL_TS.netIdx=TBL_NET.netIdx
order by 2,1
"] {
lassign $i x tsid x netid x netname x channel x siglev x quality x modulation
set modulation $($modulation == 0 ? "DVB-T" : "DVB-T2")
lappend vars [list tsid $tsid netid $netid netname [system strip $netname] channel $channel \
level $siglev quality $quality modulation $modulation]
}
puts [json::encode [list muxes $vars] {obj muxes
{list obj tsid num netid num channel num level num quality num}}]
}

View File

@@ -1,20 +0,0 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
package require json
require pkg.class
set interactive $([lindex $argv 0] == "-i")
if {$interactive} {
set type [lindex $argv 1]
if {$type eq ""} { set type "" }
} else {
package require cgi
set type [cgi_get type ""]
httpheader {application/json}
}
catch {
set pkgs [pkg instmode $type]
puts [json::encode [list packages $pkgs] {obj packages {list obj auto bool}}]
}

View File

@@ -1,20 +0,0 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
package require json
require epg.class
if {[lindex $argv 0] ne "-i"} { httpheader {application/json} }
catch {
lmap i [$channeldb query "
select usLcn, szSvcName, usSvcId, usTsId
from TBL_SVC
order by 1
"] {
lassign $i x lcn x name x svcid x tsid
lappend vars [list lcn $lcn name [system strip $name] service $svcid tsid $tsid]
}
puts [json::encode [list services $vars] {obj services {list obj lcn num service num tsid num}}]
}

View File

@@ -103,8 +103,6 @@ if {[llength $plugins(dmenu)]} {
}
}
# the maxlength values for title and synopsis are 1 less than the maximum to
# allow for an extra byte to indicate character encoding (see rename.jim)
puts {
</ul>
@@ -133,51 +131,20 @@ puts {
</th>
<td>
<input type=text name="rename_title" id="rename_title"
value="" size=70 maxlength=47
value="" size=70 maxlength=48
class="text ui-widget-content ui-corner-all">
</td>
</tr>
<tr style="display: none" class=tstype>
<th>
<label for="rename_seriesnum" style="padding-top: 0.5em">
<b>New Series Number</b>
</label>
</th>
<td>
<span title="Series number">
<input type=number name="rename_seriesnum" id="rename_seriesnum"
value=0 max=255
class="uint8_t ui-widget-content ui-corner-all">
</span>
<label for="rename_episodenum" style="padding-top: 0.5em">
<b>Episode</b>
</label>
<span title="Episode number">
<input type=number name="rename_episodenum"
id="rename_episodenum" value=0 max=255
class="uint8_t ui-widget-content ui-corner-all">
</span>
<label for="rename_episodetot" style="padding-top: 0.5em">
<b>of</b>
</label>
<span title="Episode total">
<input type=number name="rename_episodetot"
id="rename_episodetot" value=0 max=255
class="uint8_t ui-widget-content ui-corner-all">
</span>
</td>
</tr>
<tr style="display: none" class=tstype>
<th>
<label for="rename_synopsis" style="padding-top: 0.5em">
<b>New Synopsis</b>
</label>
</th>
<td colspan=3>
<td>
<textarea name="rename_synopsis" id="rename_synopsis"
value="" cols=70 rows=4 maxlength=251
value="" cols=70 rows=4
class="text ui-widget-content ui-corner-all"></textarea>
</td>
</tr>

View File

@@ -9,18 +9,14 @@ jqplugin progressbar
jscss audio.js
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set dir [file dirname $rfile]
set len [$ts duration 1]
set s [settings]
set type [$s audiomp3descr [$s audiomp3]]
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
puts "
<fieldset class=cleft>
@@ -50,4 +46,3 @@ Extracting audio: <div id=progressbar></div>
"
footer

View File

@@ -8,8 +8,7 @@ require ts.class system.class settings.class
httpheader
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} { return }
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -22,9 +21,9 @@ puts "Processing $shname"
set slow [[settings] audiomp3]
set token [system startop -multiple mp3 $rfile]
puts [$ts mkmp3 false $slow]
puts [$ts mkmp3 $slow]
system endop $token
set xtime $(([clock milliseconds] - $xstart) / 1000.0)
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
puts "Time taken: $xtime"

View File

@@ -14,9 +14,9 @@ if {![file exists "${bfile}.mp3"]} {
puts "0"
} else {
set sz [file size $rfile]
set nsz $([file size "${bfile}.mp3"] / 0.3)
set nsz [expr [file size "${bfile}.mp3"] / 0.3]
set perc $($nsz * 100 / $sz)
set perc [expr $nsz * 100 / $sz]
if {$perc > 100} { set perc 100 }
puts $perc
}

View File

@@ -2,29 +2,22 @@
package require cgi
source /mod/webif/lib/setup
require ts.class system.class pretty_size
require ts.class pretty_size
jscss script.js style.css
jqplugin touchpunch
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set ts [ts fetch $rfile]
set dir [string map {' \\'} [file dirname $rfile]]
set erfile [string map {' \\'} $rfile]
set len [$ts duration 1]
set start -1
set incr 1
set limit $(1-$start)
puts "
<script type=text/javascript>
var initbookmarks = '[$ts bookmarks]';
var len = [$ts duration 1];
var file = '$erfile';
var dir = '$dir';
@@ -32,61 +25,25 @@ var dir = '$dir';
<fieldset class=cleft>
<legend>Manage Bookmarks</legend>
<table class=keyval>
<table class=keyval cellpadding=5>
<tr><th>File:</th><td>$rfile</td></tr>
<tr><th>Length:</th><td>[clock format $len -format %T]</td></tr>
<tr><th>Size:</th><td>[pretty_size [$ts size]] ([$ts get definition])</td></tr>
<tr><th>Bookmarks<br><span class=footnote>(enter in seconds)</span></th><td>
<input id=bookmarks size=80 maxlength=255 value=\"[$ts bookmarks]\" />
<input id=bookmarks size=80 maxlength=255 init=\"[$ts bookmarks]\"
value=\"\" />
<button id=update>Update</button>
<br>
<span id=bookmarkstime></span>
</td></tr><tr><td class=cell-align-right>
</td></tr><tr><td align=right>
<button class=left id=addbmark>Add Bookmark</button>
<button class=left id=delbmark>Remove Bookmark</button>
</td><td><div id=slider></div></td></tr>
<tr><td class=cell-align-right>
<span class=left>Current: <span id=curbmk></span></span><br><br><br>
"
if {![$ts flag "ODEncrypted"]} {
puts "
<button id=genthumbs title=\"Generate Thumbnails\"
class=left>Generate Thumbnails</button>
"
}
puts "
</td><td>
<div id=thumbs class=hidden>
<table><tr>
"
set times {}
loop v $start $limit $incr {
lappend times $v
puts "
<th class=mark><span class=mark>
[format "%+d" $v]</span>s</th>
"
}
puts "</tr><tr>"
foreach v $times {
puts "<td><img class=bmp data-pos=$v alt=\"thumbnail @ $v s\"></td>"
}
puts "
</tr></table>
</div></td></tr>
</table>
<div id=buttons>
<button id=save>Save Bookmarks</button>
<button id=back>Back to Media Browser</button>
"
if {[system pkginst nicesplice]} {
puts "<button id=crop>Go to Crop</button>"
}
puts "
</div>
<div id=results class=\"hidden blood\"></div>
</fieldset>
"
footer

View File

@@ -14,8 +14,7 @@ if {[system inuse $file]} {
exit
}
set ts [ts fetch_or_error $file]
if {$ts != 0} {
$ts setbookmarks [split [string trim $bookmarks]]
puts "Bookmarks saved successfully."
}
set ts [ts fetch $file]
$ts setbookmarks [split [string trim $bookmarks]]
puts "Bookmarks saved successfully."

View File

@@ -1,225 +1,132 @@
/* using var len defined in inline script, index.jim */
/* using var file defined in inline script, index.jim */
/* using var dir defined in inline script, index.jim */
var curval = 0;
var $slider;
function
toTimeStr(tval)
setvals()
{
return new Date(null, null, null, null, null, tval)
.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0];
values = $.trim($('#bookmarks').val()).split(/ +/);
if (!values.length || values[0] == '')
{
refreshtimes();
return;
}
nvalues = [];
$.each(values, function(k, v) {
if (v > len)
v = len;
if (v < 0)
v = 0;
nvalues.push(v);
});
values = nvalues;
$('#bookmarks').val(values.join(' '));
sortmarks();
refreshtimes();
}
function
valarray(valstr)
draw_slider()
{
return valstr.trim().split(/\s+/);
if ($slider)
$slider.slider('destroy');
else
$slider = $('#slider');
setvals();
values = $.trim($('#bookmarks').val()).split(/ +/);
if (!values.length || values[0] == '')
{
$slider = null;
return;
}
$slider.slider({
min: 0,
max: len,
step: 1,
values: values,
start: function(event, ui) {
curval = ui.value;
},
stop: function(event, ui) {
curval = ui.value;
sortmarks();
refreshtimes();
},
slide: function(event, ui) {
var marks = '';
for (var i = 0; i < ui.values.length; ++i)
marks += ui.values[i] + ' ';
$('#bookmarks').val($.trim(marks));
setvals();
}
});
};
function
refreshtimes()
{
var t = '';
values = $.trim($('#bookmarks').val()).split(/ +/);
if (!values.length || values[0] == '')
{
$('#bookmarkstime').text(t);
return;
}
$.each(values, function(k, v) {
t += new Date(null, null, null, null, null, v)
.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0] + ' ';
});
$('#bookmarkstime').text(t);
}
function
sortmarks()
{
var a = $.trim($('#bookmarks').val()).split(/ +/);
a.sort(function(a, b){return a-b});
$('#bookmarks').val(a.join(" "));
}
$(function() {
var curval = 0;
var $slider;
var values;
function
sortmarks()
{
values.sort(function(a, b){return a - b});
$('#bookmarks').val(values.join(" "));
}
function
refreshtimes()
{
var t = '';
if (values.length > 0 && values[0] != '')
{
$.each(values, function(k, v) {
if (t != '') t += ', ';
t += toTimeStr(v);
});
$('#slider .ui-slider-handle').each(function(i) {
if (values[i]|0 > 0)
$(this).attr('title', toTimeStr(values[i]))
else $(this).attr('title', '');
});
$('#curbmk').html(toTimeStr(curval));
$('#genthumbs').button('enable');
}
else
{
$('#genthumbs').button('disable');
$('#curbmk').html('');
}
$('#bookmarkstime').text(t);
}
function
setvals()
{
var nvalues;
values = valarray($('#bookmarks').val());
nvalues = new Set();
$.each(values, function(k, v) {
if (v > len)
v = len;
if (v < 0)
v = 0;
nvalues.add(v);
});
values = Array.from(nvalues);
sortmarks();
}
function
regenthumbs(curbmkstr)
{
$('#curbmk').html(curbmkstr);
$('#thumbs').hide();
$('#genthumbs')
.button(curbmkstr ? 'enable': 'disable')
.button('option', 'icon', 'ui-icon-zoomin');
}
function
draw_slider()
{
if ($slider)
$slider.slider('destroy');
else
$slider = $('#slider');
setvals();
$slider.slider({
min: 0,
max: len,
step: 1,
disabled: values.length <= 0 || values[0] == '',
values: values,
start: function(event, ui) {
curval = ui.value;
},
stop: function(event, ui) {
curval = ui.value;
sortmarks();
refreshtimes();
},
slide: function(event, ui) {
var marks = '';
for (var i = 0; i < ui.values.length; ++i)
marks += ui.values[i] + ' ';
$('#bookmarks').val(marks.trim());
setvals();
}
});
refreshtimes();
/* slider values are strings */
var curvalstr = "" + curval;
if (!values.includes(curvalstr)) {
/* try to map current selected bmk to new bmk */
var ovalues = $slider.slider("option", "values");
var nn = ovalues.indexOf(curvalstr);
if (nn < 0) {
curval = 0;
regenthumbs('');
} else {
if (nn >= values.length)
nn = values.length - 1;
if (nn >= 0) {
regenthumbs(toTimeStr(curval = values[nn]));
} else {
curval = 0;
regenthumbs('');
}
}
}
};
$('#genthumbs').button({icons: {primary: "ui-icon-zoomin"}, disabled: true})
.on('click', function() {
var start;
var incr = -1;
var last;
$(this)
.button('disable')
.button('option', 'icon', 'ui-icon-refresh');
$('img.bmp').each(function(i) {
if (start === undefined) {
start = $(this).attr('data-pos') | 0;
} else {
last = $(this).attr('data-pos') | 0;
}
incr++;
$(this).attr('src', '/img/generating.png');
});
$('#thumbs').show();
incr = (last - start) / incr;
$.get('/browse/thumbnail/mkrange.jim', {
'file': file,
's': start+curval,
'e': last+curval,
'i': incr
}, function() {
$('img.bmp').each(function(i) {
/* cast to "int" */
var pos = $(this).attr('data-pos')|0;
$(this).attr('src',
'/browse/thumbnail/fetch.jim?' +
'file=' + encodeURIComponent(file) +
'&pos=' + (curval+pos).toFixed(1));
});
$('#genthumbs').button('option', 'icon', 'ui-icon-zoomin');
});
});
$('#bookmarks').val($('#bookmarks').attr('init'));
draw_slider();
$('#addbmark').button({icons: {primary: "ui-icon-plus"}, text: false})
.on('click', function() {
$('#bookmarks').val('0 ' + $('#bookmarks').val());
draw_slider();
});
$('#addbmark').button({icons: {primary: "ui-icon-plus"}, text: false})
.on('click', function() {
$('#bookmarks').val('0 ' + $('#bookmarks').val());
curval = 0;
draw_slider();
});
$('#delbmark').button({icons: {primary: "ui-icon-minus"}, text: false})
.on('click', function() {
var cur = $('#bookmarks').val();
cur = $.trim(cur.replace(
new RegExp('(^| )' + curval + '( |$)', ''), ' '));
$('#bookmarks').val(cur);
draw_slider();
});
$('#delbmark').button({icons: {primary: "ui-icon-minus"}, text: false})
.on('click', function() {
var cur = $('#bookmarks').val();
cur = cur.replace(
new RegExp('(^| )' + curval + '( |$)', ''), ' ').trim();
$('#bookmarks').val(cur);
draw_slider();
});
$('#save').button({icons: {primary: "ui-icon-disk"}})
.on('click', function() {
$.post('save.jim', {
file: file,
bookmarks: $('#bookmarks').val()
}, function(data) {
$('#results').html(data)
.slideDown('slow').delay(5000).slideUp('slow');
});
});
$('#back').button({icons: {primary: "ui-icon-arrowreturnthick-1-w"}})
.on('click', function() {
window.location = '/go/browse?dir=' + encodeURIComponent(dir);
});
$('#crop').button({icons: {primary: "ui-icon-arrowreturnthick-1-e"}})
.on('click', function() {
window.location =
window.location.href.replace('/bookmarks/?','/crop/crop.jim?');
});
$('#update').button()
.on('click', draw_slider);
$('#slider')
.on('slidechange', function(evt, ui) {
var tstr = toTimeStr(curval);
if (tstr != $('#curbmk').html())
regenthumbs(tstr);
$('#save').button({icons: {primary: "ui-icon-disk"}})
.on('click', function() {
$.post('save.jim', {
file: file,
bookmarks: $('#bookmarks').val()
}, function(data) {
$('#results').html(data)
.slideDown('slow').delay(5000).slideUp('slow');
});
});
$('#back').button({icons: {primary: "ui-icon-arrowreturnthick-1-w"}})
.on('click', function() {
window.location = '/go/browse?dir=' + encodeURIComponent(dir);
});
$('#update').button()
.on('click', function() {
draw_slider();
});
});

View File

@@ -14,20 +14,3 @@
margin-top: 5px;
}
/* <table class=keyval ... cellpadding=5> */
.keyval th, .keyval td
{
padding: 5px;
}
/* <td align=right> */
.cell-align-right
{
text-align: right;
}
/* <th style="text-align: center"> */
th.mark
{
text-align: center;
}

View File

@@ -9,11 +9,7 @@ jscss chunk.js chunk.css
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
# 45 minute chunks
@@ -64,4 +60,3 @@ Back to Media Browser
</fieldset>
"
footer

View File

@@ -18,6 +18,8 @@ set end $($part * 45 * 600 + 600)
puts "START: $start"
puts "END: $end"
set ts [ts fetch $rfile]
set base [file rootname $rfile]
set cmd [list /mod/bin/nicesplice -in $base -out "$base.part$part"]
@@ -28,7 +30,6 @@ puts "CMD: ($cmd)"
puts [exec {*}$cmd]
set ts [ts fetch_or_error "$base.part$part.ts"]
if {$ts != 0} {
$ts settitle "$part/$parts. [string range [ts get $title] 0 40]"
}
set ts [ts fetch "$base.part$part.ts"]
$ts settitle "$part/$parts. [string range [ts get $title] 0 40]"

View File

@@ -82,7 +82,6 @@ switch $action {
set path [$item get path]
set file [file tail $path]
set mode [$item get action]
set fileonly 0
puts "Pasting $file"
@@ -106,13 +105,8 @@ switch $action {
"$dir/[file tail $f]"}
}
}
} else {
set fileonly 1
}
} else {
set fileonly 1
}
if {$fileonly} {
if {$mode eq "cut"} {
catch {file rename $path \
"$dir/[file tail $path]"}

View File

@@ -2,7 +2,7 @@
package require cgi
source /mod/webif/lib/setup
require system.class settings.class ts.class pretty_size
require ts.class pretty_size
jqplugin progressbar iphone-style-checkboxes
jscss crop.js style.css
@@ -10,15 +10,10 @@ header
set rfile [cgi_get file]
set invert [cgi_get invert 0]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
set planwidth 500
puts "
<fieldset>
@@ -34,17 +29,12 @@ puts [join [lmap i [$ts bookmarks 1] {
clock format $i -format "%T"
}] ", "]
# set minimum width as positioned contents doesn't resize its cell
puts "</td></tr><tr><th>&nbsp;</th><td id=cutplan style=\"min-width: ${planwidth}px\">"
puts "</td></tr><tr><th>&nbsp;</th><td id=cutplan>"
puts "<div style=\"position: relative; top: -10px\">"
proc div {type left right} {
set width $($right - $left)
if {$width < 0} {
# negative values are invalid for CSS width
set width 0
}
puts "<div class=$type style=\"left: ${left}px; width: ${width}px\">
$type</div>"
}
@@ -72,10 +62,10 @@ foreach b $bookmarks {
set l $($end - $start)
incr keeping $l
incr cur $l
append newbookmarks "$($cur + 3) "
append newbookmarks "[expr $cur + 3] "
set left $($start * $planwidth / $len)
set right $($end * $planwidth / $len)
set left $($start * 500 / $len)
set right $($end * 500 / $len)
div cut $last $($left - 1)
div keep $left $($right - 1)
@@ -88,11 +78,11 @@ foreach b $bookmarks {
if {$start > 0} {
# Still in a keep section...
incr keeping $($len - $start)
set left $($start * $planwidth / $len)
set left $($start * 500 / $len)
div cut $last $($left - 1)
div keep $left $planwidth
div keep $left 500
} else {
div cut $last $planwidth
div cut $last 500
}
if {$cur > $keeping - 8 && $keeping - 8 > 0} {
@@ -100,11 +90,8 @@ if {$cur > $keeping - 8 && $keeping - 8 > 0} {
}
set keepperc $($keeping * 100.0 / $len)
set esttime $(int($keeping * 0.05))
if {[$ts get definition] eq "HD"} { set esttime $(int($esttime * 1.25)) }
if {[system has sidecar] && ![[settings] noregennts]} {
set esttime $($esttime + int($keeping * 0.08))
}
set esttime $(int($keeping * 0.025))
if {[$ts get definition] eq "HD"} { set esttime $($esttime * 4) }
puts "
</div>
@@ -128,7 +115,7 @@ puts [join [lmap i $newbookmarks {
puts " )</td></tr>"
puts "
<tr id=esttime><th>Time:</th>
<tr><th>Time:</th>
<td>Cropping will take around [clock format $esttime -format "%T"]</td></tr>
</table>
@@ -143,9 +130,9 @@ puts "
<td><button id=invert invert=$invert>Invert selection</button></td>
<td><button id=cropit>Perform crop operation</button></td>
<td>
<label id=saveitlabel for=saveit>Save new bookmarks?</label>
Save new bookmarks?
<input id=saveit type=checkbox name=saveit checked>
&nbsp;
<label id=saveitlabel for=saveit>&nbsp;</label>
</td>
</tr></table>
</div>
@@ -161,4 +148,3 @@ Cropping: <div id=progressbar></div>
</fieldset>
"
footer

View File

@@ -1,5 +1,12 @@
var handle = 0;
function escapestring(str)
{
str = JSON.stringify(String(str));
str = str.substring(1, str.length - 1);
return str;
}
function update()
{
$.get('progress.jim', {
@@ -20,14 +27,13 @@ $('[type="checkbox"]').iphoneStyle({
$('#progressbar').reportprogress(0);
$('#back').button({icons: {primary: "ui-icon-arrowreturnthick-1-w"}})
.on('click', function() {
$('#back').button().click(function() {
window.location = '/go/browse?dir=' + $('#params').attr('dir');
});
$('#save').button({icons: {primary: "ui-icon-disk"}})
.on('click', function() {
$('#progressdiv,#save').hide('slow');
$('#progressdiv,#output,#save').hide('slow');
$.post('../bookmarks/save.jim', {
'file': $('#fileparams').attr('file'),
'bookmarks': $('#bookmarks').attr('val')
@@ -38,17 +44,10 @@ $('#save').button({icons: {primary: "ui-icon-disk"}})
.slideUp('slow');
$('#originalbookmarks')
.html($('#newbookmarks').clone());
$('#esttime').hide();
if ($('#results').html().indexOf(' successful') < 0) {
$('#saveit').hide();
$('#saveitlabel').hide();
$('#save').show();
}
});
});
$('#cropit').button({icons: {primary: "ui-icon-scissors"}})
.on('click', function() {
$('#cropit').button().click(function() {
$('#cropdiv').hide('slow');
$('#progressdiv').show('slow');
$('#back').hide();
@@ -57,7 +56,7 @@ $('#cropit').button({icons: {primary: "ui-icon-scissors"}})
.load('execute.jim', {
'file': $('#params').attr('file'),
'invert': $('#invert').attr('invert')
}, function() {
}, function() {
clearInterval(handle);
handle = 0;
$('#back,#save').show();
@@ -74,10 +73,10 @@ $('#cropit').button({icons: {primary: "ui-icon-scissors"}})
});
});
$('#invert').button({icons: {primary: "ui-icon-shuffle"}})
.on('click', function() {
window.location = window.location.href.replace(/&invert=[01]/,'') +
'&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
$('#invert').button().on('click', function() {
window.location = 'crop.jim?file=' +
escapestring($('#params').attr('file')) +
'&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
});
});

View File

@@ -2,7 +2,7 @@
package require cgi
source /mod/webif/lib/setup
require system.class settings.class ts.class pretty_size
require ts.class pretty_size system.class
httpheader
@@ -15,7 +15,6 @@ if {[system inuse $rfile]} {
}
set ts [ts fetch_or_error $rfile]
if {$ts == 0} { return }
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -51,7 +50,7 @@ set cmd [list /mod/bin/nicesplice \
-out "$dir/$shname"]
if {$invert} {
if {([llength $bookmarks] % 2) != 0} {
if {[expr [llength $bookmarks] % 2] != 0} {
lappend bookmarks [$ts duration 1]
}
foreach k [array names bookmarks] {
@@ -64,19 +63,18 @@ if {$invert} {
#puts "CMD: $cmd"
set token [system startop -multiple crop $rfile]
catch {puts [exec {*}$cmd]}
puts [exec {*}$cmd]
system endop $token
set newname "$shname-[clock seconds]"
puts "Renaming file group to $newname"
puts "<span class=hidden id=fileparams file=\"$dir/$newname.ts\"></span>"
ts renamegroup "$dir/$shname.ts" $newname
if {[system has sidecar] && ![[settings] noregennts]} {
set cmd [list /mod/bin/sidecar -n]
lappend cmd "$dir/$newname"
puts "Regenerating .nts file"
catch {puts [exec {*}$cmd]}
}
exec /mod/bin/hmt "+setfilename=$newname" "$dir/$newname.hmt"
# New nicesplice shrinks whilst cropping.
# No longer required - nicesplice now sets this flag.
#exec /mod/bin/hmt "+shrunk" "$dir/$newname.hmt"
set croptime [expr [expr [clock milliseconds] - $cropstart] / 1000.0]
puts "Time taken: $croptime"
set croptime $(round(([clock milliseconds] - $cropstart) / 1000.0))
puts "Time taken: ${croptime} seconds"

View File

@@ -2,6 +2,7 @@
package require cgi
source /mod/webif/lib/setup
require ts.class
httpheader
@@ -11,14 +12,15 @@ set tsfile [cgi_get file]
set origfile "[file dirname $tsfile]/_original/[file tail $tsfile]"
set newfile [file rootname $tsfile]
if {[catch {
set nsz [file size $newfile]
if {![file exists $newfile]} {
puts "0"
} else {
set sz [file size $origfile]
set expected $($sz / 100 * $perc)
set nsz [file size $newfile]
set perc $($nsz * 100 / $expected)
set perc [expr $nsz * 100 / $expected]
if {$perc > 100} { set perc 100 }
puts $perc
}]} {
puts "100"
}

View File

@@ -11,8 +11,3 @@ div.sliderlabel
line-height: 40px;
}
#cutplan {
/* ensure cut plan segments are aligned left */
padding-left: 0;
}

View File

@@ -9,18 +9,14 @@ jqplugin progressbar
jscss decrypt.js
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set dir [file dirname $rfile]
set len [$ts duration 1]
set mode "dlna"
if {[system model] eq "HD"} { set mode "direct" }
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
if {$mode eq "dlna"} {
if {![system is_listening 9000]} {
puts {
@@ -71,4 +67,3 @@ Decrypting: <div id=progressbar></div>
</fieldset>
"
footer

View File

@@ -9,8 +9,7 @@ httpheader
set rfile [cgi_get file]
set mode [cgi_get mode dlna]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} { return }
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -99,6 +98,6 @@ if {$mode eq "dlna"} {
}
}
set xtime $(([clock milliseconds] - $xstart) / 1000.0)
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
puts "Time taken: $xtime"

View File

@@ -22,6 +22,6 @@ if {![file exists "$file"]} {
set sz [file size $rfile]
set nsz [file size "$file"]
puts $($nsz * 100 / $sz)
puts [expr $nsz * 100 / $sz]
}

View File

@@ -12,17 +12,18 @@ puts "<div id=deleting class=blood><img src=/img/spin.gif>De-queuing...</div>"
puts "<ul style=\"list-style-type: square\">"
foreach file [cgi_get files] {
set ts [ts fetch $file]
if {$ts eq 0} continue
puts -nonewline "<li>\"$file\"..."
if {[string first "$dir/" $file] != 0} {
puts "Error - outside directory."
} else {
queue delete $ts
continue
}
set ts [ts fetch $file]
if {$ts eq "0"} continue
queue delete $ts
puts "</li>"
}
puts "</ul>"

View File

@@ -10,7 +10,7 @@ set urlbase [cgi_get base ""]
# Default to just downloading the raw file.
set url $file
set mime "video/mp2t"
set mime "video/ts"
if {[string match {*.ts} $file]} {
if {![catch {set ts [ts fetch $file]}]} {

View File

@@ -7,6 +7,7 @@ require ts.class
httpheader
set file [cgi_get file]
set ts [ts fetch $file]
if {[set ts [ts fetch $file]] != 0} {
set action enc
if {[$ts flag "Encrypted"]} { set action unenc }

View File

@@ -9,15 +9,11 @@ httpheader "application/json"
set file [cgi_get file]
if {$file == 0} exit
set ts [ts fetch $file]
if {$ts == 0} exit
puts "{"
puts "\"title\" : \"[jescape [$ts get title]]\","
puts "\"synopsis\" : \"[jescape [$ts get synopsis]]\","
puts "\"guidance\" : \"[jescape [$ts get guidance]]\","
puts "\"genre\" : [jescape [$ts genrenib]],"
puts "\"seriesnum\" : [jescape [$ts get seriesnum]],"
puts "\"episodenum\" : [jescape [$ts get episodenum]],"
puts "\"episodetot\" : [jescape [$ts get episodetot]]"
puts "\"genre\" : [jescape [$ts genrenib]]"
puts "}"

View File

@@ -6,11 +6,5 @@ source /mod/webif/lib/setup
httpheader
set file [cgi_get file]
set log ""
catch {set log [exec /mod/bin/ffprobe -hide_banner -v level $file]}
set log [lsearch -all -regexp -inline [split $log "\n"] "^\\\[info\\\]"]
if {[regsub -all -line -- "^\\\[info\\\]" [join $log "\n"] "" log]} {
puts $log
} else {
puts None
}
puts [exec /mod/bin/ffprobe -hide_banner $file]

View File

@@ -13,22 +13,11 @@ if {$file == 0} exit
set sz [pretty_size [file size $file]]
set flags {}
set url ""
set ts 0
# assumption: the type is only ts if fetch has already been checked
if {$type eq "ts"} {
require epg.class ts.class
set ts [ts fetch $file 1]
} elseif {$type eq "bad"} {
require epg.class ts.class
set ts [ts fetch $file]
set ts [ts fetchhmt $file]
}
if {$ts != 0} {
# Causes other series information to be automatically populated
set epname [$ts episode_name]
set series [$ts series_name]
@@ -161,77 +150,76 @@ if {$ts != 0} {
<td>"
puts [clock format [$ts get end] -format "%c %Z"]
puts "<font class=also>(Scheduled: [clock format \
$([$ts get schedstart] + [$ts get scheddur]) \
[expr [$ts get schedstart] + [$ts get scheddur]] \
-format "%c %Z"])</font>"
set duration [$ts duration]
set durmins $($duration == 1 ? "minute" : "minutes")
set resume [$ts get resume]
set resmins $($resume == 1 ? "minute" : "minutes")
puts "</td>
</tr><tr>
<th>Duration</th>
<td>$duration $durmins.
<font class=also>(Scheduled: $([$ts get scheddur] / 60))
<td>[$ts duration] minute(s).
<font class=also>(Scheduled: [expr [$ts get scheddur] / 60])
</font></td>
</tr><tr>
<th>Status</th>
<td>[$ts get status]</td>
</tr><tr>
<th>Resumes</th>
<td>$($resume / 60) $resmins into recording.
[progressbar $($resume * 100 / [$ts duration 1])]
<td>[expr [$ts get resume] / 60] minutes into recording.
[progressbar $([$ts get resume] * 100 / [$ts duration 1])]
</td>
</tr><tr>
<th>Size</th>
<td>$sz</td>
"
lassign [$ts dlnaloc] url
if {$url ne ""} {
lassign [$ts dlnaloc] url
if {$url ne ""} {
puts "</tr><tr><th>DLNA&nbsp;URL</th>
<td><a href=\"$url\">$url</a></td>"
<td><a href=\"$url\">$url</a></td>"
}
puts "
puts "
</tr><tr>
<th>Files</th>
<td>
"
set fileset [$ts fileset]
puts -nonewline "<img class=collapser x=fileset id=xfileset class=va
set fileset [$ts fileset]
puts -nonewline "<img class=collapser x=fileset id=xfileset class=va
src=/img/tree/plusonly.png>"
puts -nonewline "[llength $fileset] file"
if {[llength $fileset] != 1} { puts -nonewline "s" }
puts -nonewline " in set."
puts "<div id=fileset class=hidden><ul>"
foreach f $fileset {
puts "<li>[file tail $f] ([pretty_size [file size $f]])</li>"
}
puts "</ul></div>"
puts -nonewline "[llength $fileset] file"
if {[llength $fileset] != 1} { puts -nonewline "s" }
puts -nonewline " in set."
puts "<div id=fileset class=hidden><ul>"
foreach f $fileset {
puts "<li>[file tail $f] ([pretty_size [file size $f]])</li>"
}
puts "</ul></div>"
puts "</td></tr>"
puts "</td></tr>"
eval_plugins browsetsfile
eval_plugins browsetsfile
puts "<tr>
puts "<tr>
<th>Flags</th>
<td>[set flags [$ts get flags]]</td>
</tr>
<td>[$ts get flags]</td>
</tr>
"
if {[$ts get bookmarks]} {
if {[$ts get bookmarks]} {
puts "
<tr>
<tr>
<th>Bookmarks</th>
<td>[$ts get bookmarks] @ [join [lmap i [$ts bookmarks 1] {
clock format $i -format "%T"
}] ", "]
</td>
</tr>
"
}
</tr>
"
}
puts "<div class=hidden id=file>$file</div>"
puts {
puts "
</table>
"
puts "<div class=hidden id=file>$file</div>"
puts {
<script type=text/javascript>
var file = $('#file').text();
$('button').button();
@@ -267,12 +255,13 @@ $('img.rollimg').hover(
);
</script>
}
}
exit
}
} else {
# Otherwise, for a general file.
puts "
puts "
<table class=keyval>
<tr>
<th>File</th>
@@ -280,52 +269,20 @@ $('img.rollimg').hover(
</tr><tr>
<th>Size</th>
<td>$sz</td>
</tr>"
}
set hasffmpeg 0
proc ffinfo {} {
puts "<tr>
<th>Info</th>"
if {$::hasffmpeg} {
puts " <td class=pre id=ffmpeg>
<img src=/img/spin.gif><i>Loading...</i>
</td>"
} else {
puts "<td>Encrypted</td>"
}
puts "</tr>"
}
if {$type eq "ts"} {
if {$url ne ""} {
puts [format {
<script type="text/javascript">
$('#playDL').attr('href','%s').enable();
</script> } $url]
}
} elseif {$type ne "bad"} {
if {[string tolower [file extension $file]] != ".ts"} {
set hasffmpeg 1
} else {
if {![exec /mod/bin/stripts -qE [file rootname $file]]} {
set hasffmpeg 1
}
}
ffinfo
}
puts "
</tr><tr>
<th>Info</th>
<td class=pre id=ffmpeg>
<img src=/img/spin.gif><i>Loading...</i>
</td>
</tr>
</table>
"
if {$hasffmpeg} {
set url "/browse/ffmpeg.jim?file=[cgi_quote_url $file]"
puts [format {
<script type="text/javascript">
var url = "%s";
$('#ffmpeg').load(url, function() { $('#play, #playDL').enable(); });
</script> } $url]
set url "/browse/ffmpeg.jim?file=[cgi_quote_url $file]"
puts { <script type="text/javascript"> }
puts "var url = \"$url\";"
puts {
$('#ffmpeg').load(url);
</script>
}

View File

@@ -20,7 +20,8 @@ header
set nicesplice [system pkginst nicesplice]
source /mod/webif/include/extensions.jim
set ignore {.nts .thm .hmi}
set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov .hmt .m4v .m4a}
if {![dict exists $env SCRIPT_NAME]} {
set env(SCRIPT_NAME) ""
@@ -57,10 +58,6 @@ proc icon {img {hover ""} {extra ""} {class "va"}} {
puts ">"
}
proc nbsp {str} {
return [string map {" " &nbsp;} $str]
}
proc directory {file bfile tbfile} {
puts "<div class=\"va relative\">"
set img "/images/711_1_09_Media_Folder.png"
@@ -72,7 +69,7 @@ proc directory {file bfile tbfile} {
puts "<a class=dbf
href=\"$::env(SCRIPT_NAME)?dir=[cgi_quote_url $file]\"
file=\"[cgi_quote_html $file]\">"
puts "[nbsp $bfile]</a><span class=filesize id=\"ID$tbfile\">
puts "$bfile</a><span class=filesize id=\"$tbfile\">
</span>"
lassign [dir iconset $file] icons attrs
@@ -109,12 +106,13 @@ proc entry {file} {{i 0}} {
global dircount filecount dinuse
set bfile [file tail $file]
regsub -all " +" $bfile "" tbfile
if {[string index $bfile 0] == "\025"} {
set bfile [string range $bfile 1 end]
}
if {[file isdirectory "$file"]} {
incr dircount
directory $file $bfile [b64uencode [jsescape $bfile]]
directory $file $bfile $tbfile
return
}
set ext [string tolower [file extension $file]]
@@ -138,14 +136,6 @@ proc entry {file} {{i 0}} {
set img Video_Failed
}
set omenu opt
if {[$ts get definition] eq ""} {
set type gen
set ts 0
set img Video_Other
set omenu oopt
} else {
set omenu opt
}
if {[file exists "${base}.thm"]} { set thmok 1 }
} elseif {$ext eq ".hmt"} {
if {[file exists "${base}.ts"]} { return }
@@ -184,7 +174,7 @@ proc entry {file} {{i 0}} {
<input class=\"$fscl\" type=checkbox>
<a class=bf title=\"$synopsis\"
file=\"[cgi_quote_html $file]\" type=$type href=#>
[nbsp $bfile]
$bfile
</a>
"
@@ -302,7 +292,7 @@ if {$parent ne ""} {
"
}
proc s_file_stat {a b attr {rev 0}} {
proc s_file_stat {a b attr} {
global dir
set a "$dir/$a"
@@ -324,8 +314,8 @@ proc s_file_stat {a b attr {rev 0}} {
if {[catch {file stat $b l}]} { return 0}
set bt $l($attr)
if {$at < $bt} { return $($rev ? 1 : -1) }
if {$at > $bt} { return $($rev ? -1 : 1) }
if {$at < $bt} { return -1 }
if {$at > $bt} { return 1 }
return 0
}
@@ -333,36 +323,16 @@ proc s_time {a b} {
tailcall s_file_stat $a $b mtime
}
proc s_time_r {a b} {
tailcall s_file_stat $a $b mtime 1
}
proc s_size {a b} {
tailcall s_file_stat $a $b size
}
proc s_size_r {a b} {
tailcall s_file_stat $a $b size 1
}
proc s_ext {a b} {
set at [file extension $a]
set bt [file extension $b]
if {$at == $bt} {
return [string compare -nocase $a $b]
} else {
return [string compare -nocase $at $bt]
}
}
set files [readdir -nocomplain $dir]
switch $order {
1 { set files [lsort -command s_time $files] }
2 { set files [lsort -command s_time_r $files] }
2 { set files [lreverse [lsort -command s_time $files]] }
3 { set files [lsort -command s_size $files] }
4 { set files [lsort -command s_size_r $files] }
5 { set files [lsort -command s_ext $files] }
6 { set files [lsort -dict $files] }
4 { set files [lreverse [lsort -command s_size $files]] }
default { set files [lsort -nocase $files] }
}
@@ -370,21 +340,19 @@ set dinuse [system dirinuse $dir]
foreach file $files { entry "$dir/$file" }
puts "
Select: <a href=# id=selectall>All</a> | <a href=# id=deselectall>None</a>
&nbsp;&nbsp;Folders: $dircount, Files: $filecount
<a href=# id=selectall>Select all</a> | <a href=# id=deselectall>none</a>
&nbsp;&nbsp;
Directories: $dircount, Files: $filecount
"
# Sort icons
puts "<div id=sortdiv>"
set sortlist {
{0 sort_name Name {Alphanumeric order}}
{6 sort_name Natural {Dictionary order}}
{5 sort_type Type {Type A->Z}}
{1 sort_date Date {Oldest first}}
{2 sort_date Reverse-date {Newest first}}
{3 sort_size Size {Smallest first}}
{4 sort_size Reverse-size {Largest first}}
}
{0 sort_name name {Alphabetical order A->Z}}
{1 sort_date date {Oldest first}}
{2 sort_date reverse-date {Newest first}}
{3 sort_size size {Smallest first}}
{4 sort_size reverse-size {Largest first}}}
puts "
Sort by: "
foreach sl $sortlist {
@@ -394,7 +362,7 @@ foreach sl $sortlist {
set tag " (current)"
if {$order != $index} {
set qs [regsub -all {&order=[[:digit:]]+} $env(QUERY_STRING) ""]
set qs [regsub -all {&order=[[[:digit:]]+} $env(QUERY_STRING) ""]
puts "<a href=\"$env(SCRIPT_NAME)?$qs&order=$index\" title=\"$tt\">"
set tag ""
set ket "a"
@@ -423,14 +391,9 @@ File Clipboard
puts {
<div class=buttonrow>
<button id=newdir>New Folder</button>
<button id=copy class=onesel>Copy</button>
<button id=cut class=onesel>Cut</button>
<button id=delete class=onesel>Delete</button>
}
# Join
if {$nicesplice} {
puts { <button id=join class=tstwosel>Join</button> }
<button id=dedup><img src=/img/dedup.png width=16>
De-duplicate/tidy this folder</button>
<button id=queue><img src=/img/queueps.png class=qb> View Queue</button>
}
# Streamer file
@@ -443,9 +406,19 @@ if {[file exists /mnt/hd3/Streamer_down_file]} {
</button>
}
}
puts "</div>"
# Buttons dependent on selection
puts {
<div class=buttonrow>
<button id=copy class=onesel>Copy</button>
<button id=cut class=onesel>Cut</button>
<button id=delete class=onesel>Delete</button>
}
# Join
if {$nicesplice} {
puts { <button id=join class=tstwosel>Join</button> }
}
# Queue
set queueactions(decrypt) "Decryption"
if {$model ne "HD"} {
@@ -459,10 +432,6 @@ set queueactions(mpg) "Conversion to MPG"
eval_plugins queueactions
puts {
<div class=buttonrow>
<button id=dedup><img src=/img/dedup.png width=16>
De-duplicate/tidy this folder</button>
<button id=queue><img src=/img/queueps.png class=qb> View Queue</button>
<button id=so_queue class=tsonesel><img src=/img/queueps.png class=qb>
Queue for</button>
<select id=so_queueactions

View File

@@ -22,13 +22,12 @@ lappend cmd "-out" "$dir/$dst"
puts "($cmd)"
set token [system startop -multiple join "$dir/$dst"]
catch {puts [exec {*}$cmd]}
puts [exec {*}$cmd]
system endop $token
set ts [ts fetch_or_error "$dir/$dst.ts"]
if {$ts != 0} {
$ts settitle $dst
set ts [ts fetch "$dir/$dst.ts"]
$ts settitle $dst
set jointime [expr [expr [clock milliseconds] - $joinstart] / 1000.0]
puts "Time taken: $jointime"
set jointime $(([clock milliseconds] - $joinstart) / 1000.0)
puts "Time taken: $jointime"
}

View File

@@ -23,18 +23,16 @@ foreach file [split [cgi_get files] ","] {
set file [cgi_unquote_input $file]
set dir [file dirname $file]
set ts [ts fetch $file]
if {$ts != 0} {
puts "<li class=\"va ui-state-default\" id=\"$file\"><span
class=\"va ui-icon ui-icon-arrowthick-2-n-s\"></span>
<img class=va src=/img/Video_TS.png>
<span class=pl>
$file ([clock format [$ts duration 1] -format "%T"])
\[[pretty_size [$ts size]]\]
<br><i style=\"font-size: 0.8em\">[$ts get title]</i>
</span>
</li>"
incr esize [$ts size]
}
puts "<li class=\"va ui-state-default\" id=\"$file\"><span
class=\"va ui-icon ui-icon-arrowthick-2-n-s\"></span>
<img class=va src=/img/Video_TS.png>
<span class=pl>
$file ([clock format [$ts duration 1] -format "%T"])
\[[pretty_size [$ts size]]\]
<br><i style=\"font-size: 0.8em\">[$ts get title]</i>
</span>
</li>"
incr esize [$ts size]
}
puts "</ul>"
@@ -58,3 +56,4 @@ Joining: <div id=progressbar></div>
"
footer

View File

@@ -16,7 +16,7 @@ if {![file exists $file]} {
} else {
set sz [file size $file]
set perc $($sz * 100 / $expected)
set perc [expr $sz * 100 / $expected]
if {$perc > 100} { set perc 100 }
puts $perc
}

View File

@@ -7,6 +7,7 @@ require ts.class
httpheader
set file [cgi_get file ""]
set ts [ts fetch $file]
if {[set ts [ts fetch $file]] != 0} {
set action lock
if {[$ts flag "Locked"]} { set action unlock }

View File

@@ -9,7 +9,7 @@ httpheader "application/json"
set dir [cgi_get dir "/media/My Video/test"]
puts "{"
foreach file [readdir -nocomplain $dir] {
foreach file [readdir $dir] {
if {[file extension $file] ne ".mp3"} continue
if {[catch {

View File

@@ -8,8 +8,7 @@ require ts.class system.class
httpheader
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} { return }
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -19,6 +18,6 @@ set token [system startop -multiple mpg $rfile]
$ts mkmpg
system endop $token
set xtime $(([clock milliseconds] - $xstart) / 1000.0)
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
puts "Time taken: $xtime"

View File

@@ -10,11 +10,7 @@ jscss mpg.js
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -47,4 +43,3 @@ Extracting mpg: <div id=progressbar></div>
"
footer

View File

@@ -14,9 +14,9 @@ if {![file exists "${bfile}.mpg"]} {
puts "0"
} else {
set sz [file size $rfile]
set nsz $([file size "${bfile}.mpg"] / 0.75)
set nsz [expr [file size "${bfile}.mpg"] / 0.75]
set perc $($nsz * 100 / $sz)
set perc [expr $nsz * 100 / $sz]
if {$perc > 100} { set perc 100 }
puts $perc
}

View File

@@ -7,6 +7,7 @@ require ts.class
httpheader
set file [cgi_get file]
set ts [ts fetch $file]
if {[set ts [ts fetch $file]] != 0} {
set action new
if {[$ts flag "New"]} { set action watched }

View File

@@ -1,63 +0,0 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require system.class
require ts.class
set file [cgi_get file]
set urlbase [cgi_get base ""]
set duration [cgi_get duration 1]
set fmts [split [cgi_get fmts ""] ","]
set vc [cgi_get vc ""]
# Default to just downloading the raw file.
set url $file
# Prefer to use DLNA server ... (necessary if encrypted)
set dlna [system dlnaurl [file normalize $url] $urlbase]
if {[llength $dlna]} {
set url [lindex $dlna 0]
} elseif {[regexp {^(https?://(.+:.*@)?[[:alnum:].]+(:[[:digit:]]+)?)/} $urlbase x y]} {
set url "$y$url"
} else {
set url "http://[system ip]$url"
}
if {[file extension $file] in {.ts .TS}} {
if {![catch {set ts [ts fetch $file]}] && $ts != 0} {
set duration [$ts duration 1]
$ts set_watched
}
}
set file [file tail $file]
set playlist [file tempfile "[env "TMPDIR" [env "TMP" "/tmp"]]/playXXXXXX"]
set pl ""
try {
set pl [open $playlist w]
$pl puts "#EXTM3U"
$pl puts "#EXTINF:$duration,$file"
$pl puts "#PLAYLIST:$file"
$pl puts [cgi_quote_url $url]
} finally {
if {$pl ne ""} {
$pl close
}
}
httpheader "application/x-mpegurl" 0 [list \
"Content-Disposition" "attachment; filename=\"[file rootname $file].m3u\"" \
"Content-Length" "[file size $playlist]" \
]
set pl ""
try {
set pl [open $playlist r]
$pl copyto stdout
} finally {
if {$pl ne ""} {
$pl close
}
}
catch {file delete $playlist}

View File

@@ -17,21 +17,22 @@ puts "<div id=deleting class=blood><img src=/img/spin.gif>Queuing...</div>"
puts "<ul style=\"list-style-type: square\">"
foreach file [cgi_get files] {
set ts [ts fetch $file]
if {$ts eq 0} continue
puts -nonewline "<li>\"$file\"..."
if {[string first "$dir/" $file] != 0} {
puts "Error - outside directory."
} else {
lassign $act xact args
set q [queue insert -hold $ts $xact]
if {$args ne ""} { $q set args $args }
$q submit
continue
}
set ts [ts fetch $file]
if {$ts eq "0"} continue
lassign $act xact args
set q [queue insert -hold $ts $xact]
if {$args ne ""} { $q set args $args }
$q submit
puts "</li>"
}
puts "</ul>"

View File

@@ -26,57 +26,19 @@ if {[file isdirectory $file]} {
set new [string map {"\n" ""} [
string trim [cgi_get "rename_$attr"]]]
set old [$ts get $attr]
if {$attr eq "genre"} {
set new [ts genre $new]
if {$attr eq "title" || $attr eq "synopsis"} {
set new "\025$new"
}
if {$new ne $old} {
if {$attr eq "guidance" || $new ne ""} {
if {$attr eq "guidance" ||
[string length $new] > 0} {
$ts set$attr $new
}
}
} msg]} {
stderr puts "$attr: $msg"
puts "$attr: $msg"
}
}
# deal with series number/ep num/ep total, which get set together
# list the old values seen in case a later one is changed
set epdataold {}
# list values to be set, or {}
set epdatanew {}
foreach attr {seriesnum episodenum episodetot} {
if {[catch {
set new [string map {"\n" ""} [
string trim [cgi_get "rename_$attr"]]]
set old [$ts get $attr]
if {$new ne $old} {
switch $attr {
seriesnum {
set epdatanew [list $new]
}
episodenum -
episodetot {
if {$epdatanew eq {}} {
set epdatanew $epdataold
}
lappend epdatanew $new
}
}
} elseif {$epdatanew eq {}} {
# nothing to be changed yet
lappend epdataold $old
} else {
# fill to-be-set list with old value
lappend epdatanew $old
}
} msg]} {
stderr puts "$attr: $msg"
}
}
if {$epdatanew ne {}} {
if {[catch {$ts storeepisode $epdatanew} msg]} {
puts "ts::storeepisode: $msg"
}
}
if {"$dir/$newfile.ts" ne "$file"} { ts renamegroup $file $newfile }
} else {

View File

@@ -10,18 +10,6 @@ var plugins = {
dmenu_prepare: {}
};
// pattern matches directory path prefix and suffix
var pathre = /.*\/|\.[^.]*$/g;
// IDs of size, img elements for folders use RFC4648 s5 encoding of name
function folderID(folder)
{
return btoa(escape(folder))
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
}
function blockpage(msg)
{
if (!msg)
@@ -117,21 +105,23 @@ function epginfo_callback(data, status, xhr)
$('#rename_synopsis').val(data.synopsis);
$('#rename_guidance').val(data.guidance);
$('#rename_genre').val(data.genre);
$('#rename_seriesnum').val(data.seriesnum);
$('#rename_episodenum').val(data.episodenum);
$('#rename_episodetot').val(data.episodetot);
$('tr.tstype').show('slow');
}
function insert_folder_size(folder, size)
{
// folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
size += (size.search(/\d$/) == -1 ? 'iB' : ' bytes');
folder = folderID(folder);
folder = folder.replace(/ /g, '');
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
//console.log("Folder: (%s) = (%s)", folder, size);
$(folder == "" ? '#dirsize' : '#ID' + folder)
.text(' (' + size + ')');
if (size.search(/\d$/) == -1)
size += 'iB';
else
size += ' bytes';
if (folder == "")
$('#dirsize').text(' (' + size + ')');
else
$('#' + folder).text(' (' + size + ')');
}
function folder_size_callback(data, status, xhr)
@@ -143,9 +133,11 @@ function folder_size_callback(data, status, xhr)
function set_folder_new(folder, cnt)
{
folder = folder.replace(/ /g, '');
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
//console.log("Folder: (%s) = (%s)", folder, cnt);
left = cnt > 99 ? 11 : (cnt > 9 ? 14 : 17);
$('#img' + folderID(folder))
$('#img' + folder)
.attr('src', '/img/Folder_New.png')
.next('span.foldernum')
.css('left', left + 'px')
@@ -164,8 +156,10 @@ function new_folder_callback(data, status, xhr)
function set_folder__(folder)
{
folder = folder.replace(/ /g, '');
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
//console.log("Folder: (%s)", folder);
$('#img' + folderID(folder) + ' ~ span.folderu').show();
$('#img' + folder + ' ~ span.folderu').show();
}
function __folder_callback(data, status, xhr)
@@ -262,7 +256,7 @@ var $confirm; // Populated after DOM is loaded.
function confirm_action(action, callback, file, type, id)
{
var bfile = file.replace(pathre, '');
var bfile = file.replace(/.*\/|\.[^.]*$/g, '');
$confirm.dialog('option', 'buttons', {
'Yes': function() { $(this).dialog('close');
callback(file, type, id); },
@@ -435,7 +429,7 @@ var menuclick = function(action, el, pos)
{
var file = $(el).parent().prevAll('a.bf').last().attr('file');
var efile = encodeURIComponent(file);
var bfile = file.replace(pathre, '');
var bfile = file.replace(/.*\/|\.[^.]*$/g, '');
bfile = bfile.replace(/[\x00-\x1f]+/g, '');
var type = $(el).attr('type');
var id = $(el).attr('did');
@@ -787,14 +781,12 @@ $('img.doopt').contextMenu(
// Disable items which are not yet implemented.
$('#optmenu').disableContextMenuItems('#title');
var $buttons = [
{ id: 'close',
text: 'Close',
click: function() {$(this).dialog('close');}},
{ id: 'play',
text: 'Play',
click: function() { doplay(this); }}
];
var $buttons = {
"Close" : function() {$(this).dialog('close');}
};
var $buttonsp = $.extend(
{"Play" : function() { doplay(); }},
$buttons);
// Create reusable dialogue.
var $dialog = $('#dialogue').dialog({
@@ -808,56 +800,16 @@ var $dialog = $('#dialogue').dialog({
'<img src="/img/spin.gif">Retrieving data...'); }
});
/* insert button-like Download link before Play */
$('#play').before(function(i){
var dl = document.createElement('a');
dl.setAttribute('class', this.className);
dl.id = this.id + 'DL';
dl.innerHTML = 'Download';
return dl;
});
function doplay(it)
function doplay()
{
var file = $dialog.attr('file');
var type = $dialog.attr('type');
var duration = 0;
var fmts = "";
var vc = ""
var ff = $('#ffmpeg')[0];
disableall();
if (ff) {
/* extract duration, container and video codec from ffmpeg output */
ff = ff.innerHTML;
var match = /Duration:\s+([0-9.:]+),/.exec(ff);
if (match && match[1])
duration = (new Date('1970-01-01T' + match[1] + 'Z')).getTime()/1000;
match = /Input #0,\s+([-A-Za-z0-9_,]+),\s/.exec(ff);
if (match && match[1]) fmts = match[1];
match = /Stream #.+\sVideo:\s+([-A-Za-z0-9_]+)\s/.exec(ff);
if (match && match[1]) vc = match[1];
}
fmts = /mp4|webm/.exec(fmts);
if (fmts && fmts[0])
vc = /h264|av1|vp9/.exec(vc);
else
vc = null;
if (vc && vc[0]) {
/* base on page address to handle client on external network, etc */
var hh = new URL(file, window.location.href);
window.open(hh.href, 'WebIf_Player');
} else {
window.location = '/browse/play.jim?' +
'dir=' + encodeURIComponent(dir) +
'&base=' + encodeURI(window.location.hostname) +
'&duration=' + duration +
'&file=' + encodeURIComponent(file);
}
$(it).dialog('close');
window.location = '/play/play.jim?' +
'dir=' + encodeURIComponent(dir) +
'&file=' + encodeURIComponent(file);
}
// Bind dialogue open to filenames.
@@ -876,27 +828,11 @@ $('a.bf').click(function(e) {
$dialog.attr('file', file);
$dialog.attr('type', type);
$('#playDL').attr('download', file.replace(/.*\//, ''));
$('#play, #playDL').enable();
if (type == 'ts') {
if (opt.attr('odencd') != 0) {
/* encrypted: link to be enabled once populated */
$('#playDL').disable();
/* ... but if no DLNA never Play */
if (opt.attr('dlna') != 1) $('#play').disable();
} else {
/* link unencrypted file directly */
$('#playDL').attr('href', file);
}
} else if (type == 'bad') {
$('#play, #playDL').disable();
} else {
/* generic: enable Play once media file is parsed */
$('#play, #playDL').disable();
$('#playDL').attr('href', file);
}
if (type == 'ts' &&
(opt.attr('odencd') == 0 || opt.attr('dlna') == 1))
$dialog.dialog("option", "buttons", $buttonsp);
else
$dialog.dialog("option", "buttons", $buttons);
$dialog.dialog('open');
});
@@ -1049,7 +985,7 @@ $('#join').button({icons: {primary: "ui-icon-video"}})
.click(function() {
var files = new Array();
var els = $('input.fsts:checked + a').each(function() {
files.push(encodeURIComponent($(this).attr('file')));
files.push($(this).attr('file'));
});
//console.log("%o", files);
window.location.href = '/browse/join/join.jim?files=' +
@@ -1060,7 +996,7 @@ $('#delete').button({icons: {primary: "ui-icon-trash"}})
.click(function() {
var files = new Array();
var els = $('input.fs:checked + a').each(function() {
files.push($(this).attr('file'));
files.push(decodeURIComponent($(this).attr('file')));
});
//console.log("%o", files);
var str = 'Are you sure you want to delete ' + files.length +
@@ -1100,7 +1036,7 @@ $('#copy,#cut')
.click(function() {
var files = new Array();
var els = $('input.fs:checked + a').each(function() {
files.push($(this).attr('file'));
files.push(decodeURIComponent($(this).attr('file')));
});
//console.log("%o", files);
var action = $(this).attr('id');
@@ -1165,7 +1101,7 @@ $('#so_queue').button()
.click(function() {
var files = new Array();
var els = $('input.fs:checked + a').each(function() {
files.push($(this).attr('file'));
files.push(decodeURIComponent($(this).attr('file')));
});
disableall();

View File

@@ -24,7 +24,7 @@ foreach line [split $dutxt "\n"] {
}
# Handle symbolic links.
foreach file [readdir -nocomplain $dir] {
foreach file [readdir $dir] {
set file "$dir/$file"
if {[catch {set lk [file readlink $file]}]} continue

View File

@@ -7,8 +7,7 @@ require system.class ts.class pretty_size
httpheader
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} { return }
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -52,6 +51,6 @@ ts renamegroup "$dir/$shname.ts" $newname
exec /mod/bin/hmt "+setfilename=$newname" "$dir/$newname.hmt"
exec /mod/bin/hmt "+shrunk" "$dir/$newname.hmt"
set striptime $(([clock milliseconds] - $stripstart) / 1000.0)
set striptime [expr [expr [clock milliseconds] - $stripstart] / 1000.0]
puts "Time taken: $striptime"

View File

@@ -17,7 +17,7 @@ if {![file exists $ntsfile]} {
set sz [file size $origfile]
set nsz [file size $ntsfile]
set perc $($nsz * 100 / $sz)
set perc [expr $nsz * 100 / $sz]
if {$perc > 100} { set perc 100 }
puts $perc
}

View File

@@ -9,11 +9,7 @@ jscss strip.js
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -60,4 +56,3 @@ Shrinking: <div id=progressbar></div>
</fieldset>
"
footer

View File

@@ -30,18 +30,3 @@ img.qb
color: #ff4000;
}
input.uint8_t
{
width: 6ch;
}
/* a link that looks like a button */
button + a.ui-button
{
margin-right: 0.4em;
}
.ui-button:link
{
background-color: rgb(254, 206, 47) !important;
}

View File

@@ -9,11 +9,11 @@ httpheader "image/bmp"
set rfile [cgi_get file]
set pos [cgi_get pos 0]
set ts [ts fetch $rfile]
if {$ts != 0} {
if {![catch {set ts [ts fetch $rfile]}]} {
$ts mkbmp $pos ".pos$pos"
set f "[file rootname $rfile].pos$pos.bmp"
cat $f
file delete $f
}

View File

@@ -9,11 +9,7 @@ jscss script.js
header
set rfile [cgi_get file]
set ts [ts fetch_or_error $rfile]
if {$ts == 0} {
footer
return
}
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
@@ -63,11 +59,11 @@ puts "<div style=\"width=100%; text-align: center\">
<input name=pos id=pos size=5 maxlength=4 value=\"$pos\">
second(s) into recording.
</form>
<button class=mvpos pos=$($pos - 30)>&lt;&lt; 30 seconds</button>
<button class=mvpos pos=$($pos - 5)>&lt; 5 seconds</button>
<button class=mvpos pos=[expr $pos - 30]>&lt;&lt; 30 seconds</button>
<button class=mvpos pos=[expr $pos - 5]>&lt; 5 seconds</button>
<button id=repos>Update</button>
<button class=mvpos pos=$($pos + 5)>&gt; 5 seconds</button>
<button class=mvpos pos=$($pos + 30)>&gt;&gt; 30 seconds</button>
<button class=mvpos pos=[expr $pos + 5]>&gt; 5 seconds</button>
<button class=mvpos pos=[expr $pos + 30]>&gt;&gt; 30 seconds</button>
</div>
<span id=start class=hidden>$start</span>
<span id=end class=hidden>$limit</span>
@@ -75,7 +71,7 @@ puts "<div style=\"width=100%; text-align: center\">
<tr>
"
for {set i $($start + 0.0)} {$i <= $limit} {set i $($i + 0.5)} {
for {set i [expr $start + 0.0]} {$i <= $limit} {set i [expr $i + 0.5]} {
lappend times $i
puts "<th style=\"text-align: center\">
@ <span class=mark>$i</span>s</th>"
@@ -99,6 +95,4 @@ foreach i $times {
puts "</tr>"
puts "</table>"
puts "</fieldset>"
footer

View File

@@ -9,13 +9,13 @@ httpheader
set rfile [cgi_get file]
set s [cgi_get s 0]
set e [cgi_get e $($s + 2)]
set i $([cgi_get i 0.5] + 0.0)
set i [expr [cgi_get i 0.5] + 0.0]
set ts [ts fetch $rfile]
if {$ts != 0} {
if {![catch {set ts [ts fetch $rfile]}]} {
$ts cleanbmp
for {set n $($s + 0.0)} {$n <= $e} {set n $($n + $i)} {
for {set n [expr $s + 0.0]} {$n <= $e} {set n [expr $n + $i]} {
puts "Generating thumbnail for pos $n"
$ts mkbmp $n ".pos$n"
}
}

View File

@@ -9,7 +9,7 @@ httpheader
set file [cgi_get file]
set pos [cgi_get pos 0]
set ts [ts fetch $file]
if {$ts != 0} {
if {![catch {set ts [ts fetch $file]}]} {
$ts mkthm $pos
}

View File

@@ -8,10 +8,8 @@ jqplugin highlight tablesorter2
header
set file [cgi_get file -]
if {$file eq "-"} {
footer
exit
}
if {$file eq "-"} exit
puts "
<script type=text/javascript>
var file = '$file';
@@ -24,7 +22,6 @@ set search [cgi_get search ""]
if {[catch {set ts [ts fetch $file]}] || $ts eq "0"} {
puts "Unable to load recording data."
footer
exit
}
@@ -76,7 +73,6 @@ if {$search ne ""} {
}
if {![llength $matches]} {
footer
exit
}
@@ -125,4 +121,3 @@ puts "
</div>
"
footer

View File

@@ -56,7 +56,7 @@ proc db_info {db_file} {
where type='table' order by name
}]
puts "<h3><a href=\"/db/index.jim?db=[file tail $db_file]\">
puts "<h3><a href=/db/index.jim?db=[file tail $db_file]>
$db_file</a></h3>"
foreach table $tables {
@@ -66,7 +66,7 @@ proc db_info {db_file} {
set datas [$db query "SELECT * FROM $table order by 1"]
puts "
<h2><a href=\"/db/index.jim?db=[file tail $db_file]&tab=$table\">$table</a></h2>
<h2><a href=/db/index.jim?db=[file tail $db_file]&tab=$table>$table</a></h2>
<table>
<thead>
<tr>

View File

@@ -19,7 +19,7 @@ foreach arg $argv {
lappend dirs $arg
}
}
if {![llength $dirs]} { lappend dirs [pwd] }
if {![llength $dirs]} { lappend dirs [exec pwd] }
foreach dir $dirs {
if {[string index $dir end] eq "/"} {
@@ -28,7 +28,7 @@ foreach dir $dirs {
if {!$auto} { puts "\[$dir\]" }
loadseries $dir
foreach file [lsort -command dedupsort [readdir -nocomplain $dir]] {
foreach file [lsort -command dedupsort [readdir $dir]] {
if {[file extension $file] ne ".nts"} { continue }
set file "$dir/[file rootname $file].hmt"

View File

@@ -28,7 +28,7 @@ puts "<fieldset style=\"display: inline\">
loadseries $dir
set recalc 0
foreach file [lsort -command dedupsort [readdir -nocomplain $dir]] {
foreach file [lsort -command dedupsort [readdir $dir]] {
set file "$dir/$file"
if {[file extension $file] ne ".nts"} { continue }

View File

@@ -4,7 +4,7 @@ require system.class
proc dedupsort {a b} {
global dir
return $([file mtime "$dir/$a"] > [file mtime "$dir/$b"])
return [expr [file mtime "$dir/$a"] > [file mtime "$dir/$b"]]
}
proc dedupprocess {file} {{seen {}}} {

View File

@@ -14,12 +14,12 @@ puts {
<div class=va>
<img class=va src=/img/safe.png height=50>
<span class="va blood">
<i>Safe Mode on next boot is currently
<i>Safe mode on next boot is currently
<b><span class=cur></span></b></i>
</span>
</div><div>
Safe Mode allows you to start up your Humax without
any of the Custom Firmware packages in order to run
any of the custom firmware packages in order to run
diagnostics or troubleshoot the system.
<br><br>
If enabled, Safe Mode will be entered the
@@ -28,8 +28,8 @@ puts {
panel after the Custom Firmware version message.
<br><br>
Safe Mode can be disabled again via a simple web
interface which is available in Safe Mode or via the
Administration (telnet) menu.
interface which is available in safe mode or via the
telnet menu.
</div>
</div>
@@ -41,9 +41,9 @@ puts {
<b><span class=cur></span></b></i>
</span>
</div><div>
When the CFW Reset option is enabled, all Custom Firmware
When the CFW Reset option is enabled, all custom firmware
packages and settings will be removed on the next system
startup and a blank Custom Firmware environment will be
startup and a blank custom firmware environment will be
initialised.
<br><br>
The initial bootstrap web interface will be running to allow
@@ -60,9 +60,9 @@ puts {
<b><span class=cur></span></b></i>
</span>
</div><div>
When the RMA Clear option is enabled, all Custom Firmware
When the RMA Clear option is enabled, all custom firmware
packages and settings will be removed on the next system
startup and the Custom Firmware environment will <b>not</b> be
startup and the custom firmware environment will <b>not</b> be
re-initialised.
<br><br>
Once in this state, the installation of an official Humax
@@ -82,7 +82,7 @@ puts {
</div><div>
Maintenance Mode allows you to start up your Humax
in a mode where neither the standard Humax software
nor the Custom Firmware packages are running.
nor the custom firmware packages are running.
<br><br>
This mode is primarily intended to be used for checking
and repairing the hard disk or for modifying files which

View File

@@ -30,10 +30,7 @@ puts "
<table>
<tr><th class=key>SMART Status</th><td>$smart<td></tr>
"
if {[catch {set msg [exec /bin/smartctl -i $device]} xmsg]} {
set msg $xmsg
}
foreach line [split $msg "\n"] {
foreach line [split [exec /bin/smartctl -i $device] "\n"] {
if {[string match "*Not in smartctl database*" $line]} continue
if {[string match "*: *" $line]} {
regsub -all -- {[[:space:]]+} $line " " line
@@ -84,7 +81,7 @@ proc flags {val} {
set f ""
set fx ""
loop i 0 [llength $flaglist] {
if {$val & (1 << $i)} {
if {[expr $val & (1 << $i)]} {
append f [lindex $flaglist $i]
append fx "[lindex $flagdescr $i]\n"
} else {
@@ -98,11 +95,8 @@ set nolife {184 187 188 189 191 197 198}
set derive {4 "" 5 sectors 9 hours 12 cycles 192 "" 193 "cycles"}
if {[catch {set msg [exec /bin/smartctl -A $device]}]} {
set msg ""
}
set i 0
foreach line [split $msg "\n"] {
foreach line [split [exec /bin/smartctl -A $device] "\n"] {
regsub -all -- {[[:space:]]+} $line " " line
regsub -all -- {^[[:space:]]+} $line "" line
if {[incr i] < 8} continue
@@ -135,18 +129,20 @@ foreach line [split $msg "\n"] {
set left ""
if {$flags eq ""} { set flags 0 }
if {$id ni $nolife &&
($flags & 0x18) == 0x10 && $val == $worst && $val <= 100 &&
[expr $flags & 0x18] == 0x10 && $val == $worst && $val <= 100 &&
$thresh < 100} {
# Event counter which is not a rate and has not regressed.
set notes ""
set left $(100 - 100 * (100 - $val) / (100 - $thresh))
set left [expr 100 - 100 * (100 - $val) / (100 - $thresh)]
if {$left < 10} { set class orangeshade }
# rval can be non-numeric (e.g. 6078h+41m+22.260s)
if {[regexp {^\d+$} $rval] && $rval > 0 && [\
dict exists $derive $id]} {
if {$left < 100} {
set total $(round(($rval / (100 - $left) \
* 100) / 10000) * 10000)
set total [expr \
round(($rval / (100 - $left) * 100) \
/ 10000) * 10000 \
]
set remain $($total - $rval)
set notes "$remain of approximately"
append notes " $total $derive($id)"
@@ -155,9 +151,9 @@ foreach line [split $msg "\n"] {
set left "<span title=\"$notes\">$left%</span>"
}
if {$id == 190} {
append val " ($(100 - $val)&deg;C)"
append worst " ($(100 - $worst)&deg;C)"
append thresh " ($(100 - $thresh)&deg;C)"
append val " ([expr 100 - $val]&deg;C)"
append worst " ([expr 100 - $worst]&deg;C)"
append thresh " ([expr 100 - $thresh]&deg;C)"
}
puts "<tr class=$class>
<td>$id</td>
@@ -189,17 +185,17 @@ puts {
</tr>
}
if {[catch {exec /bin/smartctl -l selftest $device} msg]} {
set rc [lindex $::errorCode 2]
set rc $($rc eq "" ? 1 : $rc & 7)
if {$rc} { set msg "" }
if {[catch {set msg [exec /bin/smartctl -l selftest $device]} xmsg]} {
set msg $xmsg
}
set i 0
foreach line [split $msg "\n"] {
regsub -all -- {[[:space:]][[:space:]]+} $line "|" line
if {[incr i] < 7} continue
if {[regexp {\s*#\s*(\d+)\s+((?:\s?[\w-][:;.,]?)+)\s+((?:\s?\(?[\w-][:;.,)]?)+?)\s+(\d\d?%)\s+(\d+)\s+([\d-]\d*)} \
$line x id name status remaining when lba] == 0} continue
lassign [split $line "|"] id name status remaining when lba
if {[string length $id] > 10} continue
if {$id eq ""} continue
puts "<tr>
<td>$id</td>
<td>$name</td>
@@ -215,33 +211,18 @@ puts {
</fieldset>
<div class=cleft style="padding-top: 2em">
<button id=diskack>Acknowledge any current disk faults</button>
}
if {[system is_smarttesting]} {
puts {
<button id=smartstop>Stop SMART test</button>
}
} else {
puts {
<button id=smartshort>Start SMART short test</button>
<button id=smartlong>Start SMART long test</button>
}
}
puts {
<button id=diskack>Acknowledge any current disk faults.</button>
</div>
<script type=text/javascript>
$(function() {
$('#diskack,#smartshort,#smartlong,#smartstop')
$('#diskack')
.button()
.on('click', function(e) {
e.preventDefault();
$('button').disable();
act = $(this).attr('id');
$.get('diskact.jim?act=' + act, function() {
$.get('diskack.jim', function() {
window.location.reload(true);
});
});

16
webif/html/diag/diskack.jim Executable file
View File

@@ -0,0 +1,16 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require settings.class
httpheader
set settings [settings]
foreach attr {realloc pending offline} {
set val [$settings _nval_setting "SMART_$attr"]
if {$val < 0} continue
$settings _nval_setting "SMART_ack_$attr" $val
}

View File

@@ -1,24 +0,0 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
httpheader
set act [cgi_get act]
switch $act {
"diskack" {
require settings.class
set settings [settings]
foreach attr {realloc pending offline spinretry} {
set val [$settings _nval_setting "SMART_$attr"]
if {$val < 0} continue
$settings _nval_setting "SMART_ack_$attr" $val
}
}
"smartshort" { system smarttest }
"smartlong" { system smarttest long }
"smartstop" { system smarttest stop }
}

View File

@@ -12,10 +12,11 @@ if {[catch {set db [sqlite3.open /var/lib/humaxtv/channel.db]} msg]} {
exit
}
pkg removemuxdb
pkg loadmuxdb
proc f2c {frequency} {
return $(int((($frequency / 1000) - 303.25) / 8))
set ch int($((($frequency / 1000) - 303.25) / 8))
return [expr int($ch)]
}
proc svc2mux {svcid mux} {
@@ -26,6 +27,7 @@ proc svc2mux {svcid mux} {
3 { format "COM4/SDN" }
5 { format "COM5/ARQ A" }
6 { format "COM6/ARQ B" }
10 { format "COM7/ARQ C" }
default { format $mux }
}]
}
@@ -52,16 +54,12 @@ puts "
<th>&gt;799</th>
</tr>
"
set res {}
catch { \
set res [$db query {
foreach tw [$db query {
select tsIdx, szNetName, usTsID, ulFrequency, ucLevel,
ucQuality, eTransMode, eConstellation, eSystem
from TBL_TS join TBL_NET using (netIdx)
order by ulFrequency
}]
}
foreach tw $res {
}] {
lassign $tw \
x tsIdx x netName x usTsID x ulFrequency x ucLevel x ucQuality \
x eTransMode x eConstellation x eSystem
@@ -69,21 +67,18 @@ foreach tw $res {
puts "
<tr class=odd>
<td>[f2c $ulFrequency]</td>
<td>$($ulFrequency / 1000.0) MHz</td>
<td>[expr $ulFrequency / 1000.0] MHz</td>
"
puts "<td>[progressbar $ucLevel]</td>"
puts "<td>[progressbar $ucQuality]</td>"
puts "<td>[system strip $netName]</td>"
set channels {}
catch { \
set channels [$db query {
select usLcn, szSvcName, usSvcId, szPrvName, aucDefaultAuthority
from TBL_SVC left join TBL_PRV using (prvIdx)
where tsIdx = %s
order by usLcn
set channels [$db query {
select usLcn, szSvcName, usSvcId, szPrvName, aucDefaultAuthority
from TBL_SVC left join TBL_PRV using (prvIdx)
where tsIdx = %s
order by usLcn
} $tsIdx]
}
if {$eConstellation == 1} {
set mux "Local"
@@ -102,9 +97,9 @@ foreach tw $res {
}
puts "<td>$mux</td>"
if {$eSystem == 0} {
puts [string cat "<td>DVB-T (SD" $($eTransMode==2 ? "" : ";$eTransMode") ")</td>"]
puts "<td>DVB-T (SD;$eTransMode)</td>"
} else {
puts [string cat "<td class=blood>DVB-T2 (HD" $($eTransMode==6 ? "" : ";$eTransMode") ")</td>"]
puts "<td class=blood>DVB-T2 (HD;$eTransMode)</td>"
}
puts "<td>[llength $channels]
@@ -142,7 +137,6 @@ foreach tw $res {
}
puts "</table>"
puts "<div class=blood>Signal strength and quality figures are as at the last retune.</div>"
puts {
<script type=text/javascript>

View File

@@ -1,20 +1,18 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require queue.class json settings.class system.class
require queue.class json settings.class
httpheader "application/json"
set s [settings]
set autolast [$s autolast]
set autofreq [$s autofreq]
set qrunning $([string length [queue pids]] ? 1 : 0)
if {$autofreq == 0} { set autofreq 10 }
puts "{"
puts " \"autofreq\": \"$autofreq\","
puts " \"autolast\": \"[clock format $autolast] ([clock format \
$([clock seconds] - $autolast) -format %T] ago)\","
puts " \"qrunning\": \"$qrunning\","
puts " \"autolast\": \"[clock format $autolast] ([clock format [expr \
[clock seconds] - $autolast] -format %T] ago)\","
puts " \"data\": \["
set flag 0
@@ -35,7 +33,7 @@ foreach q [queue all] {
}
set start [$q get start]
if {$start ne "0"} { set start $([clock seconds] - $start) }
if {$start ne "0"} { set start $($start - [clock seconds]) }
if {$flag} { puts "," } else { incr flag }
puts "{"

View File

@@ -46,19 +46,13 @@ There are no tasks in the queue.
</tbody>
</table>
<div class=buttonbar>
<button id=selcomplete class=needsdata>Select Completed</button>
<button id=selfailed class=needsdata>Select Failed</button>
<button id=selpending class=needsdata>Select Pending</button>
<button id=selall class=needsdata>Select All</button>
<button id=selnone class=needsdata>Select None</button>
</div>
<div class=buttonbar>
<button id=qdelete act=delete class="submit needssel">Delete</button>
<button id=qresubmit act=resubmit class="submit needssel">Re-submit</button>
<button id=qhold act=hold class="submit needssel">Hold</button>
<button id=killrun>Kill Running</button>
<button id=refresh class=refresh>Refresh</button>
<button id=viewlog>View auto.log</button>
<button id=selcomplete class=needsdata>Select Completed</button>
<button id=selall class=needsdata>Select All</button>
<button id=selnone class=needsdata>Select None</button>
<button class=refresh id=refresh>Refresh</button>
<span class=isloading><img src=/img/spin.gif></span>
</div>
<div id=lastscan>Last media scan: <span id=autolast>retrieving...</span> -

View File

@@ -24,11 +24,6 @@ function load()
$('#autolast').html(data.autolast);
$('#autofreq').html(data.autofreq);
if (data.qrunning != 0)
$('#killrun').enable();
else
$('#killrun').disable();
data = data.data;
$.each(data, function(k, v) {
@@ -45,8 +40,7 @@ function load()
$('<td>').append($('<a>', {
'class': 'file',
href: '#',
html: v.file,
title: v.file
html: v.file
})).appendTo($row);
$('<td>', { html: v.action + ' ' + v.args })
.appendTo($row);
@@ -108,8 +102,6 @@ function load()
$(function() {
var loader=0;
$('table')
.tablesorter({
sortList: [[0,1]],
@@ -156,7 +148,7 @@ $('button.submit').on('click', function() {
$.unblockUI();
load();
});
});
});
});
@@ -170,49 +162,12 @@ $('#selall').button({icons:{primary:"ui-icon-star"}})
$('#queuetab input:checkbox').prop('checked', true).trigger('change');
});
$('#selpending').button({icons:{primary:"ui-icon-check"}})
.on('click', function() {
$('#queuetab input:checkbox[status="PENDING"]').prop('checked', true)
.trigger('change');
});
$('#selfailed').button({icons:{primary:"ui-icon-check"}})
.on('click', function() {
$('#queuetab input:checkbox[status="FAILED"]').prop('checked', true)
.trigger('change');
});
$('#selcomplete').button({icons:{primary:"ui-icon-check"}})
.on('click', function() {
$('#queuetab input:checkbox[status="COMPLETE"]').prop('checked', true)
.trigger('change');
});
$('#killrun').button({icons:{primary:"ui-icon-stop"}})
.on('click', function() {
$(this).dojConfirmAction({
question: $(this).text() + '?',
yesAnswer: 'Yes',
cancelAnswer: 'No'
}, function(el) {
$.blockUI({
message: '<h1><img src=/img/spin.gif> Processing... </h1>'
});
var slots = $('#queuetab input:checkbox[status="RUNNING"]').map(function() {
return this.value;
}).get();
$.get('update.jim', {
act: 'kill',
slot: slots.join(',')
}, function() {
$.unblockUI();
load();
});
});
});
$('button.refresh').button({icons:{primary:"ui-icon-refresh"}})
.on('click', function() {
load();
@@ -230,20 +185,7 @@ $('#queuetab').on('click', 'a.file', function(e) {
encodeURIComponent('{root}/' + dirname(file));
});
$('#viewlog').button().click(function() {
window.location = '/log/?log=/mod/tmp/auto.log';
});
function set_loader() {
if (loader != 0)
clearInterval(loader);
loader=setInterval(load, 60000);
}
$('#queuetab').on('change', 'input[type=checkbox]', set_loader);
set_loader();
setInterval(load, 60000);
});

View File

@@ -1,10 +1,3 @@
/* constrain File column width */
td:nth-child(3), th:nth-child(3)
{
max-width: 50ch;
overflow: hidden;
text-overflow: ellipsis;
}
td.status
{

View File

@@ -2,38 +2,24 @@
package require cgi
source /mod/webif/lib/setup
require queue.class system.class lock
require queue.class
httpheader
set slots [cgi_get slot 0]
set act [cgi_get act -]
set slots [cgi_get slot ""]
if {$act eq "kill" } {
foreach pid [queue pids] {
catch {kill $pid}
}
if {![catch {acquire_lock webif_autorunq 5}]} {
foreach slot [split $slots ","] {
queue hold $slot
}
release_lock webif_autorunq
}
} else {
foreach slot [split $slots ","] {
switch -- $act {
delete {
queue delete_by_id $slot
}
resubmit {
queue resubmit $slot
}
hold {
queue hold $slot
}
}
foreach slot [split $slots ","] {
switch -- $act {
delete {
queue delete_by_id $slot
}
resubmit {
queue resubmit $slot
}
hold {
queue hold $slot
}
}
}

View File

@@ -14,13 +14,12 @@ set files {
}
if {$act eq "getall"} {
package require json
httpheader "application/json"
set ret {}
foreach {k v} $files {
lappend ret $k [file exists $v]
lappend ret "\"$k\":\"[file exists $v]\""
}
puts [json::encode $ret obj]
puts [concat "{\n" [join $ret ",\n"] "\n}"]
exit
}
@@ -28,7 +27,6 @@ httpheader
if {$opt ni $files} {
puts 0
exit
}
switch $act {

View File

@@ -12,7 +12,7 @@ set diag [cgi_get diag general]
httpheader "text/plain"
if {[system modversion 1] < 113} {
puts ">>> Diagnostics only available with Customised Firmware 1.13 or above."
puts ">>> Diagnostics only available with customised firmware 1.13 or above."
exit
}

View File

@@ -9,11 +9,6 @@ lassign [system diskspace 1] size used perc free fperc tsrbuf tsrused
set tsrreserve $($tsrbuf - $tsrused)
# Adjust values to account for the TSR reserve
set free $($free - $tsrreserve)
# In case the reserve has been over-committed
if {$free < 0} {
# avoid displaying negative free, or used > available
set free 0
}
set used $($size - $free)
set dbs 0

View File

@@ -12,7 +12,7 @@ set file [cgi_get file -]
set backdesc [cgi_get backdesc "Back to diagnostics"]
set backlink [cgi_get backlink "/diag/diag.jim"]
if {$file ne "-"} {
puts "<script type=text/javascript>forcefile = \"[cgi_quote_url $file]\";</script>"
puts "<script type=text/javascript>forcefile = '$file';</script>"
}
puts {

View File

@@ -11,22 +11,20 @@ set file [cgi_get file "/tmp/hosts"]
if {$file eq "-"} { exit }
httpheader "text/plain" 0
set maxfsize $(1024 * 1024 * 2)
if {![file exists $file]} {
puts ">>> File $file does not exist."
puts ">>> File $file does not exist.\r\n"
} else {
set type [exec /mod/bin/file --brief --mime-type --dereference $file]
if {!([string match {text/*} $type] || [string match {application/xml*} $type])} {
puts ">>> File $file is not an editable type ($type)."
if {![string match {text/*} $type]} {
puts ">>> File $file is not a plain file ($type)"
} elseif {[file size $file] > 102400} {
puts ">>> File $file is too large."
puts ">>> [pretty_size [file size $file]]"
} else {
set fsize [file size $file]
if {$fsize > $maxfsize} {
puts ">>> File $file is too large ([pretty_size $fsize] > [pretty_size $maxfsize])."
} else {
set fp [open $file r]
puts -nonewline [read $fp]
close $fp
}
set fp [open $file r]
puts [read $fp]
close $fp
}
}

View File

@@ -9,7 +9,7 @@ var changed = false;
$('button').button();
$('button.editactive').disable();
$('#editor').tabsupport().disable().val('');
$('#editor').tabsupport().disable();
$('#open').button({icons: {primary: "ui-icon-folder-open"}});
$('#revert').button({icons: {primary: "ui-icon-refresh"}});
@@ -189,7 +189,7 @@ $('#executable').on('click', function() {
if (forcefile)
{
loadfile(decodeURIComponent(forcefile));
loadfile(forcefile);
$('#open,#create,#qedit').remove();
}

View File

@@ -110,9 +110,11 @@ puts "
</a><br>
"
set end [clock milliseconds]
puts "<font class=footnote>
Retrieved in: $(($got - $start) / 1000.0) seconds.
</font>"
Retrieved in: [expr [expr $got - $start] / 1000.0] seconds.
Rendered in: [expr [expr $end - $start] / 1000.0] seconds.
</font>"
epg cleanup

View File

@@ -78,7 +78,7 @@ puts "
<tr>
<th class=hour></th>
"
set t [midnight]
set t [clock seconds]
set firstday [clock format $t -format {%Y%m%d}]
set daymap {}
loop i 0 8 {
@@ -87,7 +87,7 @@ loop i 0 8 {
set day [clock format $t -format {%Y%m%d}]
set daymap($day) $i
set dayrmap($i) $day
set t [midnight_local $($t+93600)]
incr t 86400
}
puts "
</tr>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 19 B

1
webif/html/favicon.ico Symbolic link
View File

@@ -0,0 +1 @@
img/fav/favicon.ico

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 19 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

View File

@@ -29,6 +29,10 @@ $(document).ready(function() {
source /mod/webif/include/menuicons.jim
if {[$settings notwitfeed] == 0} {
source /mod/webif/include/twitfeed.jim
}
puts {<div class=cleft>}
if {[$settings nohelplinks] == 0} {
source /mod/webif/include/helplinks.jim

View File

@@ -22,6 +22,7 @@ setInterval(updateidle, 60000);
if ($('#vfd').length)
{
function updatevfd()
{
$.get('/cgi-bin/vfd.jim', function(vfd) {
@@ -33,18 +34,5 @@ if ($('#vfd').length)
setInterval(updatevfd, 5000);
}
if ($('#status_txt').length)
{
function updatestatus()
{
$.get('/cgi-bin/status.jim', function(status) {
$('#status_txt').html(status);
});
}
updatestatus();
setInterval(updatestatus, 60000);
}
});

View File

@@ -6,7 +6,7 @@ puts {
}
catch {
set rendertime $(([clock milliseconds] - $renderstart) / 1000.0)
set rendertime [expr ([clock milliseconds] - $renderstart) / 1000.0]
puts "<span class=footnote>Rendered in: $rendertime seconds</span>"
}

View File

@@ -17,6 +17,5 @@ incr ::mws::headerdone
puts {
</head>
<body>
<div>
}

View File

@@ -43,10 +43,10 @@ function loadlog_entire(data)
{
var lines = 0;
if (data.lines > 100000)
if (data.lines > 5000)
{
lines = 100000;
$('#loginfo').append(' - <i>showing 100000 most recent.</i>');
lines = 5000;
$('#loginfo').append(' - <i>showing 5000 most recent.</i>');
}
$.get('fetch.jim', {

Some files were not shown because too many files have changed in this diff Show More