mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-15 17:12:36 +02:00
2020-02-02 Fred Gleason <fredg@paravelsystems.com>
* Added support for reading ISRCs from MusicBrainz.
This commit is contained in:
parent
faf8d098ed
commit
acec6be323
@ -19475,3 +19475,5 @@
|
||||
in rdlibrary(1).
|
||||
2020-02-01 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added support for saving Label data from MusicBrainz releases.
|
||||
2020-02-02 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added support for reading ISRCs from MusicBrainz.
|
||||
|
@ -94,48 +94,52 @@ void RDDiscLookup::lookup()
|
||||
}
|
||||
|
||||
//
|
||||
// Get some basic disc parameters (CDDB DiskID, MusicBrainz mbid and,
|
||||
// if enabled in rdadmin(1), MCN and ISRCs).
|
||||
// Get some basic disc parameters,
|
||||
//
|
||||
DiscId *disc=discid_new();
|
||||
if(rda->libraryConf()->readIsrc()) {
|
||||
if(discid_read(disc,rda->libraryConf()->ripperDevice().toUtf8())==0) {
|
||||
QMessageBox::warning(this,caption()+" - "+tr("Error"),
|
||||
tr("Unable to read CD.")+
|
||||
"\n["+QString(discid_get_error_msg(disc))+"]");
|
||||
discid_free(disc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(discid_read_sparse(disc,rda->libraryConf()->ripperDevice().toUtf8(),0)==0) {
|
||||
QMessageBox::warning(this,caption()+" - "+tr("Error"),
|
||||
tr("Unable to read CD.")+
|
||||
"\n["+QString(discid_get_error_msg(disc))+"]");
|
||||
discid_free(disc);
|
||||
return;
|
||||
}
|
||||
if(discid_read_sparse(disc,rda->libraryConf()->ripperDevice().toUtf8(),0)==0) {
|
||||
QMessageBox::warning(this,caption()+" - "+tr("Error"),
|
||||
tr("Unable to read CD.")+
|
||||
"\n["+QString::fromUtf8(discid_get_error_msg(disc))+"]");
|
||||
discid_free(disc);
|
||||
return;
|
||||
}
|
||||
discRecord()->setDiscId(QString(discid_get_freedb_id(disc)).toUInt(NULL,16));
|
||||
discRecord()->setDiscMbId(discid_get_id(disc));
|
||||
discRecord()->setMbSubmissionUrl(discid_get_submission_url(disc));
|
||||
if(rda->libraryConf()->readIsrc()) {
|
||||
|
||||
//
|
||||
// Call the low-level driver to do its lookup.
|
||||
//
|
||||
lookupRecord();
|
||||
|
||||
//
|
||||
// If the low-level driver didn't find ISRCs, and the user has requested
|
||||
// them, try to find them on the disc.
|
||||
//
|
||||
// WARNING: This operation can be VERY expensive if the disc does not in
|
||||
// fact contain ISRCs!
|
||||
//
|
||||
if((!discRecord()->hasIsrcs())&&rda->libraryConf()->readIsrc()) {
|
||||
if(discid_read(disc,rda->libraryConf()->ripperDevice().toUtf8())==0) {
|
||||
QMessageBox::warning(this,caption()+" - "+tr("Error"),
|
||||
tr("Unable to read CD.")+
|
||||
"\n["+QString::fromUtf8(discid_get_error_msg(disc))+"]");
|
||||
discid_free(disc);
|
||||
return;
|
||||
}
|
||||
discRecord()->setMcn(discid_get_mcn(disc));
|
||||
int first=discid_get_first_track_num(disc);
|
||||
int last=discid_get_last_track_num(disc);
|
||||
for(int i=first;i<=last;i++) {
|
||||
if((i-first)<lookup_record->tracks()) {
|
||||
if((i-first)<discRecord()->tracks()) {
|
||||
discRecord()->setIsrc(i-first,
|
||||
RDDiscLookup::normalizedIsrc(discid_get_track_isrc(disc,i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
discid_free(disc);
|
||||
|
||||
//
|
||||
// Call the low-level driver to complete the lookup.
|
||||
//
|
||||
lookupRecord();
|
||||
discid_free(disc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,6 +333,17 @@ void RDDiscRecord::setTrackMbId(int track,const QString &str)
|
||||
}
|
||||
|
||||
|
||||
bool RDDiscRecord::hasIsrcs() const
|
||||
{
|
||||
for(int i=0;i<tracks();i++) {
|
||||
if(isrc(i).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString RDDiscRecord::isrc(int track) const
|
||||
{
|
||||
if(track<CDROM_LEADOUT) {
|
||||
|
@ -81,6 +81,7 @@ class RDDiscRecord
|
||||
void setTrackArtist(int track,QString artist);
|
||||
QString trackMbId(int track) const;
|
||||
void setTrackMbId(int track,const QString &str);
|
||||
bool hasIsrcs() const;
|
||||
QString isrc(int track) const;
|
||||
void setIsrc(int track,QString isrc);
|
||||
QString dump();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <musicbrainz5/ArtistCredit.h>
|
||||
#include <musicbrainz5/Disc.h>
|
||||
#include <musicbrainz5/HTTPFetch.h>
|
||||
#include <musicbrainz5/ISRC.h>
|
||||
#include <musicbrainz5/Label.h>
|
||||
#include <musicbrainz5/LabelInfo.h>
|
||||
#include <musicbrainz5/Medium.h>
|
||||
@ -196,7 +197,7 @@ RDDiscLookup::Result RDMbLookup::ProcessRelease(MusicBrainz5::CRelease *release)
|
||||
// Extract Extended Release Data
|
||||
//
|
||||
MusicBrainz5::CQuery::tParamMap params;
|
||||
params["inc"]="artists labels recordings";
|
||||
params["inc"]="artists labels recordings isrcs";
|
||||
MusicBrainz5::CMetadata metadata=mbq.Query("release",release->ID(),"",params);
|
||||
if(metadata.Release()) {
|
||||
//
|
||||
@ -238,7 +239,14 @@ RDDiscLookup::Result RDMbLookup::ProcessRelease(MusicBrainz5::CRelease *release)
|
||||
setTrackTitle(k,QString::fromUtf8(recording->Title().c_str()));
|
||||
discRecord()->
|
||||
setTrackMbId(k,QString::fromUtf8(recording->ID().c_str()));
|
||||
//std::cout << k << ": " << recording->Title() << std::endl;
|
||||
MusicBrainz5::CISRCList *isrcs=recording->ISRCList();
|
||||
if(isrcs) {
|
||||
if(isrcs->NumItems()>0) {
|
||||
discRecord()->
|
||||
setIsrc(k,RDDiscLookup::normalizedIsrc(QString::fromUtf8(isrcs->
|
||||
Item(0)->ID().c_str())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user