2020-02-02 Fred Gleason <fredg@paravelsystems.com>

* Added support for saving Label data from MusicBrainz releases.
This commit is contained in:
Fred Gleason 2020-02-01 19:42:39 -05:00
parent 8dfd341cdf
commit e5b72e0cd4
17 changed files with 156 additions and 28 deletions

View File

@ -19473,3 +19473,5 @@
in rdlibrary(1).
* Added a MusicBrainz record lookup button to the disc track ripper
in rdlibrary(1).
2020-02-02 Fred Gleason <fredg@paravelsystems.com>
* Added support for saving Label data from MusicBrainz releases.

View File

@ -59,7 +59,7 @@ RDDiscLookup::RDDiscLookup(const QString &caption,FILE *profile_msgs,
QSize RDDiscLookup::sizeHint() const
{
return QSize(400,120);
return QSize(400,140);
}
@ -164,7 +164,7 @@ void RDDiscLookup::resizeEvent(QResizeEvent *e)
lookup_titles_label->setGeometry(15,2,w-30,20);
lookup_titles_box->setGeometry(10,24,w-20,20);
lookup_titles_box->setGeometry(10,24,w-20,40);
lookup_ok_button->setGeometry(w-180,h-60,80,50);
lookup_cancel_button->setGeometry(w-90,h-60,80,50);
@ -289,3 +289,65 @@ QString RDDiscLookup::normalizedIsrc(const QString &isrc,bool *ok)
}
return QString();
}
bool RDDiscLookup::upcAIsValid(const QString &barcode)
{
//
// For formatting rules for UPC-A barcodes, see
// https://en.wikipedia.org/wiki/Universal_Product_Code
//
QString str=barcode;
str.replace("-","");
str.replace(" ","");
if(str.length()!=12) {
return false;
}
for(int i=0;i<12;i++) {
if(str.at(i).category()!=QChar::Number_DecimalDigit) {
return false;
}
}
return true;
}
QString RDDiscLookup::formattedUpcA(const QString &barcode,bool *ok)
{
if(RDDiscLookup::upcAIsValid(barcode)) {
if(ok!=NULL) {
*ok=true;
}
QString str=barcode;
str.insert(1," ");
str.insert(6,"-");
str.insert(12,"-");
str.insert(14," ");
return str;
}
if(ok!=NULL) {
*ok=false;
}
return QString();
}
QString RDDiscLookup::normalizedUpcA(const QString &barcode,bool *ok)
{
if(RDDiscLookup::upcAIsValid(barcode)) {
if(ok!=NULL) {
*ok=true;
}
QString str=barcode;
str.replace("-","");
str.replace(" ","");
return str;
}
if(ok!=NULL) {
*ok=false;
}
return QString();
}

View File

@ -49,6 +49,9 @@ class RDDiscLookup : public RDDialog
static bool isrcIsValid(const QString &isrc);
static QString formattedIsrc(const QString &isrc,bool *ok=NULL);
static QString normalizedIsrc(const QString &isrc,bool *ok=NULL);
static bool upcAIsValid(const QString &barcode);
static QString formattedUpcA(const QString &barcode,bool *ok=NULL);
static QString normalizedUpcA(const QString &barcode,bool *ok=NULL);
signals:
void lookupDone(RDDiscLookup::Result,const QString &err_msg);

View File

@ -95,9 +95,23 @@ void RDMbLookup::lookupRecord()
titlesBox()->clear();
for(int i=0;i<releases->NumItems();i++) {
MusicBrainz5::CRelease *release=releases->Item(i);
QString barcode=RDDiscLookup::
formattedUpcA(QString::fromUtf8(release->Barcode().c_str()));
MusicBrainz5::CMediumList *media=release->MediumList();
QString format="";
for(int j=0;j<media->NumItems();j++) {
format=QString::fromUtf8(media->Item(j)->Format().c_str())+" | ";
}
format=format.left(format.length()-3);
QString title=QString::fromUtf8(release->Title().c_str())+"\n";
if(!format.isEmpty()) {
title+=" ["+format+"]";
}
if(!barcode.isEmpty()) {
title+=" [UPC "+barcode+"]";
}
titlesKey()->push_back(QString::fromUtf8(release->Title().c_str()));
titlesBox()->insertItem(titlesBox()->count(),
QString::fromUtf8(release->Title().c_str()));
titlesBox()->insertItem(titlesBox()->count(),title);
}
if((index=exec())>=0) {
result_code=ProcessRelease(releases->Item(index));

View File

@ -546,6 +546,7 @@ void AudioCart::ripCutData()
QString title;
QString artist;
QString album;
QString label;
RDListViewItem *item=NULL;
std::vector<QString> cutnames;
@ -555,7 +556,7 @@ void AudioCart::ripCutData()
cutname=item->text(12);
RDDiscRecord *rec=new RDDiscRecord();
CdRipper *ripper=new CdRipper(cutname,rec,rda->libraryConf(),rdcart_profile_rip);
if((track=ripper->exec(&title,&artist,&album))>=0) {
if((track=ripper->exec(&title,&artist,&album,&label))>=0) {
if((rdcart_controls->title_edit->text().isEmpty()||
(rdcart_controls->title_edit->text()==tr("[new cart]")))&&
(!title.isEmpty())) {
@ -563,6 +564,7 @@ void AudioCart::ripCutData()
}
rdcart_controls->artist_edit->setText(artist);
rdcart_controls->album_edit->setText(album);
rdcart_controls->label_edit->setText(label);
RDCut *cut=new RDCut(cutname);
cut->setIsrc(rec->isrc(track));
cut->setTrackMbId(rec->trackMbId(track));

View File

@ -114,6 +114,14 @@ CdRipper::CdRipper(QString cutname,RDDiscRecord *rec,RDLibraryConf *conf,
rip_album_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
rip_album_edit=new QLineEdit(this);
//
// Label Edit
//
rip_label_label=new QLabel(tr("Label:"),this);
rip_label_label->setFont(labelFont());
rip_label_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
rip_label_edit=new QLineEdit(this);
//
// Other Edit
//
@ -295,7 +303,7 @@ CdRipper::~CdRipper()
QSize CdRipper::sizeHint() const
{
return QSize(730,606);
return QSize(730,628);
}
@ -305,11 +313,12 @@ QSizePolicy CdRipper::sizePolicy() const
}
int CdRipper::exec(QString *title,QString *artist,QString *album)
int CdRipper::exec(QString *title,QString *artist,QString *album,QString *label)
{
rip_title=title;
rip_artist=artist;
rip_album=album;
rip_label=label;
return QDialog::exec();
}
@ -422,6 +431,7 @@ void CdRipper::ripTrackButtonData()
*rip_title=rip_title_box->currentText();
*rip_artist=rip_artist_edit->text();
*rip_album=rip_album_edit->text();
*rip_label=rip_label_edit->text();
}
//
@ -587,6 +597,7 @@ void CdRipper::lookupDoneData(RDDiscLookup::Result result,const QString &err_msg
}
rip_artist_edit->setText(rip_disc_record->discArtist());
rip_album_edit->setText(rip_disc_record->discAlbum());
rip_label_edit->setText(rip_disc_record->discLabel());
rip_other_edit->setText(rip_disc_record->discExtended());
for(int i=0;i<rip_disc_record->tracks();i++) {
rip_track_list->findItem(QString().sprintf("%d",i+1),0)->
@ -657,28 +668,30 @@ void CdRipper::resizeEvent(QResizeEvent *e)
rip_artist_edit->setGeometry(65,31,size().width()-125,18);
rip_album_label->setGeometry(10,54,50,18);
rip_album_edit->setGeometry(65,53,size().width()-125,18);
rip_other_label->setGeometry(10,76,50,16);
rip_other_edit->setGeometry(65,75,size().width()-125,60);
rip_apply_box->setGeometry(65,140,15,15);
rip_apply_label->setGeometry(85,140,250,20);
rip_browser_button->setGeometry(size().width()-260,139,200,35);
rip_track_list->setGeometry(10,178,size().width()-110,size().height()-290);
rip_track_label->setGeometry(10,162,100,14);
rip_label_label->setGeometry(10,76,50,18);
rip_label_edit->setGeometry(65,75,size().width()-125,18);
rip_other_label->setGeometry(10,98,50,16);
rip_other_edit->setGeometry(65,97,size().width()-125,60);
rip_apply_box->setGeometry(65,162,15,15);
rip_apply_label->setGeometry(85,162,250,20);
rip_browser_button->setGeometry(size().width()-260,161,200,35);
rip_track_list->setGeometry(10,200,size().width()-110,size().height()-290);
rip_track_label->setGeometry(10,184,100,14);
rip_bar->setGeometry(10,size().height()-100,size().width()-112,20);
rip_eject_button->setGeometry(size().width()-90,178,80,50);
rip_play_button->setGeometry(size().width()-90,238,80,50);
rip_stop_button->setGeometry(size().width()-90,298,80,50);
rip_rip_button->setGeometry(size().width()-90,402,80,50);
rip_eject_button->setGeometry(size().width()-90,200,80,50);
rip_play_button->setGeometry(size().width()-90,260,80,50);
rip_stop_button->setGeometry(size().width()-90,320,80,50);
rip_rip_button->setGeometry(size().width()-90,424,80,50);
rip_normalize_box->setGeometry(10,size().height()-76,20,20);
rip_normalize_box_label->setGeometry(30,size().height()-76,85,20);
rip_normalize_spin->setGeometry(170,size().height()-76,40,20);
rip_normalize_label->setGeometry(120,size().height()-76,45,20);
rip_normalize_unit->setGeometry(215,size().height()-76,40,20);
rip_autotrim_box->setGeometry(10,size().height()-52,20,20);
rip_normalize_spin->setGeometry(170,size().height()-76,50,20);
rip_normalize_unit->setGeometry(225,size().height()-76,40,20);
rip_autotrim_box_label->setGeometry(30,size().height()-52,85,20);
rip_autotrim_spin->setGeometry(170,size().height()-52,40,20);
rip_autotrim_box->setGeometry(10,size().height()-52,20,20);
rip_autotrim_label->setGeometry(120,size().height()-52,45,20);
rip_autotrim_unit->setGeometry(215,size().height()-52,40,20);
rip_autotrim_spin->setGeometry(170,size().height()-52,50,20);
rip_autotrim_unit->setGeometry(225,size().height()-52,40,20);
rip_channels_box->setGeometry(90,size().height()-28,50,20);
rip_channels_label->setGeometry(10,size().height()-28,75,20);
rip_close_button->setGeometry(size().width()-90,size().height()-60,80,50);

View File

@ -46,7 +46,7 @@ class CdRipper : public RDDialog
QSizePolicy sizePolicy() const;
public slots:
int exec(QString *title,QString *artist,QString *album);
int exec(QString *title,QString *artist,QString *album,QString *label);
private slots:
void trackSelectionChangedData();
@ -83,10 +83,13 @@ class CdRipper : public RDDialog
QString *rip_title;
QString *rip_artist;
QString *rip_album;
QString *rip_label;
QLabel *rip_title_label;
QComboBox *rip_title_box;
QLabel *rip_album_label;
QLineEdit *rip_album_edit;
QLabel *rip_label_label;
QLineEdit *rip_label_edit;
QLabel *rip_artist_label;
QLineEdit *rip_artist_edit;
QLabel *rip_other_label;

View File

@ -812,6 +812,7 @@ void DiskRipper::lookupDoneData(RDDiscLookup::Result result,
rip_wave_datas[i]->setTitle(rip_disc_record.trackTitle(i));
rip_wave_datas[i]->setArtist(rip_disc_record.discArtist());
rip_wave_datas[i]->setAlbum(rip_disc_record.discAlbum());
rip_wave_datas[i]->setLabel(rip_disc_record.discLabel());
}
rip_apply_box->setChecked(true);
rip_apply_box->setEnabled(true);
@ -940,14 +941,14 @@ void DiskRipper::resizeEvent(QResizeEvent *e)
rip_clear_button->setGeometry(size().width()-90,480,80,50);
rip_normalizebox_label->setGeometry(30,size().height()-78,85,20);
rip_normalize_box->setGeometry(10,size().height()-78,20,20);
rip_normalize_spin->setGeometry(170,size().height()-79,40,20);
rip_normalize_label->setGeometry(120,size().height()-78,45,20);
rip_normalize_unit->setGeometry(215,size().height()-78,40,20);
rip_normalize_spin->setGeometry(170,size().height()-79,50,20);
rip_normalize_unit->setGeometry(225,size().height()-78,40,20);
rip_autotrimbox_label->setGeometry(30,size().height()-54,85,20);
rip_autotrim_box->setGeometry(10,size().height()-54,20,20);
rip_autotrim_spin->setGeometry(170,size().height()-54,40,20);
rip_autotrim_label->setGeometry(120,size().height()-54,45,20);
rip_autotrim_unit->setGeometry(215,size().height()-54,40,20);
rip_autotrim_spin->setGeometry(170,size().height()-54,50,20);
rip_autotrim_unit->setGeometry(225,size().height()-54,40,20);
rip_channels_label->setGeometry(10,size().height()-30,75,20);
rip_channels_box->setGeometry(90,size().height()-30,50,20);
rip_rip_button->setGeometry(size().width()-200,size().height()-60,80,50);

View File

@ -472,6 +472,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File

@ -472,6 +472,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File

@ -472,6 +472,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File

@ -360,6 +360,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File

@ -462,6 +462,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File

@ -462,6 +462,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File

@ -463,6 +463,10 @@ Track</source>
<source>Lookup Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskGauge</name>

View File