2022-09-01 Fred Gleason <fredg@paravelsystems.com>

* Added CD-Text support to rdlibrary(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-09-01 10:33:39 -04:00
parent 4071607711
commit 6606e39f6d
26 changed files with 984 additions and 227 deletions

View File

@@ -2,7 +2,7 @@
//
// RDDiscLookup instance class for accessing the FreeDB CD Database.
//
// (C) Copyright 2003-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -56,7 +56,7 @@ RDCddbLookup::~RDCddbLookup()
QString RDCddbLookup::sourceName() const
{
return QString("FreeDB");
return QString("CDDB");
}
@@ -153,7 +153,7 @@ void RDCddbLookup::readyReadData()
f0.erase(f0.begin());
f0.erase(f0.begin());
f0.erase(f0.begin());
discRecord()->setDiscTitle(f0.join(" "));
discRecord()->setDiscTitle(RDDiscRecord::RemoteSource,f0.join(" "));
snprintf(buffer,2048,"cddb read %s %08x\n",
(const char *)discRecord()->discGenre().toUtf8(),
discRecord()->discId());
@@ -245,10 +245,12 @@ void RDCddbLookup::readyReadData()
discRecord()->setDiscGenre(f0.at(0));
f0=titlesBox()->currentText().split("/");
if(f0.size()==2) {
discRecord()->setDiscTitle(f0.at(1).trimmed());
discRecord()->setDiscTitle(RDDiscRecord::RemoteSource,
f0.at(1).trimmed());
}
else {
discRecord()->setDiscTitle(titlesBox()->currentText().trimmed());
discRecord()->setDiscTitle(RDDiscRecord::RemoteSource,
titlesBox()->currentText().trimmed());
}
snprintf(buffer,2048,"cddb read %s %08x\n",
(const char *)discRecord()->discGenre().toUtf8(),
@@ -288,7 +290,8 @@ void RDCddbLookup::readyReadData()
}
ParsePair(&line,&tag,&value,&index);
if(tag=="DTITLE") {
discRecord()->setDiscTitle(value.left(value.length()-1));
discRecord()->setDiscTitle(RDDiscRecord::RemoteSource,
value.left(value.length()-1));
}
if(tag=="DYEAR") {
discRecord()->setDiscYear(value.toUInt());
@@ -302,7 +305,8 @@ void RDCddbLookup::readyReadData()
discRecord()->setDiscPlayOrder(value);
}
if((tag=="TTITLE")&&(index!=-1)) {
discRecord()->setTrackTitle(index,value.left(value.length()-1));
discRecord()->setTrackTitle(RDDiscRecord::RemoteSource,index,
value.left(value.length()-1));
}
if((tag=="EXTT")&&(index!=-1)) {
discRecord()->
@@ -333,7 +337,6 @@ void RDCddbLookup::errorData(QAbstractSocket::SocketError err)
}
lookup_state=0;
QApplication::restoreOverrideCursor();
emit lookupDone(RDCddbLookup::LookupError,err_msg);
}
@@ -344,8 +347,8 @@ void RDCddbLookup::FinishCddbLookup(RDCddbLookup::Result res,
lookup_socket->close();
lookup_state=0;
QApplication::restoreOverrideCursor();
emit lookupDone(res,err_msg);
profile("CDDB lookup finished");
processLookup(res,err_msg);
}

View File

@@ -2,7 +2,7 @@
//
// RDDiscLookup instance class for accessing the FreeDB CD Database.
//
// (C) Copyright 2003-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -56,16 +56,16 @@ class RDCddbLookup : public RDDiscLookup
private:
void FinishCddbLookup(RDCddbLookup::Result res,const QString &err_msg);
QString DecodeString(QString &str);
void ParsePair(QString *line,QString *tag,QString *value,int *index);
int GetIndex(QString *tag);
void SendToServer(const QString &msg);
QTcpSocket *lookup_socket;
int lookup_state;
QString lookup_username;
QString lookup_appname;
QString lookup_appver;
QString lookup_hostname;
QString DecodeString(QString &str);
void ParsePair(QString *line,QString *tag,QString *value,int *index);
int GetIndex(QString *tag);
void SendToServer(const QString &msg);
QTcpSocket *lookup_socket;
int lookup_state;
QString lookup_username;
QString lookup_appname;
QString lookup_appver;
QString lookup_hostname;
};
#endif // RDCDDBLOOKUP_H

View File

@@ -2,7 +2,7 @@
//
// Base class for CD metadata lookup methods
//
// (C) Copyright 2003-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -22,13 +22,12 @@
#include <stdlib.h>
#include <string.h>
#include <qapplication.h>
#include <qdatetime.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qtimer.h>
#include <discid/discid.h>
#include <QApplication>
#include <QDateTime>
#include <QMessageBox>
#include <QProcess>
#include <QRegExp>
#include <QTimer>
#include "rdtempdirectory.h"
#include "rddisclookup.h"
@@ -38,8 +37,20 @@ RDDiscLookup::RDDiscLookup(const QString &caption,FILE *profile_msgs,
QWidget *parent)
: RDDialog(parent)
{
QString err_msg;
lookup_caption=caption;
lookup_profile_msgs=profile_msgs;
lookup_has_cd_text=false;
lookup_disc=NULL;
lookup_temp_directory=new RDTempDirectory("rddisclookup");
if(!lookup_temp_directory->create(&err_msg)) {
QMessageBox::warning(this,caption+" - "+tr("Error"),
tr("Unable to create temporary directory")+
" \""+lookup_temp_directory->path()+"\".\n"+
"["+err_msg+"]");
}
lookup_titles_label=new QLabel(tr("Multiple Matches Found!"),this);
lookup_titles_label->setAlignment(Qt::AlignCenter|Qt::AlignVCenter);
@@ -57,6 +68,12 @@ RDDiscLookup::RDDiscLookup(const QString &caption,FILE *profile_msgs,
}
RDDiscLookup::~RDDiscLookup()
{
delete lookup_temp_directory;
}
QSize RDDiscLookup::sizeHint() const
{
return QSize(400,140);
@@ -65,7 +82,7 @@ QSize RDDiscLookup::sizeHint() const
QString RDDiscLookup::sourceName() const
{
return QString();
return QString("CD-Text");
}
@@ -75,6 +92,23 @@ QPixmap RDDiscLookup::sourceLogo() const
}
QPixmap RDDiscLookup::sourceLogo(RDDiscRecord::DataSource src) const
{
QPixmap ret=RDLibraryConf::cdServerLogo(RDLibraryConf::DummyType);
switch(src) {
case RDDiscRecord::LocalSource:
case RDDiscRecord::LastSource:
break;
case RDDiscRecord::RemoteSource:
ret=sourceLogo();
}
return ret;
}
QString RDDiscLookup::sourceUrl() const
{
return QString();
@@ -89,61 +123,99 @@ void RDDiscLookup::setCddbRecord(RDDiscRecord *rec)
void RDDiscLookup::lookup()
{
QString rip_dev=rda->libraryConf()->ripperDevice();
if(discRecord()->tracks()==0) {
return;
}
if((lookup_has_cd_text=ReadCdText(rip_dev))) {
profile("CD-TEXT lookup success");
}
else {
profile("CD-TEXT lookup failure");
}
//
// Get some basic disc parameters,
//
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
DiscId *disc=discid_new();
if(discid_read_sparse(disc,rda->libraryConf()->ripperDevice().toUtf8(),0)==0) {
if(lookup_disc!=NULL) {
discid_free(lookup_disc);
lookup_disc=NULL;
}
lookup_disc=discid_new();
if(discid_read_sparse(lookup_disc,rip_dev.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);
tr("Unable to read CD.")+
"\n["+QString::fromUtf8(discid_get_error_msg(lookup_disc))+"]");
discid_free(lookup_disc);
lookup_disc=NULL;
discid_free(lookup_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));
discRecord()->setDiscId(QString(discid_get_freedb_id(lookup_disc)).toUInt(NULL,16));
discRecord()->setDiscMbId(discid_get_id(lookup_disc));
discRecord()->setMbSubmissionUrl(discid_get_submission_url(lookup_disc));
QApplication::restoreOverrideCursor();
//
// Call the low-level driver to do its lookup.
//
lookupRecord();
}
void RDDiscLookup::lookupRecord()
{
processLookup(RDDiscLookup::ExactMatch,"OK");
}
void RDDiscLookup::processLookup(RDDiscLookup::Result result,
const QString &err_msg)
{
QString rip_dev=rda->libraryConf()->ripperDevice();
//
// 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
// WARNING: This operation can take a long time if the disc does not in
// fact contain ISRCs!
//
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
if((!discRecord()->hasIsrcs())&&rda->libraryConf()->readIsrc()) {
if(discid_read(disc,rda->libraryConf()->ripperDevice().toUtf8())==0) {
if(discid_read(lookup_disc,rip_dev.toUtf8())==0) {
QMessageBox::warning(this,caption()+" - "+tr("Error"),
tr("Unable to read CD.")+
"\n["+QString::fromUtf8(discid_get_error_msg(disc))+"]");
discid_free(disc);
"\n["+QString::fromUtf8(discid_get_error_msg(lookup_disc))+"]");
discid_free(lookup_disc);
lookup_disc=NULL;
return;
}
discRecord()->setMcn(discid_get_mcn(disc));
int first=discid_get_first_track_num(disc);
int last=discid_get_last_track_num(disc);
discRecord()->setMcn(discid_get_mcn(lookup_disc));
int first=discid_get_first_track_num(lookup_disc);
int last=discid_get_last_track_num(lookup_disc);
for(int i=first;i<=last;i++) {
if((i-first)<discRecord()->tracks()) {
discRecord()->setIsrc(i-first,
RDDiscLookup::normalizedIsrc(discid_get_track_isrc(disc,i)));
}
RDDiscLookup::normalizedIsrc(discid_get_track_isrc(lookup_disc,i)));
}
}
}
QApplication::restoreOverrideCursor();
discid_free(disc);
discid_free(lookup_disc);
lookup_disc=NULL;
emit lookupDone(RDDiscLookup::ExactMatch,"OK");
}
bool RDDiscLookup::hasCdText() const
{
return lookup_has_cd_text;
}
@@ -360,3 +432,82 @@ QString RDDiscLookup::normalizedUpcA(const QString &barcode,bool *ok)
}
return QString();
}
QString RDDiscLookup::tempDirectoryPath() const
{
return lookup_temp_directory->path();
}
bool RDDiscLookup::ReadCdText(const QString &cdda_dev)
{
RDProfile *title_profile=new RDProfile();
bool ret=false;
QString str;
QString cmd;
int exit_code;
QStringList args;
args.push_back("-D");
args.push_back(cdda_dev);
args.push_back("--info-only");
args.push_back("-v");
args.push_back("titles");
QProcess *proc=new QProcess(this);
proc->setWorkingDirectory(tempDirectoryPath());
proc->start("/usr/bin/cdda2wav",args);
proc->waitForFinished(); // 5 minutes
QByteArray output=proc->readAllStandardError();
if(proc->exitStatus()!=QProcess::NormalExit) {
QMessageBox::warning(this,lookup_caption+" - "+tr("Ripper Error"),
tr("CD-Text reader process crashed!"));
delete proc;
return false;
}
if((exit_code=proc->exitCode())!=0) {
QMessageBox::warning(this,lookup_caption+" - "+tr("Ripper Error"),
tr("CD-Text reader process returned an error!")+"\n"+
"["+output+"]");
delete proc;
return false;
}
delete proc;
//
// Read the Track Title Data File
//
for(int i=0;i<lookup_record->tracks();i++) {
title_profile->setSource(tempDirectoryPath()+
QString().sprintf("/audio_%02d.inf",i+1));
str=title_profile->stringValue("","Albumtitle","");
str.remove("'");
if((!str.isEmpty())&&(str!="''")) {
lookup_record->setDiscTitle(RDDiscRecord::LocalSource,str);
ret=true;
}
str=title_profile->stringValue("","Albumperformer","");
str.remove("'");
if((!str.isEmpty())&&(str!="''")) {
lookup_record->setDiscArtist(RDDiscRecord::LocalSource,str);
ret=true;
}
str=title_profile->stringValue("","Tracktitle","");
str.remove("'");
if((!str.isEmpty())&&(str!="''")) {
lookup_record->setTrackTitle(RDDiscRecord::LocalSource,i,str);
ret=true;
}
str=title_profile->stringValue("","Performer","");
str.remove("'");
if((!str.isEmpty())&&(str!="''")) {
lookup_record->setTrackArtist(RDDiscRecord::LocalSource,i,str);
ret=true;
}
}
return ret;
}

View File

@@ -2,7 +2,7 @@
//
// Base class for CD metadata lookup methods
//
// (C) Copyright 2003-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -24,6 +24,8 @@
#include <stdio.h>
#include <discid/discid.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qpixmap.h>
@@ -33,6 +35,7 @@
#include <rddiscrecord.h>
#include <rddialog.h>
#include <rdtempdirectory.h>
class RDDiscLookup : public RDDialog
{
@@ -40,12 +43,15 @@ class RDDiscLookup : public RDDialog
public:
enum Result {ExactMatch=0,NoMatch=1,LookupError=2};
RDDiscLookup(const QString &caption,FILE *profile_msgs,QWidget *parent=0);
~RDDiscLookup();
QSize sizeHint() const;
virtual QString sourceName() const;
virtual QPixmap sourceLogo() const;
QPixmap sourceLogo(RDDiscRecord::DataSource src) const;
virtual QString sourceUrl() const;
void setCddbRecord(RDDiscRecord *);
void lookup();
bool hasCdText() const;
static bool isrcIsValid(const QString &isrc);
static QString formattedIsrc(const QString &isrc,bool *ok=NULL);
static QString normalizedIsrc(const QString &isrc,bool *ok=NULL);
@@ -62,28 +68,34 @@ class RDDiscLookup : public RDDialog
void cancelData();
protected:
virtual void lookupRecord()=0;
virtual void lookupRecord();
void processLookup(RDDiscLookup::Result result,const QString &err_msg);
void resizeEvent(QResizeEvent *e);
RDDiscRecord *discRecord() const;
void profile(const QString &msg);
QComboBox *titlesBox();
QStringList *titlesKey();
QString tempDirectoryPath() const;
private:
QLabel *lookup_titles_label;
QComboBox *lookup_titles_box;
QStringList lookup_titles_key;
QPushButton *lookup_ok_button;
QPushButton *lookup_cancel_button;
RDDiscRecord *lookup_record;
QTcpSocket *lookup_socket;
int lookup_state;
QString lookup_username;
QString lookup_appname;
QString lookup_appver;
QString lookup_hostname;
FILE *lookup_profile_msgs;
QString lookup_caption;
bool ReadCdText(const QString &cdda_dev);
QLabel *lookup_titles_label;
QComboBox *lookup_titles_box;
QStringList lookup_titles_key;
QPushButton *lookup_ok_button;
QPushButton *lookup_cancel_button;
RDDiscRecord *lookup_record;
QTcpSocket *lookup_socket;
int lookup_state;
QString lookup_username;
QString lookup_appname;
QString lookup_appver;
QString lookup_hostname;
FILE *lookup_profile_msgs;
QString lookup_caption;
RDTempDirectory *lookup_temp_directory;
bool lookup_has_cd_text;
DiscId *lookup_disc;
};
#endif // RDDISCLOOKUP_H

View File

@@ -283,20 +283,20 @@ void RDDiscModel::setDisc(RDCdPlayer *player)
}
void RDDiscModel::refresh(RDDiscRecord *rec)
void RDDiscModel::refresh(RDDiscRecord *rec,RDDiscRecord::DataSource src)
{
beginResetModel();
for(int i=0;i<rec->tracks();i++) {
if(!rec->trackTitle(i).isEmpty()) {
d_texts[i][2]=rec->trackTitle(i);
if(!rec->trackTitle(src,i).isEmpty()) {
d_texts[i][2]=rec->trackTitle(src,i);
}
if(rec->trackArtist(i).isEmpty()) {
if(!rec->discArtist().isEmpty()) {
d_texts[i][3]=rec->discArtist();
if(rec->trackArtist(src,i).isEmpty()) {
if(!rec->discArtist(src).isEmpty()) {
d_texts[i][3]=rec->discArtist(src);
}
}
else {
d_texts[i][3]=rec->trackArtist(i);
d_texts[i][3]=rec->trackArtist(src,i);
}
}
endResetModel();

View File

@@ -2,7 +2,7 @@
//
// Data model for Audio CD track information
//
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2021-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -62,7 +62,7 @@ class RDDiscModel : public QAbstractTableModel
public slots:
void clear();
void setDisc(RDCdPlayer *player);
void refresh(RDDiscRecord *rec);
void refresh(RDDiscRecord *rec,RDDiscRecord::DataSource src);
private:
QPalette d_palette;

View File

@@ -2,7 +2,7 @@
//
// Container Class for Compact Disc Metadata
//
// (C) Copyright 2003-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -18,6 +18,8 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <QObject>
#include "rddiscrecord.h"
RDDiscRecord::RDDiscRecord()
@@ -28,12 +30,23 @@ RDDiscRecord::RDDiscRecord()
void RDDiscRecord::clear()
{
for(int i=0;i<CDROM_LEADOUT;i++) {
disc_track_title[RDDiscRecord::LocalSource][i]=
QObject::tr("Track")+QString().sprintf(" %d",i+1);
disc_track_title[RDDiscRecord::RemoteSource][i]="";
}
for(int i=0;i<RDDiscRecord::LastSource;i++) {
disc_has_data[i]=false;
disc_disc_title[i]="";
disc_disc_artist[i]="";
disc_disc_album[i]="";
for(int j=0;j<CDROM_LEADOUT;j++) {
disc_track_artist[i][j]="";
}
}
disc_tracks=0;
disc_disc_id=0;
disc_disc_length=0;
disc_disc_title="";
disc_disc_artist="";
disc_disc_album="";
disc_disc_author="";
disc_disc_year=0;
disc_disc_genre="";
@@ -41,9 +54,7 @@ void RDDiscRecord::clear()
disc_disc_playorder="";
disc_disc_release_mb_id="";
for(int i=0;i<CDROM_LEADOUT;i++) {
disc_track_title[i]="";
disc_track_extended[i]="";
disc_track_artist[i]="";
disc_track_isrc[i]="";
disc_track_offset[i]=0;
disc_track_recording_mb_id[i]="";
@@ -63,6 +74,12 @@ void RDDiscRecord::setTracks(int num)
}
bool RDDiscRecord::hasData(RDDiscRecord::DataSource src) const
{
return disc_has_data[src];
}
unsigned RDDiscRecord::discLength() const
{
return disc_disc_length;
@@ -107,7 +124,7 @@ QString RDDiscRecord::mcn() const
void RDDiscRecord::setMcn(const QString &mcn)
{
disc_mcn=mcn;
disc_mcn=mcn.trimmed();
}
@@ -119,7 +136,7 @@ QString RDDiscRecord::trackRecordingMbId(int track) const
void RDDiscRecord::setTrackRecordingMbId(int track,const QString &str)
{
disc_track_recording_mb_id[track]=str;
disc_track_recording_mb_id[track]=str.trimmed();
}
@@ -131,7 +148,7 @@ QString RDDiscRecord::discReleaseMbId() const
void RDDiscRecord::setDiscReleaseMbId(const QString &mbid)
{
disc_disc_release_mb_id=mbid;
disc_disc_release_mb_id=mbid.trimmed();
}
@@ -143,55 +160,62 @@ QString RDDiscRecord::mbSubmissionUrl() const
void RDDiscRecord::setMbSubmissionUrl(const QString &url)
{
disc_mb_submission_url=url;
disc_mb_submission_url=url.trimmed();
}
QString RDDiscRecord::discTitle() const
QString RDDiscRecord::discTitle(RDDiscRecord::DataSource src) const
{
return disc_disc_title;
return disc_disc_title[src];
}
void RDDiscRecord::setDiscTitle(QString title)
void RDDiscRecord::setDiscTitle(RDDiscRecord::DataSource src,
const QString &title)
{
int n;
disc_disc_title=title;
disc_disc_title[src]=title;
disc_has_data[src]=true;
disc_disc_title[src]=title.trimmed();
if((n=title.indexOf(" / "))!=-1) {
disc_disc_artist=title.left(n);
disc_disc_album=title.right(title.length()-n-3);
disc_disc_artist[src]=title.left(n).trimmed();
disc_disc_album[src]=title.right(title.length()-n-3).trimmed();
disc_disc_author="";
}
else {
disc_disc_album=title;
disc_disc_artist=title;
disc_disc_album[src]=title.trimmed();
disc_disc_artist[src]=title.trimmed();
disc_disc_author="";
}
}
QString RDDiscRecord::discArtist() const
QString RDDiscRecord::discArtist(RDDiscRecord::DataSource src) const
{
return disc_disc_artist;
return disc_disc_artist[src];
}
void RDDiscRecord::setDiscArtist(QString artist)
void RDDiscRecord::setDiscArtist(RDDiscRecord::DataSource src,
const QString &artist)
{
disc_disc_artist=artist;
disc_has_data[src]=true;
disc_disc_artist[src]=artist.trimmed();
}
QString RDDiscRecord::discAlbum() const
QString RDDiscRecord::discAlbum(RDDiscRecord::DataSource src) const
{
return disc_disc_album;
return disc_disc_album[src];
}
void RDDiscRecord::setDiscAlbum(QString album)
void RDDiscRecord::setDiscAlbum(RDDiscRecord::DataSource src,
const QString &album)
{
disc_disc_album=album;
disc_has_data[src]=true;
disc_disc_album[src]=album.trimmed();
}
@@ -203,7 +227,7 @@ QString RDDiscRecord::discAuthor() const
void RDDiscRecord::setDiscAuthor(QString author)
{
disc_disc_author=author;
disc_disc_author=author.trimmed();
}
@@ -227,7 +251,7 @@ QString RDDiscRecord::discGenre() const
void RDDiscRecord::setDiscGenre(QString genre)
{
disc_disc_genre=genre;
disc_disc_genre=genre.trimmed();
}
@@ -239,7 +263,7 @@ QString RDDiscRecord::discLabel() const
void RDDiscRecord::setDiscLabel(const QString &str)
{
disc_disc_label=str;
disc_disc_label=str.trimmed();
}
@@ -263,7 +287,7 @@ QString RDDiscRecord::discPlayOrder() const
void RDDiscRecord::setDiscPlayOrder(QString order)
{
disc_disc_playorder=order;
disc_disc_playorder=order.trimmed();
}
@@ -284,19 +308,21 @@ void RDDiscRecord::setTrackOffset(int track,unsigned frames)
}
QString RDDiscRecord::trackTitle(int track) const
QString RDDiscRecord::trackTitle(RDDiscRecord::DataSource src,int track) const
{
if(track<CDROM_LEADOUT) {
return disc_track_title[track];
return disc_track_title[src][track];
}
return QString();
}
void RDDiscRecord::setTrackTitle(int track,QString title)
void RDDiscRecord::setTrackTitle(RDDiscRecord::DataSource src,int track,
const QString &title)
{
if(track<CDROM_LEADOUT) {
disc_track_title[track]=title;
disc_has_data[src]=true;
disc_track_title[src][track]=title.trimmed();
}
}
@@ -313,24 +339,26 @@ QString RDDiscRecord::trackExtended(int track) const
void RDDiscRecord::setTrackExtended(int track,QString text)
{
if(track<CDROM_LEADOUT) {
disc_track_extended[track]=text;
disc_track_extended[track]=text.trimmed();
}
}
QString RDDiscRecord::trackArtist(int track) const
QString RDDiscRecord::trackArtist(RDDiscRecord::DataSource src,int track) const
{
if(track<CDROM_LEADOUT) {
return disc_track_artist[track];
return disc_track_artist[src][track];
}
return QString();
}
void RDDiscRecord::setTrackArtist(int track,QString artist)
void RDDiscRecord::setTrackArtist(RDDiscRecord::DataSource src,int track,
const QString &artist)
{
if(track<CDROM_LEADOUT) {
disc_track_artist[track]=artist;
disc_has_data[src]=true;
disc_track_artist[src][track]=artist.trimmed();
}
}
@@ -355,17 +383,39 @@ QString RDDiscRecord::isrc(int track) const
}
void RDDiscRecord::setIsrc(int track,QString isrc)
void RDDiscRecord::setIsrc(int track,const QString &isrc)
{
if(track<CDROM_LEADOUT) {
disc_track_isrc[track]=isrc;
disc_track_isrc[track]=isrc.trimmed();
}
}
QString RDDiscRecord::dump()
QString RDDiscRecord::summary(RDDiscRecord::DataSource src) const
{
QString ret="RDDiscRecord::dump()\n";
QString ret;
if(!discTitle(src).isEmpty()) {
ret+="<strong>"+QObject::tr("Disc Title")+"</strong>: "+
discTitle(src)+"<br>\n";
}
if(!discArtist(src).isEmpty()) {
ret+="<strong>"+QObject::tr("Disc Artist")+"</strong>: "+
discArtist(src)+"<br>\n";
}
for(int i=0;i<tracks();i++) {
ret+="<strong>"+QObject::tr("Track")+QString().sprintf(" %2d: ",i+1)+
"</strong>"+trackTitle(src,i)+"<br>\n";
}
return ret;
}
QString RDDiscRecord::dump(RDDiscRecord::DataSource src) const
{
QString ret=QString().sprintf("RDDiscRecord::dump(%u)\n",src);
ret+=QString::asprintf("tracks: %d\n",tracks());
ret+=QString::asprintf("discLength: %d\n",discLength());
@@ -373,9 +423,9 @@ QString RDDiscRecord::dump()
ret+="mcn: "+mcn()+"\n";
ret+="discMbId: "+discMbId()+"\n";
ret+="mbSubmissionUrl: "+mbSubmissionUrl()+"\n";
ret+="discTitle: "+discTitle()+"\n";
ret+="discArtist: "+discArtist()+"\n";
ret+="discAlbum: "+discAlbum()+"\n";
ret+="discTitle: "+discTitle(src)+"\n";
ret+="discArtist: "+discArtist(src)+"\n";
ret+="discAlbum: "+discAlbum(src)+"\n";
ret+="discAuthor: "+discAuthor()+"\n";
ret+=QString::asprintf("discYear: %u\n",discYear());
ret+="discGenre: "+discGenre()+"\n";
@@ -385,7 +435,7 @@ QString RDDiscRecord::dump()
for(int i=0;i<tracks();i++) {
QString num=QString::asprintf("(%d): ",i+1);
ret+="trackOffset"+num+QString::asprintf("%u",trackOffset(i))+"\n";
ret+="trackTitle"+num+trackTitle(i)+"\n";
ret+="trackTitle"+num+trackTitle(src,i)+"\n";
ret+="trackExtended"+num+trackExtended(i)+"\n";
ret+="trackRecordingMbId"+num+trackRecordingMbId(i)+"\n";
ret+="isrc"+num+isrc(i)+"\n";

View File

@@ -2,7 +2,7 @@
//
// Container Class for Compact Disc Metadata
//
// (C) Copyright 2003-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -25,22 +25,15 @@
#include <qstring.h>
#include <linux/cdrom.h>
/**
* @short A container class for CDDB data.
* @author Fred Gleason <fredg@paravelsystems.com>
**/
class RDDiscRecord
{
public:
/**
* Create an RDDiscRecord object
**/
public:
enum DataSource {LocalSource=0,RemoteSource=1,LastSource=2};
RDDiscRecord();
void clear();
int tracks() const;
void setTracks(int num);
bool hasData(RDDiscRecord::DataSource src) const;
unsigned discLength() const;
void setDiscLength(unsigned len);
unsigned discId() const;
@@ -53,12 +46,12 @@ class RDDiscRecord
void setDiscReleaseMbId(const QString &mbid);
QString mbSubmissionUrl() const;
void setMbSubmissionUrl(const QString &url);
QString discTitle() const;
void setDiscTitle(QString title);
QString discArtist() const;
void setDiscArtist(QString artist);
QString discAlbum() const;
void setDiscAlbum(QString album);
QString discTitle(DataSource src) const;
void setDiscTitle(DataSource src,const QString &title);
QString discArtist(DataSource src) const;
void setDiscArtist(DataSource src,const QString &artist);
QString discAlbum(DataSource src) const;
void setDiscAlbum(DataSource src, const QString &album);
QString discAuthor() const;
void setDiscAuthor(QString author);
unsigned discYear() const;
@@ -73,18 +66,19 @@ class RDDiscRecord
void setDiscPlayOrder(QString order);
unsigned trackOffset(int track) const;
void setTrackOffset(int track,unsigned frames);
QString trackTitle(int track) const;
void setTrackTitle(int track,QString title);
QString trackTitle(DataSource src,int track) const;
void setTrackTitle(DataSource src,int track,const QString &title);
QString trackExtended(int track) const;
void setTrackExtended(int track,QString text);
QString trackArtist(int track) const;
void setTrackArtist(int track,QString artist);
QString trackArtist(DataSource src,int track) const;
void setTrackArtist(DataSource src,int track,const QString &artist);
QString trackRecordingMbId(int track) const;
void setTrackRecordingMbId(int track,const QString &str);
bool hasIsrcs() const;
QString isrc(int track) const;
void setIsrc(int track,QString isrc);
QString dump();
void setIsrc(int track,const QString &isrc);
QString summary(RDDiscRecord::DataSource src) const;
QString dump(RDDiscRecord::DataSource src) const;
private:
int disc_tracks;
@@ -94,21 +88,22 @@ class RDDiscRecord
QString disc_disc_release_mb_id;
QString disc_mb_submission_url;
unsigned disc_disc_length;
QString disc_disc_title;
QString disc_disc_artist;
QString disc_disc_album;
QString disc_disc_title[RDDiscRecord::LastSource];
QString disc_disc_artist[RDDiscRecord::LastSource];
QString disc_disc_album[RDDiscRecord::LastSource];
QString disc_disc_author;
unsigned disc_disc_year;
QString disc_disc_genre;
QString disc_disc_label;
QString disc_disc_extended;
QString disc_disc_playorder;
QString disc_track_title[CDROM_LEADOUT];
QString disc_track_title[RDDiscRecord::LastSource][CDROM_LEADOUT];
QString disc_track_extended[CDROM_LEADOUT];
QString disc_track_artist[CDROM_LEADOUT];
QString disc_track_artist[RDDiscRecord::LastSource][CDROM_LEADOUT];
QString disc_track_isrc[CDROM_LEADOUT];
unsigned disc_track_offset[CDROM_LEADOUT];
QString disc_track_recording_mb_id[CDROM_LEADOUT];
bool disc_has_data[RDDiscRecord::LastSource];
};

View File

@@ -2,7 +2,7 @@
//
// RDDiscLookup instance class for dummy lookup
//
// (C) Copyright 2003-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -30,5 +30,5 @@ RDDummyLookup::RDDummyLookup(const QString &caption,FILE *profile_msgs,
void RDDummyLookup::lookupRecord()
{
emit lookupDone(RDDiscLookup::NoMatch,"OK");
processLookup(RDDiscLookup::NoMatch,"OK");
}

View File

@@ -2,7 +2,7 @@
//
// RDDiscLookup instance class for dummy lookup
//
// (C) Copyright 2003-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License

View File

@@ -279,7 +279,7 @@ void RDFontEngine::MakeFonts(const QFont &default_font)
font_big_label_font=QFont(family,label_size+4,QFont::Bold);
font_big_label_font.setPixelSize(label_size+4);
font_big_label_font_metrics=new QFontMetrics(font_label_font);
font_big_label_font_metrics=new QFontMetrics(font_big_label_font);
font_label_font=QFont(family,label_size,QFont::Bold);
font_label_font.setPixelSize(label_size);

View File

@@ -2,7 +2,7 @@
//
// Abstract an RDLibrary Configuration.
//
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -18,14 +18,20 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <QPixmap>
#include "rdconf.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlibrary_conf.h"
//
// Global Classes
// Logos
//
#include "../icons/cd-text-55x47.xpm"
#include "../icons/cddb-60x25.xpm"
#include "../icons/musicbrainz-159x25.xpm"
RDLibraryConf::RDLibraryConf(const QString &station)
{
RDSqlQuery *q;
@@ -414,7 +420,7 @@ QString RDLibraryConf::cdServerTypeText(RDLibraryConf::CdServerType type)
break;
case RDLibraryConf::CddbType:
ret="FreeDB";
ret="CDDB";
break;
case RDLibraryConf::MusicBrainzType:
@@ -428,6 +434,30 @@ QString RDLibraryConf::cdServerTypeText(RDLibraryConf::CdServerType type)
}
QPixmap RDLibraryConf::cdServerLogo(CdServerType type)
{
QPixmap ret;
switch(type) {
case RDLibraryConf::DummyType:
ret=QPixmap(cd_text_55x47_xpm);
break;
case RDLibraryConf::CddbType:
ret=QPixmap(cddb_60x25_xpm);
break;
case RDLibraryConf::MusicBrainzType:
ret=QPixmap(musicbrainz_159x25_xpm);
break;
case RDLibraryConf::LastType:
break;
}
return ret;
}
void RDLibraryConf::SetRow(const QString &param,int value) const
{
RDSqlQuery *q;

View File

@@ -2,7 +2,7 @@
//
// Abstract RDLibrary Configuration
//
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -84,6 +84,7 @@ class RDLibraryConf
bool searchLimited() const;
void setSearchLimited(bool state) const;
static QString cdServerTypeText(CdServerType type);
static QPixmap cdServerLogo(CdServerType type);
private:
void SetRow(const QString &param,int value) const;
@@ -95,4 +96,4 @@ class RDLibraryConf
};
#endif
#endif // RDLIBRARY_CONF_H

View File

@@ -2,7 +2,7 @@
//
// RDDiscLookup instance class for MusicBrainz
//
// (C) Copyright 2003-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2003-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@@ -53,7 +53,6 @@
#include "rdconf.h"
#include "rdmblookup.h"
#include "../icons/musicbrainz-159x25.xpm"
#include "../icons/cover_art_default-60x60.xpm"
QString err_str="OK";
@@ -118,7 +117,7 @@ QString RDMbLookup::sourceName() const
QPixmap RDMbLookup::sourceLogo() const
{
return QPixmap(musicbrainz_159x25_xpm);
return RDLibraryConf::cdServerLogo(RDLibraryConf::MusicBrainzType);
}
@@ -246,7 +245,7 @@ void RDMbLookup::lookupRecord()
result_code=RDDiscLookup::NoMatch;
}
QApplication::restoreOverrideCursor();
emit lookupDone(result_code,err_str);
processLookup(result_code,err_str);
}
@@ -260,7 +259,8 @@ RDDiscLookup::Result RDMbLookup::ProcessRelease(MusicBrainz5::CRelease *release)
// Extract Basic Release Data
//
discRecord()->setDiscReleaseMbId(QString::fromUtf8(release->ID().c_str()));
discRecord()->setDiscAlbum(QString::fromUtf8(release->Title().c_str()));
discRecord()->setDiscAlbum(RDDiscRecord::RemoteSource,
QString::fromUtf8(release->Title().c_str()));
//discRecord()->setDiscGenre();
QStringList f0=QString::fromUtf8(release->Date().c_str()).split("-");
discRecord()->setDiscYear(f0.at(0).toInt());
@@ -284,7 +284,7 @@ RDDiscLookup::Result RDMbLookup::ProcessRelease(MusicBrainz5::CRelease *release)
QString::fromUtf8(credits->Item(j)->Artist()->Name().c_str());
str+=QString::fromUtf8(credits->Item(j)->JoinPhrase().c_str());
}
discRecord()->setDiscArtist(str);
discRecord()->setDiscArtist(RDDiscRecord::RemoteSource,str);
}
//
@@ -307,7 +307,8 @@ RDDiscLookup::Result RDMbLookup::ProcessRelease(MusicBrainz5::CRelease *release)
MusicBrainz5::CTrack *track=tracks->Item(k);
MusicBrainz5::CRecording *recording=track->Recording();
discRecord()->
setTrackTitle(k,QString::fromUtf8(recording->Title().c_str()));
setTrackTitle(RDDiscRecord::RemoteSource,k,
QString::fromUtf8(recording->Title().c_str()));
discRecord()->
setTrackRecordingMbId(k,QString::fromUtf8(recording->ID().c_str()));
MusicBrainz5::CISRCList *isrcs=recording->ISRCList();