root/trunk/install/perl/addatq.pl

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

SQLite採用

  • svn:executable 属性の設定値:
Line 
1 #!/usr/bin/perl
2 #
3 # Anime recording system foltia
4 # http://www.dcc-jpl.com/soft/foltia/
5 #
6 #addatq.pl
7 #
8 #TIDと局IDを受け取りatqに入れる
9 # addatq.pl <TID> <StationID> [DELETE]
10 # DELETEフラグがつくと削除のみ行う
11 #
12 # DCC-JPL Japan/foltia project
13 #
14 #
15
16 use DBI;
17 use DBD::Pg;
18 use DBD::SQLite;
19 use Schedule::At;
20 use Time::Local;
21
22 $path = $0;
23 $path =~ s/addatq.pl$//i;
24 if ($path ne "./"){
25 push( @INC, "$path");
26 }
27
28 require "foltialib.pl";
29
30 #引き数がアルか?
31 $tid = $ARGV[0] ;
32 $station = $ARGV[1];
33
34 if (($tid eq "" )|| ($station eq "")){
35         #引き数なし出実行されたら、終了
36         print "usage;addatq.pl <TID> <StationID> [DELETE]\n";
37         exit;
38 }
39
40 #DB検索(TIDとStationIDからPIDへ)
41 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;;
42
43 if ($station == 0){
44     $sth = $dbh->prepare($stmt{'addatq.1'});
45     $sth->execute($tid);
46 }else{
47     $sth = $dbh->prepare($stmt{'addatq.2'});
48     $sth->execute($tid, $station);
49 }
50  @titlecount = $sth->fetchrow_array;
51 #件数数える
52
53 #2以上だったら
54 if ($titlecount[0]  >= 2){
55     #全局録りが含まれているか調べる
56     $kth = $dbh->prepare($stmt{'addatq.3'});
57     $kth->execute($tid);
58         @reservecounts = $kth->fetchrow_array;
59
60         if($reservecounts[0] >= 1 ){#含まれていたら
61                 if($tid == 0){
62                 #今回の引き数がSID 0だったら
63             #全局録りだけ予約
64 #               &writelog("addatq  DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}");
65                 &addcue;
66                 }else{
67                 #ほかの全局録画addatqが予約入れてくれるからなにもしない
68 #               &writelog("addatq  DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}");
69                 exit;
70                 }#end if ふくまれていたら
71         }#endif 2つ以上   
72 }elsif($titlecount[0]  == 1){
73                 &addcue;
74 }else{
75     &writelog("addatq  error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}");
76 }
77
78 #旧処理
79 # if ($titlecount[0]  == 1 ){
80 #       & addcue;
81 # }else{
82 #&writelog("addatq  error record TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}");
83 #}
84
85 sub addcue{
86
87 if ($station == 0){
88         $sth = $dbh->prepare($stmt{'addatq.addcue.1'});
89         $sth->execute($tid);
90 }else{
91         $sth = $dbh->prepare($stmt{'addatq.addcue.2'});
92         $sth->execute($tid, $station);
93 }
94  @titlecount= $sth->fetchrow_array;
95 $bitrate = $titlecount[2];#ビットレート取得
96
97 #PID抽出
98     $now = &epoch2foldate(time());
99     $twodaysafter = &epoch2foldate(time() + (60 * 60 * 24 * 2));
100 #キュー入れは直近2日後まで
101 if ($station == 0 ){
102         $sth = $dbh->prepare($stmt{'addatq.addcue.3'});
103         $sth->execute($tid, $now, $twodaysafter);
104 }else{
105 #stationIDからrecch
106         $stationh = $dbh->prepare($stmt{'addatq.addcue.4'});
107         $stationh->execute($station);
108 @stationl =  $stationh->fetchrow_array;
109 $recch = $stationl[1];
110
111         $sth = $dbh->prepare($stmt{'addatq.addcue.5'});
112         $sth->execute($tid, $station, $now, $twodaysafter);
113     }
114  
115 while (($pid ,
116 $tid ,
117 $stationid ,
118 $countno,
119 $subtitle,
120 $startdatetime,
121 $enddatetime,
122 $startoffset ,
123 $lengthmin,
124 $atid ) = $sth->fetchrow_array()) {
125
126 if ($station == 0 ){
127 #stationIDからrecch
128             $stationh = $dbh->prepare($stmt{'addatq.addcue.6'});
129             $stationh->execute($stationid);
130 @stationl =  $stationh->fetchrow_array;
131 $recch = $stationl[1];
132 }
133 #キュー入れ
134         #プロセス起動時刻は番組開始時刻の-1分
135 $atdateparam = &calcatqparam(300);
136 $reclength = $lengthmin * 60;
137 #&writelog("TIME $atdateparam COMMAND $toolpath/perl/tvrecording.pl $recch $reclength 0 0 $bitrate $tid $countno");
138 #キュー削除
139  Schedule::At::remove ( TAG => "$pid"."_X");
140         &writelog("addatq remove $pid");
141 if ( $ARGV[2] eq "DELETE"){
142         &writelog("addatq remove  only $pid");
143 }else{
144         Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/folprep.pl $pid" , TAG => "$pid"."_X");
145         &writelog("addatq TIME $atdateparam   COMMAND $toolpath/perl/folprep.pl $pid ");
146 }
147 ##processcheckdate
148 #&writelog("addatq TIME $atdateparam COMMAND $toolpath/perl/schedulecheck.pl");
149 }#while
150
151
152
153 }#endsub
154
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed