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 |
|
---|
31 |
$query = "DELETE FROM foltia_m2pfiles "; |
---|
32 |
$sth = $dbh->prepare($query); |
---|
33 |
$sth->execute(); |
---|
34 |
|
---|
35 |
while ($file = glob("$recfolderpath/*.m2p")) { |
---|
36 |
$file =~ s/$recfolderpath\///; |
---|
37 |
$query = "insert into foltia_m2pfiles values ('$file')"; |
---|
38 |
$sth = $dbh->prepare($query); |
---|
39 |
$sth->execute(); |
---|
40 |
|
---|
41 |
} |
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
$query = "DELETE FROM foltia_mp4files "; |
---|
47 |
$sth = $dbh->prepare($query); |
---|
48 |
$sth->execute(); |
---|
49 |
|
---|
50 |
@mp4filelist = `find $recfolderpath | grep MP4`; |
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
foreach (@mp4filelist) { |
---|
58 |
chomp(); |
---|
59 |
s/$recfolderpath\///; |
---|
60 |
|
---|
61 |
|
---|
62 |
@fileline = split (/\//); |
---|
63 |
$filetid = $fileline[0]; |
---|
64 |
$filetid =~ s/[^0-9]//g; |
---|
65 |
|
---|
66 |
$query = "insert into foltia_mp4files values ('$filetid','$fileline[2]')"; |
---|
67 |
$sth = $dbh->prepare($query); |
---|
68 |
$sth->execute(); |
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 |
|
---|
74 |
} |
---|