root/trunk/install/perl/addpidatq.pl

リビジョン 1, 3.3 kB (コミッタ: jplcom, コミット時期: 16 年 前)

initial import

  • 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 Schedule::At;
17 use Time::Local;
18
19 $path = $0;
20 $path =~ s/addpidatq.pl$//i;
21 if ($pwd  ne "./"){
22 push( @INC, "$path");
23 }
24
25 require "foltialib.pl";
26
27
28 #引き数がアルか?
29 $pid = $ARGV[0] ;
30 if ($pid eq "" ){
31         #引き数なし出実行されたら、終了
32         print "usage;addpidatq.pl <PID>\n";
33         exit;
34 }
35
36
37 #DB検索(PID)
38         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d",
39                 $DBDriv,$DBName,$DBHost,$DBPort);
40          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;;
41
42 $DBQuery =  "SELECT count(*) FROM  foltia_subtitle WHERE pid = '$pid' ";
43          $sth = $dbh->prepare($DBQuery);
44         $sth->execute();
45  @titlecount= $sth->fetchrow_array;
46  
47  if ($titlecount[0]  == 1 ){
48
49 $DBQuery =  "SELECT bitrate FROM  foltia_tvrecord , foltia_subtitle  WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND pid='$pid' ";
50  $sth = $dbh->prepare($DBQuery);
51 $sth->execute();
52  @titlecount= $sth->fetchrow_array;
53 $bitrate = $titlecount[0];#ビットレート取得
54
55 #PID抽出
56 $now = &epoch2foldate(`date +%s`);
57
58 $DBQuery =  "SELECT stationrecch FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = '$pid'  AND  foltia_subtitle.stationid =  foltia_station.stationid ";
59
60
61 #stationIDからrecch
62  $stationh = $dbh->prepare($DBQuery);
63         $stationh->execute();
64 @stationl =  $stationh->fetchrow_array;
65 $recch = $stationl[0];
66
67 $DBQuery =  "SELECT  * FROM  foltia_subtitle WHERE pid='$pid' ";
68  $sth = $dbh->prepare($DBQuery);
69 $sth->execute();
70 ($pid ,
71 $tid ,
72 $stationid ,
73 $countno,
74 $subtitle,
75 $startdatetime,
76 $enddatetime,
77 $startoffset ,
78 $lengthmin,
79 $atid ) = $sth->fetchrow_array();
80 # print "$pid ,$tid ,$stationid ,$countno,$subtitle,$startdatetime,$enddatetime,$startoffset ,$lengthmin,$atid \n";
81
82 if($now< $startdatetime){#放送が未来の日付なら
83 #もし新開始時刻が15分移譲先なら再キュー
84 $startafter = &calclength($now,$startdatetime);
85 &writelog("addpidatq DEBUG \$startafter $startafter \$now $now \$startdatetime $startdatetime");
86
87 if ($startafter > 14 ){
88
89 #キュー削除
90  Schedule::At::remove ( TAG => "$pid"."_X");
91         &writelog("addpidatq remove que $pid");
92
93
94 #キュー入れ
95         #プロセス起動時刻は番組開始時刻の-5分
96 $atdateparam = &calcatqparam(300);
97         Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/folprep.pl $pid" , TAG => "$pid"."_X");
98         &writelog("addpidatq TIME $atdateparam   COMMAND $toolpath/perl/folprep.pl $pid ");
99 }else{
100 $atdateparam = &calcatqparam(60);
101 $reclength = $lengthmin * 60;
102
103 #キュー削除
104  Schedule::At::remove ( TAG => "$pid"."_R");
105         &writelog("addpidatq remove que $pid");
106
107 if ($countno eq ""){
108         $countno = "0";
109 }
110
111 Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/recwrap.pl $recch $reclength  $bitrate $tid $countno $pid" , TAG => "$pid"."_R");
112         &writelog("addpidatq TIME $atdateparam   COMMAND $toolpath/perl/recwrap.pl $recch $reclength  $bitrate $tid $countno $pid");
113
114 }#end #もし新開始時刻が15分移譲先なら再キュー
115
116 }else{
117 &writelog("addpidatq drop:expire  $pid  $startafter  $now  $startdatetime");
118 }#放送が未来の日付なら
119
120 }else{
121 print "error record TID=$tid SID=$station $titlecount[0] match:$DBQuery\n";
122 &writelog("addpidatq error record TID=$tid SID=$station $titlecount[0] match:$DBQuery");
123
124 }#end if ($titlecount[0]  == 1 ){
125
126
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed