use DateTime;
use DBI;
use MIME::Base64;
-use Perl6::Slurp;
+use File::Slurp;
use Sort::Naturally;
use Time::Piece;
use Time::Seconds;
use Time::HiRes;
use Tie::IxHash;
-#require SVG Time::Simple XML::Atom Encode Text::Ngram List::Compare List::Util
+#require SVG Time::Simple XML::Atom Encode List::Compare List::Util
use utf8;
#%DB::packages = ( 'main' => 1 );
var win = new Ext.Window({
title: 'FFmpeg info',
//autoShow: true,
- autoLoad: "rectool.pl?mode=list&mode_sub=ffmpeg&path=" + Ext.Element(elRef).getAttribute("path"),
+ autoLoad: "rectool.pl?mode=list&mode_sub=ffmpeg&path=" + Ext.Element(elRef).getAttribute("path") +
+ "&pathtype=" + Ext.Element(elRef).getAttribute("pathtype"),
});
win.show();
}, null, {stopEvent:true});
var tooltip = new Ext.ToolTip({
target: elem,
width: 400,
- autoLoad: {url: "rectool.pl?mode=list&mode_sub=ffmpeg&path=" + elem.getAttribute("path")},
+ autoLoad: {url: "rectool.pl?mode=list&mode_sub=ffmpeg&path=" + elem.getAttribute("path")},
autoHide: false,
closable: true,
draggable: true,
$script =~ s/^\t{2}//gm;
$HTML =~ s/%SCRIPT%/$script/;
- my $recording = $cfg->param( 'path.recpath' );
- my $ts_movepath = $cfg->param( 'path.ts_movepath' );
- my $recorded = $cfg->param( 'path.recorded' );
+ my $recording = $cfg->param( 'path.recpath' );
+ my $movedest = $cfg->param( 'path.ts_movepath' );
+ my $recorded = $cfg->param( 'path.recorded' );
if ( $mode_sub eq 'log' ) {
my $title = $params{ 'title' };
- my $log = slurp( "$recording/$title.log" ) if ( -e "$recording/$title.log" );
+ my $log = read_file( "$recording/$title.log" ) if ( -e "$recording/$title.log" );
utf8::decode( $log );
$HTML .= '<pre>'.$log."</pre>\n";
goto end;
}
if ( $mode_sub eq 'ffmpeg' ) {
my $path = $params{ 'path' };
+ my $pathtype = $params{ 'pathtype' };
+ my $pathdir;
+ $pathdir = $recording if ( $pathtype eq 'ing');
+ $pathdir = $recorded if ( $pathtype eq 'ed' );
+ $pathdir = $movedest if ( $pathtype eq 'dst');
# mediainfo (not working)
# ffprobe
- my $ffmpeg = `ffmpeg -i "$path" 2>&1`;
+ # FIXME: sanitize
+ my $ffmpeg = `ffmpeg -i "$pathdir/$path" 2>&1` if ( -f "$pathdir/$path" );
utf8::decode($ffmpeg);
$ffmpeg = join "<br>\n", grep /Duration|Stream/, split /\n/, $ffmpeg;
$HTML = $ffmpeg;
}
if ( !$mode_sub || $mode_sub eq 'old' ) {
$HTML .= "録画後のファイル一覧<br>\n";
- &simple_list( $ts_movepath );
+ &simple_list( $movedest );
&simple_list( $recorded );
}
# ○などの代わりにサイズを表示
# $value->{$exp}->{style} = $value->{$exp}->{size};
my $size = $value->{$exp}->{size};
- my $extra = qq {<td><span class="ffmpeg" path="$path/$title.mp4">$size</span></td>\n};
+ my $extra = qq {<td><span class="ffmpeg" path="$title.mp4" pathtype="ing">$size</span></td>\n};
$value->{$exp}->{extra} = $extra;
}
elsif ( $exp eq 'mkv' ) {
my $abs = shift;
my ( $size ) = &get_size( $abs );
- $rel = qq {<span class="ffmpeg" path="$abs">$rel</span>};
- push @list, $rel ."\t".$result."\t". $size;
+ $rel = qq {<span class="ffmpeg" path="$rel" pathtype="ed">$rel</span>};
+ push @list, $rel ."\t\t". $size;
}
}
$HTML .= qq {<div>\n};
require Data::Dumper;
- $tmp = Perl6::Slurp::slurp( 'config.ini' );
+ $tmp = read_file( '/etc/rec10.conf' );
$tmp =~ s/\n/<br>\n/gs;
$HTML .= $tmp;
"SELECT type, chtxt, title, btime, etime, deltaday, deltatime, opt, counter
FROM timeline WHERE id = '$id' "
);
+ &chtxt_format();
( $chname, $bctype ) = $dbh->selectrow_array(
- "SELECT chname, bctype FROM epg_ch WHERE chtxt = '$chtxt' "
+ "SELECT chname, bctype FROM epg_ch WHERE chtxt LIKE '$chtxt_sql' "
);
$start = str2datetime( $begin )->strftime( '%Y%m%d%H%M%S' );
$stop = str2datetime( $end )->strftime( '%Y%m%d%H%M%S' );
"SELECT exp, longexp, category FROM epg_timeline WHERE channel = '$chtxt' AND start = '$start' AND stop = '$stop' "
);
}
- if ( $bctype =~ /bs|cs/ ) {
- $bctype_sql = '_s%';
- }
- elsif ( $bctype =~ /te/ ) {
- ( $chtxt_0 = $chtxt ) =~ s/(\d+)_.*/$1_0/;
- ( $chtxt_sql = $chtxt ) =~ s/_0/_%/;
- $bctype_sql = 'te%';
- }
+ # set $chtxt_0, $chtxt_sql, $bctype_sql
+ &chtxt_format();
#( $chtxt_no0 ) = $chtxt =~ /(\d+)_/;
@start = $start =~ /(.{4})(.{2})(.{2})(.{2})(.{2})/;
@stop = $stop =~ /(.{4})(.{2})(.{2})(.{2})(.{2})/;
sub sqlgetsuggested {
require Encode;
- require Text::Ngram;
my ( $btime, $etime ) = @_;
$deltatime = 3 if ( !$deltatime );
#die Dumper $ary_ref;
my %hash;
- my $hash_r = Text::Ngram::ngram_counts( $title, 2 ); # bi-gram
+ my $hash_r = ngram_counts( $title, 2 ); # bi-gram
foreach my $program ( @{$ary_ref} ) {
- my $hash_k = Text::Ngram::ngram_counts( $program->[2], 2 );
+ no warnings;
+ my $hash_k = ngram_counts( $program->[2], 2 );
my $point;
map $point += $hash_k->{$_}, keys %{$hash_r};
push @{$hash{$point}}, $program if ( $point );
return %hash;
}
+sub ngram_counts {
+ my $str = shift;
+ my $klen = shift;
+ my $slen = length($str);
+
+ my $href;
+ for (my $i=0; $i < $slen-$klen+1; $i++){
+ $href->{substr($str, $i, $klen)}++;
+ }
+ return $href;
+}
+
+sub chtxt_format {
+ ( $chtxt_0 = $chtxt ) =~ s/(\d+)_\d+/$1_0/;
+ ( $chtxt_sql = $chtxt ) =~ s/(\d+)_\d+/$1_%/;
+ if ( $bctype =~ /bs|cs/ ) {
+ $bctype_sql = '_s%';
+ }
+ elsif ( $bctype =~ /te/ ) {
+ $bctype_sql = 'te%';
+ }
+}
+