1 |
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
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 |
|
---|
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 |
|
---|
57 |
$now = &epoch2foldate(time()); |
---|
58 |
|
---|
59 |
|
---|
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 |
|
---|
91 |
|
---|
92 |
if($now< $startdatetime){ |
---|
93 |
|
---|
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 |
|
---|
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 |
} |
---|
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 |
} |
---|
135 |
|
---|
136 |
|
---|