1 |
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
use DBI; |
---|
17 |
use DBD::Pg; |
---|
18 |
|
---|
19 |
$path = $0; |
---|
20 |
$path =~ s/updatem2pfiletable.pl$//i; |
---|
21 |
if ($pwd ne "./"){ |
---|
22 |
push( @INC, "$path"); |
---|
23 |
} |
---|
24 |
|
---|
25 |
require "foltialib.pl"; |
---|
26 |
my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", |
---|
27 |
$DBDriv,$DBName,$DBHost,$DBPort); |
---|
28 |
$dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; |
---|
29 |
|
---|
30 |
$dbh->{AutoCommit} = 0; |
---|
31 |
|
---|
32 |
$query = "DELETE FROM foltia_m2pfiles "; |
---|
33 |
$sth = $dbh->prepare($query); |
---|
34 |
$sth->execute(); |
---|
35 |
|
---|
36 |
while ($file = glob("$recfolderpath/*.m2?")) { |
---|
37 |
$file =~ s/$recfolderpath\///; |
---|
38 |
$query = "insert into foltia_m2pfiles values ('$file')"; |
---|
39 |
$oserr = $dbh->do($query); |
---|
40 |
|
---|
41 |
} |
---|
42 |
$oserr = $dbh->commit; |
---|
43 |
|
---|
44 |
|
---|
45 |
@mp4filelist = `find ${recfolderpath}/ | grep MP4`; |
---|
46 |
|
---|
47 |
|
---|
48 |
$query = "DELETE FROM foltia_mp4files "; |
---|
49 |
$sth = $dbh->prepare($query); |
---|
50 |
$sth->execute(); |
---|
51 |
|
---|
52 |
|
---|
53 |
foreach (@mp4filelist) { |
---|
54 |
chomp(); |
---|
55 |
s/$recfolderpath\///; |
---|
56 |
@fileline = split (/\//); |
---|
57 |
$filetid = $fileline[0]; |
---|
58 |
$filetid =~ s/[^0-9]//g; |
---|
59 |
if (($filetid ne "" )&& ($fileline[2] ne "" )){ |
---|
60 |
$query = "insert into foltia_mp4files values ('$filetid','$fileline[2]')"; |
---|
61 |
$oserr = $dbh->do($query); |
---|
62 |
|
---|
63 |
|
---|
64 |
} |
---|
65 |
} |
---|
66 |
$oserr = $dbh->commit; |
---|
67 |
|
---|