OSDN Git Service

add atom (experimental)
authorlonginus <longinus@4e526526-5e11-4fc0-8910-f8fd03428081>
Thu, 24 Dec 2009 14:38:44 +0000 (14:38 +0000)
committerlonginus <longinus@4e526526-5e11-4fc0-8910-f8fd03428081>
Thu, 24 Dec 2009 14:38:44 +0000 (14:38 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@349 4e526526-5e11-4fc0-8910-f8fd03428081

rectool/trunk/rectool.pl

index 68b8b66..69319a2 100755 (executable)
@@ -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 .= <<EOM;
 <meta http-equiv="Content-Script-Type" content="text/javascript">
 <meta http-equiv="Content-Style-Type" content="text/css">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<link rev="MADE" href="Rea10"> 
+<link rev="made" href="Rea10">
+<link rel="alternate" type="application/atom+xml" title= "Rec10 Atom Feed" href="./rectool.pl?mode=atom">
 %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 {<span style="color: #800080">$type</span>};
+                       $type = qq {<span style="color: #8B008B">$type</span>};
                        $line->[9]  = qq {<span style="color: #FF0000">空</span>} if ( !$line->[9] && $line->[1] eq 'search_everyday' );
                        $line->[10] = qq {<span style="color: #FF0000">空</span>} if ( !$line->[10] );
                }
                elsif ( $line->[1] eq 'reserve_running' ) {
-                       $type = qq {<span style="color: #FFA000">$type</span>};
+                       $type = qq {<span style="color: #FF8C00">$type</span>};
                }
                elsif ( $line->[1] =~ /^reserve/ ) {
-                       $type = qq {<span style="color: #A0A000">$type</span>};
+                       $type = qq {<span style="color: #4169E1">$type</span>};
                }
-               elsif ( $line->[1] eq 'convert_b25_ts' || $line->[1] eq 'convert_b25_ts' ) {
-                       $type = qq {<span style="color: #404040">$type</span>};
+               elsif ( $line->[1] eq 'convert_b25_ts' ) {
+                       $type = qq {<span style="color: #BC8F8F">$type</span>};
                }
                elsif ( $line->[1] eq 'convert_b25_ts_running' ) {
-                       $type = qq {<span style="color: #C04040">$type</span>};
+                       $type = qq {<span style="color: #DC143C">$type</span>};
+               }
+               elsif ( $line->[1] eq 'convert_ts_mp4' ) {
+                       $type = qq {<span style="color: #32CD32">$type</span>};
                }
                elsif ( $line->[1] eq 'convert_ts_mp4_running' ) {
-                       $type = qq {<span style="color: #008080">$type</span>};
+                       $type = qq {<span style="color: #2E8B57">$type</span>};
                }
                else {
                        $type = qq {<span style="color: #A0A0A0">$type</span>};
@@ -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 {<input type="hidden" name="id" value="$id">\n};
        $HTML .= qq {ID\n<input type="text" name="id" value="$id" size=$len disabled>\n};
        $HTML .= qq {タイプ\n<select name="type" onChange="setType();">\n};
-       while ( my ($key, $value) = each %type ) {
+       foreach my $key ( keys %type ) {
                next if ( $key !~ /^search|^reserve|^convert_b25_ts$|^convert_ts_mp4$|^$type$/ );
+               $value = $type{$key};
                if ( $key eq $type ) {
                        $HTML .= qq {<option value="$key" selected>$value</option>\n};
                }
@@ -725,16 +768,13 @@ if ( $mode eq 'confirm' ) {
                        elsif ( $chtxt  =~ /movieplus/ ) {
                                $selected_h = 'selected';
                        }
-                       elsif ( $chtxt =~ /bs-nhk/ || $bctype =~ /cs/ ) {
-                               $selected_l = 'selected';
-                       }
-                       elsif ( $bctype =~ /bs|te/ ) {
+                       else {
                                $selected_g = 'selected';
                        }
-                       $checked_a  = $chtxt  =~ /animax|atx|disney|kids/ || $category =~ /アニメ/ ? 'checked' : '';
-                       $checked_d  = $title  =~ /\Q[二]\E|[二]|\Q(二)\E|(二)/ ? 'checked' : '';
-                       $checked_5  = $title  =~ /5\.1|5.1/ ? 'checked' : '';
-                       $checked_2  = 'checked';
+                       $checked_v = $chtxt =~ /animax|atx|disney|kids/ || $category =~ /アニメ/ ? 'checked' : '';
+                       $checked_d = $title =~ /\Q[二]\E|[二]|\Q(二)\E|(二)/ ? 'checked' : '';
+                       $checked_5 = $title =~ /5\.1|5.1/ ? 'checked' : '';
+                       $checked_2 = 'checked';
 
                        $HTML .= "録画予約の詳細設定を行ってください。<br>\n";
                        $HTML .= qq {<form method="get" action="rectool.pl">\n};
@@ -749,7 +789,7 @@ if ( $mode eq 'confirm' ) {
                        $HTML .= qq {<option value="F" $selected_f>F 1920x1080 5000kbps</option>\n};
                        $HTML .= qq {<option value="S">S 720x480 1250kbps</option>\n};
                        $HTML .= qq {</select>\n};
-                       $HTML .= qq {<input type="checkbox" name="opt" value="a" $checked_a>アニメ\n};
+                       $HTML .= qq {<input type="checkbox" name="opt" value="v" $checked_v>可変フレームレート\n};
                        $HTML .= qq {<input type="checkbox" name="opt" value="d" $checked_d>二ヶ国語放送\n};
                        $HTML .= qq {<input type="checkbox" name="opt" value="2" $checked_2>2passモード\n};
                        $HTML .= qq {<input type="checkbox" name="opt" value="5" $checked_5>5.1ch放送\n};
@@ -761,6 +801,7 @@ if ( $mode eq 'confirm' ) {
                        $HTML .= qq {<option value="E">縁故後移動</option>\n};
                        $HTML .= qq {</select>\n};
                        $HTML .= qq {<input type="checkbox" name="opt" value="N">ファイル名日時追加\n};
+                       $HTML .= qq {<input type="checkbox" name="every" value="1">隔週録画\n};
                        $HTML .= qq {<input type="submit" value="予約">\n</form>\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 .= "詳細設定を行ってください。<br>\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 .= "録画予約を実行しました。<br>\n5秒後にトップへ移動します。<br>\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 {</tr>\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&amp;mode_sub=proc&amp;type=$line->[0]&amp;title=$line->[2]};
+                       $url = qq {rectool.pl?mode=confirm&amp;mode_sub=proc&amp;type=$line->[0]&amp;chtxt=$line->[1]&amp;title=$line->[3]};
                }
                else {
-                       $url = qq {rectool.pl?mode=change&amp;mode_sub=proc&amp;type=$line->[0]&amp;title=$line->[2]};
+                       $url = qq {rectool.pl?mode=change&amp;mode_sub=proc&amp;type=$line->[0]&amp;chtxt=$line->[1]&amp;title=$line->[3]};
                }
+               $line->[0] = $type{$line->[0]} ? $type{$line->[0]} : $line->[0];
                $HTML .= qq {<tr align="center">\n};
-               $HTML .= qq {<td>$type{$line->[0]}</td>\n};
-               $HTML .= qq {<td>$line->[1]</td>\n};
+               $HTML .= qq {<td>$line->[0]</td>\n};
+               $HTML .= qq {<td>$line->[2]</td>\n};
                $HTML .= qq {<td><a href="$url">予約</a></td>\n};
                $HTML .= qq {</tr>\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 {<div>\n};