root/trunk/install/perl/addpidatq.pl

リビジョン 83, 3.8 kB (コミッタ: sorshi, コミット時期: 16 年 前)

foltiaHD最初のリリース。
デジタル録画はFriio/Friio BS/CSのみに対応。
ivtvは1.0系使用になりました。

  • 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,digital 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 if ($titlecount[1] >= 1){
55         $usedigital = $titlecount[1];#デジタル優先フラグ
56 }else{
57         $usedigital = 0;
58 }
59
60 #PID抽出
61 $now = &epoch2foldate(`date +%s`);
62
63 #stationIDからrecch
64 $DBQuery =  "SELECT stationrecch,digitalch ,digitalstationband ,foltia_station.stationid  FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = '$pid'  AND  foltia_subtitle.stationid =  foltia_station.stationid ";
65
66  $stationh = $dbh->prepare($DBQuery);
67         $stationh->execute();
68 @stationl =  $stationh->fetchrow_array;
69 $recch = $stationl[0];
70 if ($recch eq ""){
71         &writelog("addpidatq ERROR recch is NULL:$DBQuery.");
72         exit 1;
73 }
74 if ($stationl[1] => 1){
75         $digitalch = $stationl[1];
76 }else{
77         $digitalch = 0;
78 }
79 if ($stationl[2] => 1){
80         $digitalstationband = $stationl[2];
81 }else{
82         $digitalstationband = 0;
83 }
84 $DBQuery =  "SELECT  * FROM  foltia_subtitle WHERE pid='$pid' ";
85  $sth = $dbh->prepare($DBQuery);
86 $sth->execute();
87 ($pid ,
88 $tid ,
89 $stationid ,
90 $countno,
91 $subtitle,
92 $startdatetime,
93 $enddatetime,
94 $startoffset ,
95 $lengthmin,
96 $atid ) = $sth->fetchrow_array();
97 # print "$pid ,$tid ,$stationid ,$countno,$subtitle,$startdatetime,$enddatetime,$startoffset ,$lengthmin,$atid \n";
98
99 if($now< $startdatetime){#放送が未来の日付なら
100 #もし新開始時刻が15分移譲先なら再キュー
101 $startafter = &calclength($now,$startdatetime);
102 &writelog("addpidatq DEBUG \$startafter $startafter \$now $now \$startdatetime $startdatetime");
103
104 if ($startafter > 14 ){
105
106 #キュー削除
107  Schedule::At::remove ( TAG => "$pid"."_X");
108         &writelog("addpidatq remove que $pid");
109
110
111 #キュー入れ
112         #プロセス起動時刻は番組開始時刻の-5分
113 $atdateparam = &calcatqparam(300);
114         Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/folprep.pl $pid" , TAG => "$pid"."_X");
115         &writelog("addpidatq TIME $atdateparam   COMMAND $toolpath/perl/folprep.pl $pid ");
116 }else{
117 $atdateparam = &calcatqparam(60);
118 $reclength = $lengthmin * 60;
119
120 #キュー削除
121  Schedule::At::remove ( TAG => "$pid"."_R");
122         &writelog("addpidatq remove que $pid");
123
124 if ($countno eq ""){
125         $countno = "0";
126 }
127
128 Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid $stationid $usedigital $digitalstationband $digitalch" , TAG => "$pid"."_R");
129         &writelog("addpidatq TIME $atdateparam   COMMAND $toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid $stationid $usedigital $digitalstationband $digitalch");
130
131 }#end #もし新開始時刻が15分移譲先なら再キュー
132
133 }else{
134 &writelog("addpidatq drop:expire $pid $startafter $now $startdatetime");
135 }#放送が未来の日付なら
136
137 }else{
138 print "error record TID=$tid SID=$station $titlecount[0] match:$DBQuery\n";
139 &writelog("addpidatq error record TID=$tid SID=$station $titlecount[0] match:$DBQuery");
140
141 }#end if ($titlecount[0]  == 1 ){
142
143
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed