-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcddb-collection.pl
executable file
·66 lines (45 loc) · 1.36 KB
/
cddb-collection.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
#!/usr/bin/perl -w
#
# cddb_add_db.pl
#
# Adds the specified CDDB to the database as "owned"
use strict ;
use CGI '-utf8';
use DBI ;
use Config::Simple ;
use Cddb ;
sub insert_cddb {
my($dbh, $artist, $title, $cddb_id) = @_ ;
my $sql_statement = "INSERT INTO `T_CDs` (`CD_Artist`, `CD_Title`, `CD_ID`) VALUES (?, ?, ?)" ;
my $sth = $dbh->prepare($sql_statement) ;
$sth->execute($artist, $title, $cddb_id) ;
}
####################################
## main starts here
##
## If it runs successfully, there is no HTML output from this script, it only redirects
## back to the referer
## globals
my $cfg = new Config::Simple('.cddbrc') ;
my $cddb_dir = $cfg->param('cddb_dir') ;
my $cgi = new CGI ;
$cgi->charset('utf-8') ;
my $cddb_genre_and_id = $cgi->param('cddb') ;
#my $artist = $cgi->param('artist') ;
#my $title = $cgi->param('title') ;
my $dbh = setup_mysql($cfg) ;
my $cddb_id = $cddb_genre_and_id ;
$cddb_id =~ s|.+/|| ;
my($artist, $title) = artist_and_title("${cddb_dir}/${cddb_genre_and_id}") ;
insert_cddb($dbh, $artist, $title, $cddb_id) ;
exit print $cgi->redirect($cgi->referer());
###########
my $doc_title = "CDDB Database Add" ;
print $cgi->header ;
print $cgi->start_html(-title=>$doc_title,
-style=>'../css/cddb.css',
) ;
print $cgi->h1("Something didn't work") ;
$cgi->end_html ;
## end of main
####################################