1 |
#!/usr/bin/perl |
---|
2 |
# |
---|
3 |
# Anime recording system foltia |
---|
4 |
# http://www.dcc-jpl.com/soft/foltia/ |
---|
5 |
# |
---|
6 |
# usage :updatem2pfiletable.pl |
---|
7 |
# |
---|
8 |
# m2pfileのリストをテーブルに入れる |
---|
9 |
# 全deleteして更新する |
---|
10 |
# おもにメンテナンス用 |
---|
11 |
# または一日一回ぐらいcronで実行させてもいいかも |
---|
12 |
# |
---|
13 |
# DCC-JPL Japan/foltia project |
---|
14 |
# |
---|
15 |
|
---|
16 |
use DBI; |
---|
17 |
use DBD::Pg; |
---|
18 |
use DBD::SQLite; |
---|
19 |
|
---|
20 |
$path = $0; |
---|
21 |
$path =~ s/updatem2pfiletable.pl$//i; |
---|
22 |
if ($path ne "./"){ |
---|
23 |
push( @INC, "$path"); |
---|
24 |
} |
---|
25 |
|
---|
26 |
require "foltialib.pl"; |
---|
27 |
$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; |
---|
28 |
|
---|
29 |
$dbh->{AutoCommit} = 0; |
---|
30 |
# ひとまず消す |
---|
31 |
$sth = $dbh->prepare($stmt{'updatem2pfiletable.1'}); |
---|
32 |
$sth->execute(); |
---|
33 |
while ($file = glob("$recfolderpath/*.m2?")) { |
---|
34 |
$file =~ s/$recfolderpath\///; |
---|
35 |
$sth = $dbh->prepare($stmt{'updatem2pfiletable.2'}); |
---|
36 |
$sth->execute($file); |
---|
37 |
# print "$file\n"; |
---|
38 |
}#while |
---|
39 |
while ($file = glob("$recfolderpath/*.aac")) { |
---|
40 |
$file =~ s/$recfolderpath\///; |
---|
41 |
$sth = $dbh->prepare($stmt{'updatem2pfiletable.2'}); |
---|
42 |
$sth->execute($file); |
---|
43 |
# print "$file\n"; |
---|
44 |
}#while |
---|
45 |
|
---|
46 |
$oserr = $dbh->commit; |
---|
47 |
|
---|
48 |
# foltia_mp4files |
---|
49 |
@mp4filelist = `find ${recfolderpath}/ | grep MP4`;#by foltia dev ticket #5 http://www.dcc-jpl.com/foltia/ticket/5 |
---|
50 |
|
---|
51 |
# ひとまず消す |
---|
52 |
$sth = $dbh->prepare($stmt{'updatem2pfiletable.3'}); |
---|
53 |
$sth->execute(); |
---|
54 |
|
---|
55 |
|
---|
56 |
foreach (@mp4filelist) { |
---|
57 |
chomp(); |
---|
58 |
s/$recfolderpath\///; |
---|
59 |
@fileline = split (/\//); |
---|
60 |
$filetid = $fileline[0]; |
---|
61 |
$filetid =~ s/[^0-9]//g; |
---|
62 |
if (($filetid ne "" )&& ($fileline[2] ne "" )){ |
---|
63 |
$sth = $dbh->prepare($stmt{'updatem2pfiletable.4'}); |
---|
64 |
$oserr = $sth->execute($filetid, $fileline[2]); |
---|
65 |
#print "$filetid;$fileline[2];$query\n" |
---|
66 |
# http://www.atmarkit.co.jp/fnetwork/rensai/sql03/sql1.html |
---|
67 |
}#end if |
---|
68 |
}# end foreach |
---|
69 |
$oserr = $dbh->commit; |
---|
70 |
|
---|