在 Perl 中获取音频 CD 的 CDDB 信息的最佳方法是什么?
从音频 CD 获取 CD 标题和 CD 曲目名称的最佳方法是什么? 我尝试了这个模块,但它不起作用。
#!/usr/bin/env perl
use warnings;
use strict;
use CDDB_get qw( get_cddb );
my %config;
$config{CDDB_HOST} = "freedb.freedb.org";
$config{CDDB_PORT} = 8880;
$config{CDDB_MODE} = "cddb";
$config{CD_DEVICE} = "/dev/sr1";
# user interaction welcome?
$config{input} = 1;
my %cd = get_cddb( \%config ); # line 16
print "$_ : $cd{$_}\n" for keys %cd;
unless( defined $cd{title} ) {
die "no cddb entry found";
}
print "artist: $cd{artist}\n";
print "title: $cd{title}\n";
print "category: $cd{cat}\n";
print "cddbid: $cd{id}\n";
print "trackno: $cd{tno}\n";
my $n = 1;
for my $i ( @{$cd{track}} ) {
print "track $n: $i\n";
$n++;
}
# OUT:
# Odd number of elements in hash assignment at ./cddb_get.pl line 16.
# Use of uninitialized value in list assignment at ./cddb_get.pl line 16.
# Use of uninitialized value in concatenation (.) or string at ./cddb_get.pl line 18.
# :
# no cddb entry found at ./cddb_get.pl line 21.
What is the best way to get the cd-title and the cd-track-names from an audio CD?
I tried this module, but it didn't work.
#!/usr/bin/env perl
use warnings;
use strict;
use CDDB_get qw( get_cddb );
my %config;
$config{CDDB_HOST} = "freedb.freedb.org";
$config{CDDB_PORT} = 8880;
$config{CDDB_MODE} = "cddb";
$config{CD_DEVICE} = "/dev/sr1";
# user interaction welcome?
$config{input} = 1;
my %cd = get_cddb( \%config ); # line 16
print "$_ : $cd{$_}\n" for keys %cd;
unless( defined $cd{title} ) {
die "no cddb entry found";
}
print "artist: $cd{artist}\n";
print "title: $cd{title}\n";
print "category: $cd{cat}\n";
print "cddbid: $cd{id}\n";
print "trackno: $cd{tno}\n";
my $n = 1;
for my $i ( @{$cd{track}} ) {
print "track $n: $i\n";
$n++;
}
# OUT:
# Odd number of elements in hash assignment at ./cddb_get.pl line 16.
# Use of uninitialized value in list assignment at ./cddb_get.pl line 16.
# Use of uninitialized value in concatenation (.) or string at ./cddb_get.pl line 18.
# :
# no cddb entry found at ./cddb_get.pl line 21.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将其放在
use CDDB_get
行之前,以获得 STDERR 的调试输出。Try putting
before the
use CDDB_get
line in order to get debugging output to STDERR.您确定模块中 FreeDB 的 API URL 正确吗?
您可以尝试使用 HTTP 而不是 CDDBP 吗?
来自 FreeDB 文档:
Are you sure the API URL to FreeDB is correct in the module?
Can you try HTTP instead of CDDBP?
From the FreeDB documentation:
我会考虑在 musicbrainz.org 上查找信息。
使用 MusicBrainz::DiscID 查找 CD 的光盘 ID 并使用 WebService::MusicBrainz 检索数据非常简单:
I would consider looking information up on musicbrainz.org instead.
Using MusicBrainz::DiscID to find the discid of a cd and WebService::MusicBrainz to retrieve the data is quite easy: