From 51565a085a1f3eb09f7cd9985314371321766718 Mon Sep 17 00:00:00 2001 From: longinus Date: Thu, 24 Dec 2009 14:38:44 +0000 Subject: [PATCH] add atom (experimental) git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@349 4e526526-5e11-4fc0-8910-f8fd03428081 --- rectool/trunk/rectool.pl | 165 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 53 deletions(-) diff --git a/rectool/trunk/rectool.pl b/rectool/trunk/rectool.pl index 68b8b66..69319a2 100755 --- a/rectool/trunk/rectool.pl +++ b/rectool/trunk/rectool.pl @@ -17,6 +17,7 @@ use MIME::Base64; use Config::Simple; use Time::HiRes; use Data::Dumper; +use Tie::IxHash; #require SVG Time::Simple Encode Text::Ngram File::Find Data::Dumper Perl6::Slurp List::Util #use utf8; %DB::packages = ( 'main' => 1 ); @@ -59,7 +60,8 @@ $HTML .= < - + + %REFRESH% %SCRIPT% %CSS% @@ -73,40 +75,42 @@ $q = new CGI::Minimal; $mode = $q->param( 'mode' ); $mode_sub = $q->param( 'mode_sub' ); +tie %type, 'Tie::IxHash'; %type = ( - 'search_everyday' => '隔日検索', - 'search_today' => '当日検索', - 'reserve_flexible' => '浮動予約', - 'reserve_fixed' => '確定予約', + 'search_everyday' => '隔日検索', + 'search_today' => '当日検索', + 'reserve_flexible' => '浮動予約', + 'reserve_fixed' => '確定予約', - 'reserve_running' => '録画途中', + 'reserve_running' => '録画途中', - 'convert_b25_ts' => '解読予約', - 'convert_b25_ts_running' => '解読途中', - 'convert_b25_ts_miss' => '解読失敗', + 'convert_b25_ts' => '解読予約', + 'convert_b25_ts_running' => '解読途中', + 'convert_b25_ts_miss' => '解読失敗', - 'convert_ts_mp4' => '縁故予約', - 'convert_ts_mp4_running' => '縁故於鯖', - 'convert_ts_mp4_network' => '縁故於網', - 'convert_ts_mp4_finished' => '縁故完了', + 'convert_ts_mp4' => '縁故予約', + 'convert_ts_mp4_running' => '縁故於鯖', + 'convert_ts_mp4_network' => '縁故於網', + 'convert_ts_mp4_finished' => '縁故完了', - 'convert_avi_mkv' => '変換旧露', - 'convert_avi_mp4' => '変換旧四', - 'convert_mkv_mp4' => '変換露四', + 'convert_avi_mkv' => '変換旧露', + 'convert_avi_mp4' => '変換旧四', + 'convert_mkv_mp4' => '変換露四', + 'convert_mkv_mp4_runnings' => '換途露四', - 'auto_suggest_dec' => '予測解読', - 'auto_suggest_enc' => '予測縁故', - 'auto_suggest_a24' => '予測旧四', - 'auto_suggest_m24' => '予測露四', + 'auto_suggest_dec' => '予測解読', + 'auto_suggest_enc' => '予測縁故', + 'auto_suggest_avi2fp' => '予測旧四', + 'auto_suggest_ap2fp' => '予測露四', - 'move_end' => '移動完了', + 'move_end' => '移動完了', ); %type_suggest = ( - 'auto_suggest_dec' => 'convert_b25_ts', - 'auto_suggest_enc' => 'convert_ts_mp4', - 'auto_suggest_a24' => 'convert_avi_mp4', - 'auto_suggest_m24' => 'convert_mkv_mp4', + 'auto_suggest_dec' => 'convert_b25_ts', + 'auto_suggest_enc' => 'convert_ts_mp4', + 'auto_suggest_avi2fp' => 'convert_avi_mkv', + 'auto_suggest_ap2fp' => 'convert_mp4_mkv', ); $type_user_made = "( 'search_everyday', 'search_today', 'reserve_flexible', 'reserve_fixed', 'reserve_running' )"; @@ -172,24 +176,27 @@ EOM $type = $type{$line->[1]} || $line->[1]; if ( $line->[1] =~ /^search/ ) { - $type = qq {$type}; + $type = qq {$type}; $line->[9] = qq {空} if ( !$line->[9] && $line->[1] eq 'search_everyday' ); $line->[10] = qq {空} if ( !$line->[10] ); } elsif ( $line->[1] eq 'reserve_running' ) { - $type = qq {$type}; + $type = qq {$type}; } elsif ( $line->[1] =~ /^reserve/ ) { - $type = qq {$type}; + $type = qq {$type}; } - elsif ( $line->[1] eq 'convert_b25_ts' || $line->[1] eq 'convert_b25_ts' ) { - $type = qq {$type}; + elsif ( $line->[1] eq 'convert_b25_ts' ) { + $type = qq {$type}; } elsif ( $line->[1] eq 'convert_b25_ts_running' ) { - $type = qq {$type}; + $type = qq {$type}; + } + elsif ( $line->[1] eq 'convert_ts_mp4' ) { + $type = qq {$type}; } elsif ( $line->[1] eq 'convert_ts_mp4_running' ) { - $type = qq {$type}; + $type = qq {$type}; } else { $type = qq {$type}; @@ -463,6 +470,41 @@ if ( $mode eq 'graph' ) { } } +if ( $mode eq 'atom' ) { + require XML::Atom::Feed; + require XML::Atom::Entry; + + my $recording_status; + my $ary_ref = $dbh->selectall_arrayref( + "SELECT chtxt, title, btime, etime, opt + FROM timeline + WHERE type = 'reserve_running' "); + foreach my $line ( @{$ary_ref} ) { + my ( $begin, $end, $diff ) = &str2readable( $line->[2], $line->[3] ); + $recording_status .= qq {$line->[0] $line->[1] $begin - $end $diff $line->[4]}; + } + + my $feed = XML::Atom::Feed->new; + $feed->title('Rec10 フィード'); + + my $entry = XML::Atom::Entry->new; + $entry->title('Rec10 録画状況'); + $entry->id('tag:recording_status'); + $entry->content($recording_status); + $feed->add_entry($entry); + + $entry = XML::Atom::Entry->new; + $entry->title('Test'); + $entry->id('testid'); + $entry->content('TestData'); + $feed->add_entry($entry); + + my $xml = $feed->as_xml; + print "Content-Type: application/atom+xml\n\n"; + print $xml; + exit; +} + if ( $mode eq 'edit' ) { my $id = $q->param( 'id' ); @@ -566,8 +608,9 @@ EOM $HTML .= qq {\n}; $HTML .= qq {ID\n\n}; $HTML .= qq {タイプ\n\n}; - $HTML .= qq {アニメ\n}; + $HTML .= qq {可変フレームレート\n}; $HTML .= qq {二ヶ国語放送\n}; $HTML .= qq {2passモード\n}; $HTML .= qq {5.1ch放送\n}; @@ -761,6 +801,7 @@ if ( $mode eq 'confirm' ) { $HTML .= qq {\n}; $HTML .= qq {\n}; $HTML .= qq {ファイル名日時追加\n}; + $HTML .= qq {隔週録画\n}; $HTML .= qq {\n\n}; } goto end; @@ -769,6 +810,7 @@ if ( $mode eq 'confirm' ) { if ( $mode_sub eq 'proc' ) { my $type = $q->param( 'type' ); + my $chtxt = $q->param( 'chtxt' ); my $title = $q->param( 'title' ); $HTML .= "詳細設定を行ってください。
\n"; @@ -814,10 +856,27 @@ if ( $mode eq 'reserve' ) { &parse_program(); @opt = $q->param( 'opt' ); $opt = join '', @opt; + my ( $deltaday, $deltatime ); + $deltaday = 7; + if ( $q->param('every') eq '1' ) { + $type = 'search_everyday'; + ( $changed_t ) = $title =~ /(.*) #/; + $title = $changed_t if ( $changed_t ); + ( $changed_t ) = $title =~ /(.*) 第/; + $title = $changed_t if ( $changed_t ); + $title =~ s/「.*」//; + $title =~ s/<.*>//; + $title =~ s/(.*)//; + $deltaday = 7; + $deltatime = 3; + } + else { + $type = 'reserve_flexible'; + } if ( !&check_error ) { $dbh->do( - "INSERT INTO timeline ( type, chtxt, title, btime, etime, opt ) - VALUES ( 'reserve_flexible', '$chtxt', '$title', '$begin', '$end', '$opt' )" + "INSERT INTO timeline ( type, chtxt, title, btime, etime, opt, deltaday, deltatime ) + VALUES ( '$type', '$chtxt', '$title', '$begin', '$end', '$opt', '$deltaday', '$deltatime' )" ); } $HTML .= "録画予約を実行しました。
\n5秒後にトップへ移動します。
\n"; @@ -890,7 +949,6 @@ if ( $mode eq 'list' ) { $HTML =~ s/%HTML_TITLE_OPT%/ - List/; - my $mode_sub = $q->param( 'mode_sub' ); my $recording = $cfg->param( 'path.recpath' ); my $recorded = $cfg->param( 'path.recorded' ); @@ -914,7 +972,7 @@ if ( $mode eq 'list' ) { local $path = shift; local %list = (); my @exp = ( 'log', 'ts.b25', 'ts.tsmix', 'ts', 'ts.log.mbtree', 'ts.log', - 'sa.avi', 'sa.avi.log', 'm2v', 'wav', 'avi', 'mkv', 'mp4' ); + 'sa.avi', 'sa.avi.log', '120.avi', 'aac', 'timecode.txt', 'm2v', 'wav', 'avi', 'mkv', 'mp4' ); for ( 0..$#exp ) { $exp{$exp[$_]} = $_; } @@ -1114,22 +1172,23 @@ if ( $mode eq 'proc' ) { $HTML .= qq {\n}; my $ary_ref = $dbh->selectall_arrayref( - "SELECT type, title + "SELECT type, chtxt, title FROM auto_proc " ); foreach my $line ( @{ $ary_ref } ) { my $url; - $line->[2] = $q->url_encode( $line->[1] ); + $line->[3] = $q->url_encode( $line->[2] ); if ( $line->[0] =~ /^auto_suggest_(dec|enc)/ ) { - $url = qq {rectool.pl?mode=confirm&mode_sub=proc&type=$line->[0]&title=$line->[2]}; + $url = qq {rectool.pl?mode=confirm&mode_sub=proc&type=$line->[0]&chtxt=$line->[1]&title=$line->[3]}; } else { - $url = qq {rectool.pl?mode=change&mode_sub=proc&type=$line->[0]&title=$line->[2]}; + $url = qq {rectool.pl?mode=change&mode_sub=proc&type=$line->[0]&chtxt=$line->[1]&title=$line->[3]}; } + $line->[0] = $type{$line->[0]} ? $type{$line->[0]} : $line->[0]; $HTML .= qq {\n}; - $HTML .= qq {$type{$line->[0]}\n}; - $HTML .= qq {$line->[1]\n}; + $HTML .= qq {$line->[0]\n}; + $HTML .= qq {$line->[2]\n}; $HTML .= qq {予約\n}; $HTML .= qq {\n}; } @@ -1227,7 +1286,7 @@ if ( $mode eq 'jbk' ) { if ( $mode eq 'expert' ) { my $ary_ref; - my $mode_sub = $q->param( 'mode_sub' ); + $HTML =~ s/%HTML_TITLE_OPT%/ - Expert/; $HTML .= qq {
\n}; -- 2.11.0