227 | | my $epgstartdate = substr($foltiastarttime,0,8); # 8桁 20050807 |
---|
228 | | my @epgcounts = ""; |
---|
229 | | my $DBQuery = ""; |
---|
230 | | |
---|
231 | | #if ($currentworkdate eq "" ){#初回起動なら |
---|
232 | | if ( $currentworkch ne $ontvepgchannel){ |
---|
233 | | |
---|
234 | | |
---|
235 | | if ($epgstartdate >= $today){# xmltvtvから今日以降のデータが来ていれば |
---|
236 | | my $epgstartdatetime = $today * 10000 ; # 200508070000 12桁 |
---|
237 | | # 新規に入る予定の未来の番組表、全部いったん消す |
---|
238 | | # $DBQuery = "DELETE from foltia_epg where startdatetime > $epgstartdatetime AND ontvchannel = '$ontvepgchannel' "; |
---|
239 | | $sth = $dbh->prepare($stmt{'xmltv2foltia.chkerase.1'}); |
---|
240 | | $sth->execute($todaytime, $ontvepgchannel); |
---|
241 | | &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$stmt{'xmltv2foltia.chkerase.1'}"); |
---|
242 | | #$currentworkdate = "$today"; |
---|
243 | | $currentworkch = $ontvepgchannel ; |
---|
244 | | }else{ |
---|
245 | | &writelog("xmltv2foltia ERROR EPG INVALID:$epgstartdate:$today"); |
---|
246 | | #exit(); |
---|
247 | | }# endif xmltvtvから今日のデータが来ていれば |
---|
248 | | }#end if 初回起動なら |
---|
249 | | |
---|
250 | | } |
---|
| 220 | my $foltiaendtime = $_[2]; # 14桁 |
---|
| 221 | my @data = (); |
---|
| 222 | |
---|
| 223 | $foltiastarttime = substr($foltiastarttime,0,12); # 12桁 200508072254 |
---|
| 224 | $foltiaendtime = substr($foltiaendtime,0,12); # 12桁 200508072355 |
---|
| 225 | |
---|
| 226 | $sth = $dbh->prepare($stmt{'xmltv2foltia.replaceepg.1'}); |
---|
| 227 | $sth->execute($foltiastarttime , $foltiaendtime , $ontvepgchannel); |
---|
| 228 | |
---|
| 229 | while (@data = $sth->fetchrow_array()) { |
---|
| 230 | push(@deleteepgid,$data[0]); |
---|
| 231 | #&writelog("xmltv2foltia DEBUG push(\@deleteepgid,$data[0]);"); |
---|
| 232 | }#end while |
---|
| 233 | }#endsub replaceepg |
---|
| 234 | |
---|
265 | | if($foltiastarttime > $todaytime){ |
---|
266 | | |
---|
267 | | $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); |
---|
268 | | $sth->execute(); |
---|
269 | | @currentepgid = $sth->fetchrow_array; |
---|
270 | | |
---|
271 | | if ($currentepgid[0] < 1 ){ |
---|
272 | | $newepgid = 1; |
---|
273 | | }else{ |
---|
274 | | $newepgid = $currentepgid[0]; |
---|
275 | | $newepgid++; |
---|
276 | | } |
---|
| 247 | if($foltiaendtime > $todaytime){ |
---|
| 248 | # epgidはAUTOINCREMENTに変更した #2010/8/10 |
---|
| 249 | # $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); |
---|
| 250 | # $sth->execute(); |
---|
| 251 | # @currentepgid = $sth->fetchrow_array; |
---|
| 252 | # |
---|
| 253 | # if ($currentepgid[0] < 1 ){ |
---|
| 254 | # $newepgid = 1; |
---|
| 255 | # }else{ |
---|
| 256 | # $newepgid = $currentepgid[0]; |
---|
| 257 | # $newepgid++; |
---|
| 258 | # } |
---|
279 | | # $newepgid = $dbh->quote($newepgid ); |
---|
280 | | # $foltiastarttime = $dbh->quote($foltiastarttime); |
---|
281 | | # $foltiaendtime = $dbh->quote($foltiaendtime ); |
---|
282 | | # $lengthmin = $dbh->quote($lengthmin ); |
---|
283 | | # $channel = $dbh->quote($channel ); |
---|
284 | | # $title = $dbh->quote($title); |
---|
285 | | # $desc = $dbh->quote($desc); |
---|
286 | | # $category = $dbh->quote($category); |
---|
287 | | |
---|
288 | | $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); |
---|
289 | | $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || |
---|
290 | | warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; |
---|
291 | | |
---|
| 261 | |
---|
| 262 | #print "xmltv2foltia DEBUG :INSERT INTO foltia_epg VALUES ($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category)\n"; |
---|
| 263 | push (@foltiastarttime,$foltiastarttime); |
---|
| 264 | push (@foltiaendtime,$foltiaendtime); |
---|
| 265 | push (@lengthmin,$lengthmin); |
---|
| 266 | push (@channel,$channel); |
---|
| 267 | push (@title,$title); |
---|
| 268 | push (@desc,$desc); |
---|
| 269 | push (@category,$category); |
---|
| 270 | # $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); |
---|
| 271 | # $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; |
---|
299 | | |
---|
300 | | |
---|
301 | | |
---|
302 | | |
---|
303 | | |
---|
304 | | |
---|
305 | | |
---|
| 292 | #追加 |
---|
| 293 | for ($i=0;$i<$loopcount;$i++){ |
---|
| 294 | $sth = $dbh->prepare($stmt{'xmltv2foltia.commitdb.2'}); |
---|
| 295 | $sth->execute( $foltiastarttime[$i],$foltiaendtime[$i], $lengthmin[$i], $channel[$i], $title[$i], $desc[$i], $category[$i]) || warn "error: $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; |
---|
| 296 | #&writelog("xmltv2foltia DEBUG : INSERT INTO foltia_epg VALUES ( NULL , $foltiastarttime[$i],$foltiaendtime[$i], $lengthmin[$i], $channel[$i], $title[$i], $desc[$i], $category[$i])"); |
---|
| 297 | }# end for |
---|
| 298 | $dbh->do('COMMIT'); |
---|
| 299 | $dbh->{AutoCommit} = 1; |
---|
| 300 | }#end sub commitdb |
---|