root/trunk/install/perl/addpidatq.pl

リビジョン 94, 3.3 kB (コミッタ: sorshi, コミット時期: 14 年 前)

SQLite採用

  • svn:executable 属性の設定値:
Line 
1 #!/usr/bin/perl
2 #
3 # Anime recording system foltia
4 # http://www.dcc-jpl.com/soft/foltia/
5 #
6 #addpidatq.pl
7 #
8 #PID受け取りatqに入れる。folprep.plからキュー再入力のために使われる
9 #
10 # DCC-JPL Japan/foltia project
11 #
12 #
13
14 use DBI;
15 use DBD::Pg;
16 use DBD::SQLite;
17 use Schedule::At;
18 use Time::Local;
19
20 $path = $0;
21 $path =~ s/addpidatq.pl$//i;
22 if ($path ne "./"){
23 push( @INC, "$path");
24 }
25
26 require "foltialib.pl";
27
28
29 #引き数がアルか?
30 $pid = $ARGV[0] ;
31 if ($pid eq "" ){
32         #引き数なし出実行されたら、終了
33         print "usage;addpidatq.pl <PID>\n";
34         exit;
35 }
36
37
38 #DB検索(PID)
39 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;;
40
41 $sth = $dbh->prepare($stmt{'addpidatq.1'});
42 $sth->execute($pid);
43  @titlecount= $sth->fetchrow_array;
44  
45  if ($titlecount[0]  == 1 ){
46     $sth = $dbh->prepare($stmt{'addpidatq.2'});
47     $sth->execute($pid);
48  @titlecount= $sth->fetchrow_array;
49 $bitrate = $titlecount[0];#ビットレート取得
50 if ($titlecount[1] >= 1){
51         $usedigital = $titlecount[1];#デジタル優先フラグ
52 }else{
53         $usedigital = 0;
54 }
55
56 #PID抽出
57     $now = &epoch2foldate(time());
58
59 #stationIDからrecch
60     $stationh = $dbh->prepare($stmt{'addpidatq.3'});
61     $stationh->execute($pid);
62     @stationl =  $stationh->fetchrow_array();
63 $recch = $stationl[0];
64 if ($recch eq ""){
65         &writelog("addpidatq ERROR recch is NULL:$stmt{'addpidatq.3'}.");
66         exit 1;
67 }
68 if ($stationl[1] => 1){
69         $digitalch = $stationl[1];
70 }else{
71         $digitalch = 0;
72 }
73 if ($stationl[2] => 1){
74         $digitalstationband = $stationl[2];
75 }else{
76         $digitalstationband = 0;
77 }
78     $sth = $dbh->prepare($stmt{'addpidatq.4'});
79     $sth->execute($pid);
80 ($pid ,
81 $tid ,
82 $stationid ,
83 $countno,
84 $subtitle,
85 $startdatetime,
86 $enddatetime,
87 $startoffset ,
88 $lengthmin,
89 $atid ) = $sth->fetchrow_array();
90 # print "$pid ,$tid ,$stationid ,$countno,$subtitle,$startdatetime,$enddatetime,$startoffset ,$lengthmin,$atid \n";
91
92 if($now< $startdatetime){#放送が未来の日付なら
93 #もし新開始時刻が15分移譲先なら再キュー
94 $startafter = &calclength($now,$startdatetime);
95 &writelog("addpidatq DEBUG \$startafter $startafter \$now $now \$startdatetime $startdatetime");
96
97 if ($startafter > 14 ){
98
99 #キュー削除
100  Schedule::At::remove ( TAG => "$pid"."_X");
101         &writelog("addpidatq remove que $pid");
102
103
104 #キュー入れ
105         #プロセス起動時刻は番組開始時刻の-5分
106 $atdateparam = &calcatqparam(300);
107         Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/folprep.pl $pid" , TAG => "$pid"."_X");
108         &writelog("addpidatq TIME $atdateparam   COMMAND $toolpath/perl/folprep.pl $pid ");
109 }else{
110 $atdateparam = &calcatqparam(60);
111 $reclength = $lengthmin * 60;
112
113 #キュー削除
114  Schedule::At::remove ( TAG => "$pid"."_R");
115         &writelog("addpidatq remove que $pid");
116
117 if ($countno eq ""){
118         $countno = "0";
119 }
120
121 Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid $stationid $usedigital $digitalstationband $digitalch" , TAG => "$pid"."_R");
122         &writelog("addpidatq TIME $atdateparam   COMMAND $toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid $stationid $usedigital $digitalstationband $digitalch");
123
124 }#end #もし新開始時刻が15分移譲先なら再キュー
125
126 }else{
127 &writelog("addpidatq drop:expire $pid $startafter $now $startdatetime");
128 }#放送が未来の日付なら
129
130 }else{
131 print "error record TID=$tid SID=$station $titlecount[0] match:$DBQuery\n";
132 &writelog("addpidatq error record TID=$tid SID=$station $titlecount[0] match:$DBQuery");
133
134 }#end if ($titlecount[0]  == 1 ){
135
136
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed