-
Notifications
You must be signed in to change notification settings - Fork 3
/
mkmovies2mysql_includes.pl
86 lines (75 loc) · 2.24 KB
/
mkmovies2mysql_includes.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# ---------------
sub mysql_insert() {
$fh = shift;
$file = shift;
$name = shift;
$title = shift;
$url = shift;
$year = shift;
$genres = shift;
$casts = shift;
$directors = shift;
$plot = shift;
$year = 0 if(!$year);
$title =~ s/ \(.*//;
$title =~ s/ - $//;
$title =~ s/ \(ISO\)//;
$plot =~ s/.*: //;
$plot =~ s/\"/\'/g;
$plot =~ s/\<br\>$//i;
$casts =~ s/, /, /g;
$casts =~ s/ /, /g;
if(! defined($DATA{lc($name)})) {
$DATA{lc($name)} = "$file;$name;$title;$url;$year;$genres;$casts;$directors;$plot";
print $fh "INSERT IGNORE INTO Media(Name,Title) VALUES (\"$name\", \"$title\");\n";
print $fh "INSERT IGNORE INTO Data(Name,URL,File,Year,Plot) VALUES (\"$name\", \"$url\", \"$file\", $year, \"$plot\");\n";
if(($file =~ /\/ISOs\//) || ($title =~ /ISO/i) || ($name =~ /ISO/i)) {
if($genres) {
$genres .= ", ISO";
} else {
$genres = "ISO";
}
}
if(($year > 0) && (! defined($YEARS{$year}))) {
$YEARS{$year} = $year;
print $fh "INSERT IGNORE INTO Years(Year) VALUES (\"$year\");\n";
}
if($genres) {
@genres = split(', ', $genres);
for $genre (@genres) {
print $fh "INSERT IGNORE INTO Genres VALUES (\"$name\", \"$genre\");\n";
if(! defined($GENRES{lc($genre)})) {
$GENRES{lc($genre)} = $genre;
print $fh "INSERT IGNORE INTO Types(Type) VALUES (\"$genre\");\n";
}
}
}
if($casts) {
@casts = split(', ', $casts);
for $cast (@casts) {
$cast =~ s/^\ //;
$cast =~ s/\|.*//;
$cast =~ s/"/'/g;
if(($cast !~ /^$/) &&
($cast !~ /&#x/) &&
($cast !~ /\| See full cast/i) &&
($cast !~ /crew/))
{
print $fh "INSERT IGNORE INTO Casts VALUES (\"$name\", \"$cast\");\n";
}
}
}
@directors = split(', ', $directors);
for $director (@directors) {
if(($director !~ /^$/) &&
($director ne '1') &&
($director !~ /more credit/) &&
($director !~ /See full technical specs/i) &&
($director !~ /^&#x/))
{
print $fh "INSERT IGNORE INTO Directors VALUES (\"$name\", \"$director\");\n";
}
}
}
}
1;