2010-02-15 93 views
1

從音頻CD獲取CD標題和CD軌道名稱的最佳方法是什麼? 我試過這個模塊,但沒有奏效。在Perl中獲取音頻CD的CDDB信息的最佳方式是什麼?

#!/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. 
+1

「它不工作」 =? – bzlm

+0

什麼,更具體地說,沒有工作? –

+0

Uups,它工作,但不是所有的CD。 –

回答

4

嘗試把

BEGIN { $CDDB_get::debug = 1 } 

use CDDB_get前行,以獲得調試輸出到STDERR。

+0

cddb:result:202光盤ID xxxxxxxx不匹配。 –

+0

因此,從技術上講,模塊畢竟工作,這是一個沒有問題的? :) – bzlm

2

您確定FreeDB的API URL在模塊中是正確的嗎?

你可以嘗試使用HTTP而不是CDDBP嗎?

the FreeDB documentation

配置CDDB1-或freedb的感知 軟件指向freedb.freedb.org (隨機的freedb服務器)作爲 CDDB /的FreeDB服務器。

所有官方的FreeDB服務器都在端口8880和HTTP 運行cddbp在 端口80用於HTTP訪問的路徑是 /~cddb/cddb.cgi。

1

我會考慮在musicbrainz.org的信息。

使用的MusicBrainz ::盤標識符找到一個CD和WebService :: MusicBrainz上的盤標識符檢索數據是很容易的:

#!/usr/bin/perl 

use strict; 
use warnings; 

use MusicBrainz::DiscID; 
use WebService::MusicBrainz; 

my $discid=MusicBrainz::DiscID->new; 
if (!$discid->read) { 
    print STDERR "Error: " . $discid->error_msg . "\n"; 
    exit 1; 
} 
print "DiscID: " . $discid->id . "\n"; 

my $service=WebService::MusicBrainz->new_release; 
my $response=$service->search({ DISCID=>$discid->id }); 
my $release=$response->release; 

print "ARTIST: " . $release->artist->name . "\n"; 
print "ALBUM: " . $release->title . "\n"; 
相關問題