[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#677252: would you accept a backported patch for musicbrainz5 in kdemultimedia, for wheezy?Hi Jon!



Hi,

Alle domenica 24 giugno 2012, Jon Dowland ha scritto:
> On Tue, Jun 19, 2012 at 08:47:19PM -0300, Lisandro Damián Nicanor 
Pérez Meyer wrote:
> > kdemultimedia creates lots of binaries [0]. Do you know exactly
> > which of them use the old mb?
> 
> Yes, it's libkcddb4 and kscd.
> 
> > Please **note** that I'm mostly speaking **for myself**: *if* the
> > patches are accepted upstream and we manage to get them before the
> > freeze (we uploaded kdemultimedia a few days ago, so we will wait
> > for it to enter unstable), I don't think there will be much
> > problem in applying them.
> 
> I don't think upstream are likely to accept these patches. My
> understanding is that the version we're talking about is considered
> stable by upstream and so they won't accept further changes.  Their
> focus is on the next release (which has moved away from the
> monolithic packaging). However I am not very familiar with KDE
> upstream, and perhaps they would consider the patches after all. The
> turn-around to get them accepted upstream would rule this out for
> wheezy, though.

This is correct, usually KDE stable series are feature- and string- 
frozen, and that includes also dependencies.
However, at this point a KDE 4.8.5 is not that likely (although it has 
not been totally ruled out yet), so a backport would not be much 
helpful.

> The patches themselves, when I write them, are backports from the git
> repositories for kcddb and kscd.

libkcddb has been converted already to MB5 for the future KDE 4.9; 
attached there is a preliminary backport I did (warning: it is not 
tested, not even to compile!) wrt kdemultimedia 4.8.x.
However, kscd has not been ported upstream yet.

> There are presently three packages relying on mb3 still:
> [...]
> There's a slim chance we can get the migration to musicbrainz5 done
> in time for wheezy.

One important question is: if libkcddb and kscd in Wheezy still use MB3, 
except the issues mentioned earlier about multi-discs, which kind of 
issues would they have? Would they still be able to search/fetch/uploadd 
disc info in, say, the next couple of years?
(Since I'm no MB-literate, I'm asking to know more about the current 
situation, and to eventually decide whether me or the team should invest 
in this.)

Thanks,
-- 
Pino Toscano
Author: Richard Lärkäng <larkang@gmail.com>
Author: Pino Toscano <pino@kde.org> <pino@debian.org>
Description: Port libkcddb to MusicBrainz5
 Apply the serie of upstream commits that port libkcddb to MusicBrainz5
 (passing through MusicBrainz4), which are part of KDE 4.9.
 It includes also a bugfix for year reading (KDE bug #300091).
 .
 The patch has been slightly modified to not change the libkcddb version,
 and to not enable Musicbrainz lookup by default (keeping the behaviour
 of kdemultimedia 4.8.x).
Applied-Upstream: commit:57902715f4592ef44da39835ace42242f96e0a3a
Applied-Upstream: commit:4c71ec9c617b4d442a42a7b2c00004c57eb333c1
Applied-Upstream: commit:fa6acd9986779659e9aac8c2cf85e735e7632f85
Applied-Upstream: commit:79b80e1ec090beedf9061cae75a04c39ae5309eb
Applied-Upstream: commit:35880a3bca3c8bf88b07b143d20b5b51ce339a21
Applied-Upstream: commit:95ab6c638ea90e3241bd1950b937c52c34cd7c99
Applied-Upstream: commit:a2d2a670fb5ac1a733f35b3358d00b8981a4a459
Last-Update: 2012-06-28

--- a/libkcddb/CMakeLists.txt
+++ b/libkcddb/CMakeLists.txt
@@ -3,19 +3,22 @@ project(libkcddb)
 add_subdirectory( test )
 add_subdirectory( kcmcddb )
 
-if(MUSICBRAINZ3_FOUND)
-    set(HAVE_MUSICBRAINZ3 1)
-    include_directories(${MUSICBRAINZ3_INCLUDE_DIR})
+macro_optional_find_package(MusicBrainz5)
+macro_log_feature(MUSICBRAINZ5_FOUND "MusicBrainz5" "A library that provides access to metadata lookup on the MusicBrainz server" "http://www.musicbrainz.org"; FALSE "" "Music metadata lookup for KDE multimedia applications through libkcddb. You need version 5.x of libmusicbrainz")
+
+if(MUSICBRAINZ5_FOUND)
+    set(HAVE_MUSICBRAINZ5 1)
+    include_directories(${MUSICBRAINZ5_INCLUDE_DIR})
 
     set(libmusicbrainz_SRCS ${libmusicbrainz_SRCS}
        musicbrainz/musicbrainzlookup.cpp
        musicbrainz/asyncmusicbrainzlookup.cpp)
 
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
-else(MUSICBRAINZ3_FOUND)
-    set(HAVE_MUSICBRAINZ3 0)
+else(MUSICBRAINZ5_FOUND)
+    set(HAVE_MUSICBRAINZ5 0)
     set(libmusicbrainz_SRCS)
-endif(MUSICBRAINZ3_FOUND)
+endif(MUSICBRAINZ5_FOUND)
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-musicbrainz.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-musicbrainz.h )
 
@@ -58,9 +61,9 @@ kde4_add_kcfg_files(kcddb_LIB_SRCS confi
 kde4_add_library(kcddb SHARED ${kcddb_LIB_SRCS})
 
 target_link_libraries(kcddb ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
-if(MUSICBRAINZ3_FOUND)
-    target_link_libraries(kcddb ${MUSICBRAINZ3_LIBRARIES})
-endif(MUSICBRAINZ3_FOUND)
+if(MUSICBRAINZ5_FOUND)
+    target_link_libraries(kcddb ${MUSICBRAINZ5_LIBRARIES})
+endif(MUSICBRAINZ5_FOUND)
 
 set_target_properties(kcddb PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
 install(TARGETS kcddb  ${INSTALL_TARGETS_DEFAULT_ARGS} )
--- a/libkcddb/cache.cpp
+++ b/libkcddb/cache.cpp
@@ -26,7 +26,7 @@
 #include "cddb.h"
 
 #include "config-musicbrainz.h"
-#ifdef HAVE_MUSICBRAINZ3
+#ifdef HAVE_MUSICBRAINZ5
 #include "musicbrainz/musicbrainzlookup.h"
 #endif
 
@@ -49,7 +49,7 @@ namespace KCDDB
     CDInfoList infoList;
 
     infoList << CDDB::cacheFiles(offsetList, c);
-#ifdef HAVE_MUSICBRAINZ3
+#ifdef HAVE_MUSICBRAINZ5
     infoList << MusicBrainzLookup::cacheFiles(offsetList, c);
 #endif
 
--- a/libkcddb/cdinfo.cpp
+++ b/libkcddb/cdinfo.cpp
@@ -443,13 +443,30 @@ namespace KCDDB
     else
       s += d->createLine(QLatin1String( "DGENRE" ),get(Genre).toString());
 
+    bool isSampler = false;
+    for (int i = 0; i < d->trackInfoList.count(); ++i){
+      QString trackArtist = d->trackInfoList[i].get(Artist).toString();
+      if (!trackArtist.isEmpty() && trackArtist != artist)
+      {
+        isSampler = true;
+        break;
+      }
+    }
+
     for (int i = 0; i < d->trackInfoList.count(); ++i){
       QString trackTitle = d->trackInfoList[i].get(Title).toString();
       QString trackArtist = d->trackInfoList[i].get(Artist).toString();
-      if(trackArtist != artist && !trackArtist.isEmpty())
+      if (isSampler)
+      {
+        if (trackArtist.isEmpty())
+          s += d->createLine(QString::fromLatin1("TTITLE%1").arg(i), QString::fromLatin1("%1 / %2").arg(artist).arg(trackTitle));
+        else
           s += d->createLine(QString::fromLatin1("TTITLE%1").arg(i), QString::fromLatin1("%1 / %2").arg(trackArtist).arg(trackTitle));
+      }
       else
+      {
           s += d->createLine(QString::fromLatin1("TTITLE%1").arg(i), trackTitle);
+      }
     }
 
     s += d->createLine(QLatin1String("EXTD"), get(Comment).toString());
--- a/libkcddb/client.cpp
+++ b/libkcddb/client.cpp
@@ -33,7 +33,7 @@
 #include "lookup.h"
 
 #include "config-musicbrainz.h"
-#ifdef HAVE_MUSICBRAINZ3
+#ifdef HAVE_MUSICBRAINZ5
 #include "musicbrainz/musicbrainzlookup.h"
 #include "musicbrainz/asyncmusicbrainzlookup.h"
 #endif
@@ -138,7 +138,7 @@ namespace KCDDB
 
     if ( blockingMode() )
     {
-#ifdef HAVE_MUSICBRAINZ3
+#ifdef HAVE_MUSICBRAINZ5
       if ( d->config.musicBrainzLookupEnabled() )
       {
         d->cdInfoLookup = new MusicBrainzLookup();
@@ -186,7 +186,7 @@ namespace KCDDB
     }
     else
     {
-#ifdef HAVE_MUSICBRAINZ3
+#ifdef HAVE_MUSICBRAINZ5
       if ( d->config.musicBrainzLookupEnabled() )
       {
         AsyncMusicBrainzLookup* lookup = new AsyncMusicBrainzLookup();
--- a/libkcddb/config-musicbrainz.h.cmake
+++ b/libkcddb/config-musicbrainz.h.cmake
@@ -1,2 +1,2 @@
 /* have MusicBrainz */
-#cmakedefine HAVE_MUSICBRAINZ3 1
+#cmakedefine HAVE_MUSICBRAINZ5 1
--- a/libkcddb/httpsubmit.cpp
+++ b/libkcddb/httpsubmit.cpp
@@ -51,8 +51,8 @@ namespace KCDDB
     header += QLatin1String( "Category: " ) + cdInfo.get(Category).toString() + QLatin1Char( '\n' );
     header += QLatin1String( "Discid: " ) + cdInfo.get(QLatin1String( "discid" )).toString() + QLatin1Char( '\n' );
     header += QLatin1String( "User-Email: " ) + from_ + QLatin1Char( '\n' );
-    // Change to sumbit
-    header += QLatin1String( "Submit-Mode: test\n" );
+    //header += QLatin1String( "Submit-Mode: test\n" );
+    header += QLatin1String( "Submit-Mode: submit\n" );
     header += QLatin1String( "Charset: UTF-8" );
 
     job->addMetaData(QLatin1String( "customHTTPHeader" ), header);
--- a/libkcddb/kcmcddb/cddbconfigwidget.cpp
+++ b/libkcddb/kcmcddb/cddbconfigwidget.cpp
@@ -46,7 +46,7 @@ CDDBConfigWidget::CDDBConfigWidget(QWidg
 {
   setupUi(this);
 
-#ifndef HAVE_MUSICBRAINZ3
+#ifndef HAVE_MUSICBRAINZ5
   kcfg_MusicBrainzLookupEnabled->hide();
 #endif
 
--- a/libkcddb/libkcddb.kcfg
+++ b/libkcddb/libkcddb.kcfg
@@ -61,7 +61,7 @@
     <entry name="smtpHostname" type="String">
     </entry>
     <entry name="submitAddress" type="String">
-      <default>test-submit@freedb.org</default>
+      <default>freedb-submit@freedb.org</default>
     </entry>
   </group>
 </kcfg>
--- a/libkcddb/musicbrainz/musicbrainzlookup.cpp
+++ b/libkcddb/musicbrainz/musicbrainzlookup.cpp
@@ -22,13 +22,21 @@
 
 #include <kdebug.h>
 #include <kcodecs.h>
+#include <klocale.h>
 #include <qcryptographichash.h>
 #include <cstdio>
 #include <cstring>
-#include <musicbrainz3/musicbrainz.h>
-#include <musicbrainz3/query.h>
-#include <musicbrainz3/release.h>
-#include <musicbrainz3/filters.h>
+#include <musicbrainz5/Query.h>
+#include <musicbrainz5/Medium.h>
+#include <musicbrainz5/Release.h>
+#include <musicbrainz5/ReleaseGroup.h>
+#include <musicbrainz5/Track.h>
+#include <musicbrainz5/Recording.h>
+#include <musicbrainz5/Disc.h>
+#include <musicbrainz5/HTTPFetch.h>
+#include <musicbrainz5/ArtistCredit.h>
+#include <musicbrainz5/Artist.h>
+#include <musicbrainz5/NameCredit.h>
 
 namespace KCDDB
 {
@@ -48,60 +56,181 @@ namespace KCDDB
 
     kDebug() << "Should lookup " << discId;
 
-    MusicBrainz::Query q;
-    MusicBrainz::ReleaseResultList results;
+    MusicBrainz5::CQuery Query("libkcddb-0.4");
+
+    // Code adapted from libmusicbrainz/examples/cdlookup.cc
 
     try {
-        MusicBrainz::ReleaseFilter f = MusicBrainz::ReleaseFilter().discId(std::string(discId.toAscii()));
-        results = q.getReleases(&f);
-    }
-		// FIXME Doesn't seem to get caught, why?
-    // catch (MusicBrainz::WebServiceError &e)
-    catch (...)
-    {
-        kDebug() << "Query failed"; //<< e.what();
-        return UnknownError;
-    }
-
-    int relnr=1;
-    for (MusicBrainz::ReleaseResultList::iterator i = results.begin(); i != results.end(); i++) {
-        MusicBrainz::ReleaseResult *result = *i;
-        MusicBrainz::Release *release;
-        try {
-            release = q.getReleaseById(result->getRelease()->getId(), &MusicBrainz::ReleaseIncludes().tracks().artist());
-        }
-        catch (MusicBrainz::WebServiceError &e) {
-            kDebug() << "Error: " << e.what();
-            continue;
-        }
-        CDInfo info;
-        info.set(QLatin1String( "source" ), QLatin1String( "musicbrainz" ));
-        // Uses musicbrainz discid for the first release,
-        // then discid-2, discid-3 and so on, to
-        // allow multiple releases with the same discid
-        if (relnr == 1)
-          info.set(QLatin1String( "discid" ), discId);
-        else
-          info.set(QLatin1String( "discid" ), discId+QLatin1String( "-" )+QString::number(relnr));
+      MusicBrainz5::CMetadata Metadata=Query.Query("discid",discId.toAscii().constData());
+
+      if (Metadata.Disc() && Metadata.Disc()->ReleaseList())
+      {
+        MusicBrainz5::CReleaseList *ReleaseList=Metadata.Disc()->ReleaseList();
+        kDebug() << "Found " << ReleaseList->NumItems() << " release(s)";
 
-        info.set(Title, QString::fromUtf8(release->getTitle().c_str()));
-        info.set(Artist, QString::fromUtf8(release->getArtist()->getName().c_str()));
+        int relnr=1;
 
-        int trackno = 0;
-        for (MusicBrainz::TrackList::iterator j = release->getTracks().begin(); j != release->getTracks().end(); j++) {
-            MusicBrainz::Track *mb_track = *j;
-            MusicBrainz::Artist *artist = mb_track->getArtist();
-            if (!artist)
-              artist = release->getArtist();
-            TrackInfo& track = info.track(trackno);
-            track.set(Artist, QString::fromUtf8(artist->getName().c_str()));
-            track.set(Title, QString::fromUtf8(mb_track->getTitle().c_str()));
-            trackno++;
+        for (int i = 0; i < ReleaseList->NumItems(); i++)
+        {
+          MusicBrainz5::CRelease* Release=ReleaseList->Item(i);
+
+          //The releases returned from LookupDiscID don't contain full information
+
+          MusicBrainz5::CQuery::tParamMap Params;
+          Params["inc"]="artists labels recordings release-groups url-rels discids artist-credits";
+
+          std::string ReleaseID=Release->ID();
+
+          MusicBrainz5::CMetadata Metadata2=Query.Query("release",ReleaseID,"",Params);
+          if (Metadata2.Release())
+          {
+            MusicBrainz5::CRelease *FullRelease=Metadata2.Release();
+
+            //However, these releases will include information for all media in the release
+            //So we need to filter out the only the media we want.
+
+            MusicBrainz5::CMediumList MediaList=FullRelease->MediaMatchingDiscID(discId.toAscii().constData());
+
+            if (MediaList.NumItems() > 0)
+            {
+              /*if (FullRelease->ReleaseGroup())
+                kDebug() << "Release group title: " << FullRelease->ReleaseGroup()->Title();
+              else
+                kDebug() << "No release group for this release";*/
+
+              kDebug() << "Found " << MediaList.NumItems() << " media item(s)";
+
+              for (int i=0; i < MediaList.NumItems(); i++)
+              {
+                MusicBrainz5::CMedium* Medium= MediaList.Item(i);
+
+                /*kDebug() << "Found media: '" << Medium.Title() << "', position " << Medium.Position();*/
+
+                CDInfo info;
+                info.set(QLatin1String( "source" ), QLatin1String( "musicbrainz" ));
+                // Uses musicbrainz discid for the first release,
+                // then discid-2, discid-3 and so on, to
+                // allow multiple releases with the same discid
+                if (relnr == 1)
+                  info.set(QLatin1String( "discid" ), discId);
+                else
+                  info.set(QLatin1String( "discid" ), discId+QLatin1String( "-" )+QString::number(relnr));
+
+                QString title = QString::fromUtf8(FullRelease->Title().c_str());
+
+                if (FullRelease->MediumList()->NumItems() > 1)
+                  title = i18n("%1 (disc %2)", title, Medium->Position());
+
+                info.set(Title, title);
+                info.set(Artist, artistFromCreditList(FullRelease->ArtistCredit()));
+
+                QString date = QString::fromUtf8(FullRelease->Date().c_str());
+                QRegExp yearRe("^(\\d{4,4})(-\\d{1,2}-\\d{1,2})?$");
+                int year = 0;
+                if (yearRe.indexIn(date) > -1)
+                {
+                  QString yearString = yearRe.cap(1);
+                  bool ok;
+                  year=yearString.toInt(&ok);
+                  if (!ok)
+                    year = 0;
+                }
+                info.set(Year, year);
+
+                MusicBrainz5::CTrackList *TrackList=Medium->TrackList();
+                if (TrackList)
+                {
+                  for (int i=0; i < TrackList->NumItems(); i++)
+                  {
+                    MusicBrainz5::CTrack* Track=TrackList->Item(i);
+                    MusicBrainz5::CRecording *Recording=Track->Recording();
+
+                    TrackInfo& track = info.track(i);
+
+                    // Prefer title and artist from the track credits, but
+                    // it appears to be empty if same as in Recording
+                    // Noticable in the musicbrainztest-fulldate test,
+                    // where the title on the credits of track 18 are
+                    // "Bara om min älskade väntar", but the recording
+                    // has title "Men bara om min älskade"
+                    if(Recording && Track->ArtistCredit() == 0)
+                      track.set(Artist, artistFromCreditList(Recording->ArtistCredit()));
+                    else
+                      track.set(Artist, artistFromCreditList(Track->ArtistCredit()));
+
+                    if(Recording && Track->Title().empty())
+                      track.set(Title, QString::fromUtf8(Recording->Title().c_str()));
+                    else
+                      track.set(Title, QString::fromUtf8(Track->Title().c_str()));
+                  }
+                }
+                cdInfoList_ << info;
+                relnr++;
+              }
+            }
+          }
         }
-        delete result;
+      }
+    }
+
+    catch (MusicBrainz5::CConnectionError& Error)
+    {
+      kDebug() << "Connection Exception: '" << Error.what() << "'";
+      kDebug() << "LastResult: " << Query.LastResult();
+      kDebug() << "LastHTTPCode: " << Query.LastHTTPCode();
+      kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str());
+
+      return ServerError;
+    }
+
+    catch (MusicBrainz5::CTimeoutError& Error)
+    {
+      kDebug() << "Timeout Exception: '" << Error.what() << "'";
+      kDebug() << "LastResult: " << Query.LastResult();
+      kDebug() << "LastHTTPCode: " << Query.LastHTTPCode();
+      kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str());
 
-        cdInfoList_ << info;
-        relnr++;
+      return ServerError;
+    }
+
+    catch (MusicBrainz5::CAuthenticationError& Error)
+    {
+      kDebug() << "Authentication Exception: '" << Error.what() << "'";
+      kDebug() << "LastResult: " << Query.LastResult();
+      kDebug() << "LastHTTPCode: " << Query.LastHTTPCode();
+      kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str());
+
+      return ServerError;
+    }
+
+    catch (MusicBrainz5::CFetchError& Error)
+    {
+      kDebug() << "Fetch Exception: '" << Error.what() << "'";
+      kDebug() << "LastResult: " << Query.LastResult();
+      kDebug() << "LastHTTPCode: " << Query.LastHTTPCode();
+      kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str());
+
+      return ServerError;
+    }
+
+    catch (MusicBrainz5::CRequestError& Error)
+    {
+      kDebug() << "Request Exception: '" << Error.what() << "'";
+      kDebug() << "LastResult: " << Query.LastResult();
+      kDebug() << "LastHTTPCode: " << Query.LastHTTPCode();
+      kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str());
+
+      return ServerError;
+    }
+
+    catch (MusicBrainz5::CResourceNotFoundError& Error)
+    {
+      kDebug() << "ResourceNotFound Exception: '" << Error.what() << "'";
+      kDebug() << "LastResult: " << Query.LastResult();
+      kDebug() << "LastHTTPCode: " << Query.LastHTTPCode();
+      kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str());
+
+      return ServerError;
     }
 
     if (cdInfoList_.isEmpty())
@@ -196,6 +325,35 @@ namespace KCDDB
 
     return infoList;
   }
+
+  QString MusicBrainzLookup::artistFromCreditList(MusicBrainz5::CArtistCredit * artistCredit )
+  {
+    kDebug() << k_funcinfo;
+    QString artistName;
+
+    MusicBrainz5::CNameCreditList *ArtistList=artistCredit->NameCreditList();
+
+    if (ArtistList)
+    {
+      for (int i=0; i < ArtistList->NumItems(); i++)
+      {
+        MusicBrainz5::CNameCredit* Name=ArtistList->Item(i);
+        MusicBrainz5::CArtist* Artist = Name->Artist();
+
+        if (!Name->Name().empty())
+          artistName += QString::fromUtf8(Name->Name().c_str());
+        else
+          artistName += QString::fromUtf8(Artist->Name().c_str());
+
+        artistName += QString::fromUtf8(Name->JoinPhrase().c_str());
+      }
+
+      kDebug() << "Artist:" << artistName;
+
+    }
+
+    return artistName;
+  }
 }
 
 // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1
--- a/libkcddb/musicbrainz/musicbrainzlookup.h
+++ b/libkcddb/musicbrainz/musicbrainzlookup.h
@@ -25,6 +25,11 @@
 #include "../kcddb.h"
 #include "../kcddbconfig.h"
 
+namespace MusicBrainz5
+{
+  class CArtistCredit;
+}
+
 namespace KCDDB
 {
   class MusicBrainzLookup : public Lookup
@@ -44,6 +49,7 @@ namespace KCDDB
     private:
 
       static QString calculateDiscId(const TrackOffsetList & );
+      static QString artistFromCreditList(MusicBrainz5::CArtistCredit * );
   } ;
 }
 
--- a/libkcddb/test/CMakeLists.txt
+++ b/libkcddb/test/CMakeLists.txt
@@ -27,6 +27,8 @@ KCDDB_UNIT_TESTS(
     asyncmusicbrainztest
     cdinfotest
     cachetest
+    musicbrainztest-severaldiscs
+    musicbrainztest-fulldate
 )
 
 KCDDB_EXECUTABLE_TESTS(
--- a/libkcddb/test/asyncmusicbrainztest.cpp
+++ b/libkcddb/test/asyncmusicbrainztest.cpp
@@ -28,7 +28,7 @@ void AsyncMusicBrainzTest::testLookup()
 {
   using namespace KCDDB;
 
-#ifndef HAVE_MUSICBRAINZ3
+#ifndef HAVE_MUSICBRAINZ5
   QSKIP("This test requires libmusicbrainz", SkipAll);
 #endif
 
@@ -74,9 +74,9 @@ void AsyncMusicBrainzTest::testLookup()
 
   QCOMPARE(m_info.get(Artist).toString(),QString("Various Artists"));
   QCOMPARE(m_info.get(Title).toString(),QString::fromUtf8("Definitivt 50 spänn 10"));
-  // genre and year not really supported for musicbrainz
+  // genre not really supported for musicbrainz
   QCOMPARE(m_info.get(Genre).toString(),QString());
-  QCOMPARE(m_info.get(Year).toInt(),0);
+  QCOMPARE(m_info.get(Year).toInt(),2001);
   QCOMPARE(m_info.track(0).get(Title).toString(),QString::fromUtf8("Uphill Struggle"));
   QCOMPARE(m_info.track(1).get(Title).toString(),QString::fromUtf8("Vill du bli miljonär?"));
   QCOMPARE(m_info.track(2).get(Title).toString(),QString::fromUtf8("Här är jag"));
--- /dev/null
+++ b/libkcddb/test/musicbrainztest-severaldiscs.cpp
@@ -0,0 +1,141 @@
+/*
+  Copyright (C) 2006 Richard Lärkäng <nouseforaname@home.se>
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; see the file COPYING.LIB.  If not, write to
+  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+
+#include <qtest_kde.h>
+#include "musicbrainztest-severaldiscs.h"
+#include "libkcddb/client.h"
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+#include "config-musicbrainz.h"
+
+
+void MusicBrainzTestSeveralDiscs::testLookup()
+{
+  using namespace KCDDB;
+
+#ifndef HAVE_MUSICBRAINZ5
+  QSKIP("This test requires libmusicbrainz", SkipAll);
+#endif
+
+  Client c;
+  c.config().setCacheLookupEnabled(false);
+  c.config().setFreedbLookupEnabled(false);
+  c.config().setMusicBrainzLookupEnabled(true);
+
+  TrackOffsetList list;
+
+  list <<
+    150 <<
+    17272 <<
+    36395 <<
+    47954 <<
+    63638 <<
+    77928 <<
+    95029 <<
+    112094 <<
+    130540 <<
+    145938 <<
+    160463 <<
+    180364 <<
+    195549 <<
+    203821 <<
+    222410 <<
+    230367 <<
+    249241 <<
+    273944 <<
+    287584 <<
+    309904 <<
+    325124;
+
+  Result r = c.lookup(list);
+
+  QVERIFY(r == Success);
+
+  kDebug() << "Client::lookup gave : " << resultToString(r);
+
+  CDInfoList response = c.lookupResponse();
+
+  kDebug() << "Client::lookup returned : " << response.count() << " entries"
+    << endl;
+
+  QVERIFY(response.count() > 0);
+
+  // See http://musicbrainz.org/release/4e0655b5-22fc-496e-9c14-2ee1a6027b45 for changes (disc 2)
+  CDInfo i(response.first());
+  QCOMPARE(i.numberOfTracks(),20);
+
+  QCOMPARE(i.get(Artist).toString(),QString("Billy Bragg"));
+  QCOMPARE(i.get(Title).toString(),QString("Must I Paint You a Picture? The Essential Billy Bragg (disc 2)"));
+  // genre not really supported for musicbrainz
+  QCOMPARE(i.get(Genre).toString(),QString());
+  QCOMPARE(i.get(Year).toInt(),2003);
+  QCOMPARE(i.track(0).get(Title).toString(),QString("Sexuality"));
+  QCOMPARE(i.track(1).get(Title).toString(),QString("Cindy of 1000 Lives"));
+  QCOMPARE(i.track(2).get(Title).toString(),QString("Moving the Goalposts"));
+  QCOMPARE(i.track(3).get(Title).toString(),QString("Tank Park Salute"));
+  QCOMPARE(i.track(4).get(Title).toString(),QString("You Woke Up My Neighbourhood"));
+  QCOMPARE(i.track(5).get(Title).toString(),QString("Accident Waiting to Happen (Red Stars version)"));
+  QCOMPARE(i.track(6).get(Title).toString(),QString("Sulk"));
+  QCOMPARE(i.track(7).get(Title).toString(),QString("Upfield"));
+  QCOMPARE(i.track(8).get(Title).toString(),QString("The Fourteenth of February"));
+  QCOMPARE(i.track(9).get(Title).toString(),QString("Brickbat"));
+  QCOMPARE(i.track(10).get(Title).toString(),QString("The Space Race Is Over"));
+  QCOMPARE(i.track(11).get(Title).toString(),QString("The Boy Done Good"));
+  QCOMPARE(i.track(12).get(Title).toString(),QString("Ingrid Bergman"));
+  QCOMPARE(i.track(13).get(Title).toString(),QString("Way Over Yonder in the Minor Key"));
+  QCOMPARE(i.track(14).get(Title).toString(),QString("My Flying Saucer"));
+  QCOMPARE(i.track(15).get(Title).toString(),QString("All You Fascists Bound to Lose (Blokes version)"));
+  QCOMPARE(i.track(16).get(Title).toString(),QString("NPWA"));
+  QCOMPARE(i.track(17).get(Title).toString(),QString("St. Monday"));
+  QCOMPARE(i.track(18).get(Title).toString(),QString("Somedays I See the Point"));
+  QCOMPARE(i.track(19).get(Title).toString(),QString("Take Down the Union Jack (Band version)"));
+  for (int j=0; j < 12; j++)
+    QCOMPARE(i.track(j).get(Artist).toString(),QString("Billy Bragg"));
+  for (int j=12; j < 15; j++)
+    QCOMPARE(i.track(j).get(Artist).toString(),QString("Billy Bragg & Wilco"));
+  for (int j=15; j < 20; j++)
+    QCOMPARE(i.track(j).get(Artist).toString(),QString("Billy Bragg and The Blokes"));
+  // comments not supported in a simple way
+  for (int j=0; j < 19; j++)
+    QCOMPARE(i.track(j).get(Comment).toString(),QString());
+
+  // Make sure it's the same when loaded from the cache again
+  c.config().setCacheLookupEnabled(true);
+  c.config().setFreedbLookupEnabled(false);
+  c.config().setMusicBrainzLookupEnabled(false);
+
+  c.lookup(list);
+
+  response = c.lookupResponse();
+  QVERIFY(response.count() > 0);
+
+  CDInfo cacheInfo(response.first());
+  QCOMPARE(i.get(Artist).toString(),cacheInfo.get(Artist).toString());
+  QCOMPARE(i.get(Title).toString(),cacheInfo.get(Title).toString());
+  QCOMPARE(i.get(Year).toInt(),cacheInfo.get(Year).toInt());
+  for (int j=0; j < 19; j++)
+  {
+    QCOMPARE(i.track(j).get(Title).toString(),cacheInfo.track(j).get(Title).toString());
+    QCOMPARE(i.track(j).get(Comment).toString(),cacheInfo.track(j).get(Comment).toString());
+  }
+}
+
+QTEST_KDEMAIN(MusicBrainzTestSeveralDiscs, NoGUI)
+
+#include "musicbrainztest-severaldiscs.moc"
--- /dev/null
+++ b/libkcddb/test/musicbrainztest-severaldiscs.h
@@ -0,0 +1,32 @@
+/*
+  Copyright (C) 2006 Richard Lärkäng <nouseforaname@home.se>
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; see the file COPYING.LIB.  If not, write to
+  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+
+#ifndef MUSICBRAINZTESTSEVERALDISCS_H
+#define MUSICBRAINZTESTSEVERALDISCS_H
+
+#include <QObject>
+
+class MusicBrainzTestSeveralDiscs : public QObject
+{
+  Q_OBJECT
+  private slots:
+    void testLookup();
+};
+
+#endif
--- a/libkcddb/test/musicbrainztest.cpp
+++ b/libkcddb/test/musicbrainztest.cpp
@@ -29,7 +29,7 @@ void MusicBrainzTest::testLookup()
 {
   using namespace KCDDB;
 
-#ifndef HAVE_MUSICBRAINZ3
+#ifndef HAVE_MUSICBRAINZ5
   QSKIP("This test requires libmusicbrainz", SkipAll);
 #endif
 
@@ -71,15 +71,15 @@ void MusicBrainzTest::testLookup()
 
   QVERIFY(response.count() > 0);
 
-  // See http://musicbrainz.org/showalbum.html?albumid=375639 for changes
+  // See http://musicbrainz.org/release/68ec4a09-576c-472e-9103-aed99b6a3ffc for changes
   CDInfo i(response.first());
   QCOMPARE(i.numberOfTracks(),14);
 
   QCOMPARE(i.get(Artist).toString(),QString("The Liptones"));
   QCOMPARE(i.get(Title).toString(),QString("The Latest News"));
-  // genre and year not really supported for musicbrainz
+  // genre not really supported for musicbrainz
   QCOMPARE(i.get(Genre).toString(),QString());
-  QCOMPARE(i.get(Year).toInt(),0);
+  QCOMPARE(i.get(Year).toInt(),2002);
   QCOMPARE(i.track(0).get(Title).toString(),QString("Jungle Heat"));
   QCOMPARE(i.track(1).get(Title).toString(),QString("It's All I Hear You Say"));
   QCOMPARE(i.track(2).get(Title).toString(),QString("Girl for Tonight"));
--- /dev/null
+++ b/cmake/modules/FindMusicBrainz5.cmake
@@ -0,0 +1,26 @@
+# Module to find the musicbrainz-4 library
+#
+# It defines
+#  MUSICBRAINZ5_INCLUDE_DIR - the include dir
+#  MUSICBRAINZ5_LIBRARIES - the required libraries
+#  MUSICBRAINZ5_FOUND - true if both of the above have been found
+
+# Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if(MUSICBRAINZ5_INCLUDE_DIR AND MUSICBRAINZ5_LIBRARIES)
+   set(MUSICBRAINZ5_FIND_QUIETLY TRUE)
+endif(MUSICBRAINZ5_INCLUDE_DIR AND MUSICBRAINZ5_LIBRARIES)
+
+FIND_PATH(MUSICBRAINZ5_INCLUDE_DIR musicbrainz5/Disc.h)
+
+FIND_LIBRARY( MUSICBRAINZ5_LIBRARIES NAMES musicbrainz5)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args( MusicBrainz5 DEFAULT_MSG
+                                   MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES)
+
+MARK_AS_ADVANCED(MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES)
+
--- /dev/null
+++ b/libkcddb/test/musicbrainztest-fulldate.cpp
@@ -0,0 +1,157 @@
+/*
+  Copyright (C) 2006 Richard Lärkäng <nouseforaname@home.se>
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; see the file COPYING.LIB.  If not, write to
+  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+
+#include <qtest_kde.h>
+#include "musicbrainztest-fulldate.h"
+#include "libkcddb/client.h"
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+#include "config-musicbrainz.h"
+
+
+void MusicBrainzTestFullDate::testLookup()
+{
+  using namespace KCDDB;
+
+#ifndef HAVE_MUSICBRAINZ5
+  QSKIP("This test requires libmusicbrainz", SkipAll);
+#endif
+
+  Client c;
+  c.config().setCacheLookupEnabled(false);
+  c.config().setFreedbLookupEnabled(false);
+  c.config().setMusicBrainzLookupEnabled(true);
+
+  TrackOffsetList list;
+
+  list <<
+    150 <<
+    11837 <<
+    20687 <<
+    29120 <<
+    35557 <<
+    50087 <<
+    58550 <<
+    72575 <<
+    81887 <<
+    95745 <<
+    104340 <<
+    115425 <<
+    124285 <<
+    132317 <<
+    142692 <<
+    160272 <<
+    169325 <<
+    181377 <<
+    194482 <<
+    205747 <<
+    216492 <<
+    229507 <<
+    242715 <<
+    252112 <<
+    274965 <<
+    285820 <<
+    308957 <<
+    322362 <<
+    338662 <<
+    350172 <<
+    356692;
+
+  Result r = c.lookup(list);
+
+  QVERIFY(r == Success);
+
+  kDebug() << "Client::lookup gave : " << resultToString(r);
+
+  CDInfoList response = c.lookupResponse();
+
+  kDebug() << "Client::lookup returned : " << response.count() << " entries"
+    << endl;
+
+  QVERIFY(response.count() > 0);
+
+  // See http://musicbrainz.org/release/04319e80-0948-4e89-8180-7cf6f17fc77a for changes
+  CDInfo i(response.first());
+  QCOMPARE(i.numberOfTracks(),30);
+
+  QCOMPARE(i.get(Artist).toString(),QString("Troublemakers"));
+  QCOMPARE(i.get(Title).toString(),QString("30"));
+  // genre not really supported for musicbrainz
+  QCOMPARE(i.get(Genre).toString(),QString());
+  QCOMPARE(i.get(Year).toInt(),2011);
+  QCOMPARE(i.track(0).get(Title).toString(),QString("30"));
+  QCOMPARE(i.track(1).get(Title).toString(),QString::fromUtf8("Staden Göteborg"));
+  QCOMPARE(i.track(2).get(Title).toString(),QString::fromUtf8("Lilla Blå"));
+  QCOMPARE(i.track(3).get(Title).toString(),QString("Kleptoman"));
+  QCOMPARE(i.track(4).get(Title).toString(),QString::fromUtf8("Grogg å parabol"));
+  QCOMPARE(i.track(5).get(Title).toString(),QString("Majorna brinner"));
+  QCOMPARE(i.track(6).get(Title).toString(),QString::fromUtf8("Utan hjärta stannar Sverige"));
+  QCOMPARE(i.track(7).get(Title).toString(),QString("Dom e efter mig"));
+  QCOMPARE(i.track(8).get(Title).toString(),QString("Mammas flickor"));
+  QCOMPARE(i.track(9).get(Title).toString(),QString("Handgranat"));
+  QCOMPARE(i.track(10).get(Title).toString(),QString("Stenar o blod"));
+  QCOMPARE(i.track(11).get(Title).toString(),QString("Enkel Berlin"));
+  QCOMPARE(i.track(12).get(Title).toString(),QString("Dom ljuger"));
+  QCOMPARE(i.track(13).get(Title).toString(),QString("Jobba"));
+  QCOMPARE(i.track(14).get(Title).toString(),QString::fromUtf8("Varför lyser inga stjärnor"));
+  QCOMPARE(i.track(15).get(Title).toString(),QString("Partytrash"));
+  QCOMPARE(i.track(16).get(Title).toString(),QString::fromUtf8("Förstod ingenting"));
+  QCOMPARE(i.track(17).get(Title).toString(),QString::fromUtf8("Bara om min älskade väntar"));
+  QCOMPARE(i.track(18).get(Title).toString(),QString("Lillebror"));
+  QCOMPARE(i.track(19).get(Title).toString(),QString("Skandaler"));
+  QCOMPARE(i.track(20).get(Title).toString(),QString::fromUtf8("Hjältarna skålar i blod"));
+  QCOMPARE(i.track(21).get(Title).toString(),QString("Bomber o granater"));
+  QCOMPARE(i.track(22).get(Title).toString(),QString::fromUtf8("Vill du bli miljonär"));
+  QCOMPARE(i.track(23).get(Title).toString(),QString::fromUtf8("Stjärnorna kvittar det lika"));
+  QCOMPARE(i.track(24).get(Title).toString(),QString("Naken"));
+  QCOMPARE(i.track(25).get(Title).toString(),QString::fromUtf8("Månen lyser klar"));
+  QCOMPARE(i.track(26).get(Title).toString(),QString("Vild o vacker"));
+  QCOMPARE(i.track(27).get(Title).toString(),QString("Jag fryser"));
+  QCOMPARE(i.track(28).get(Title).toString(),QString("Ein zwei polizei"));
+  QCOMPARE(i.track(29).get(Title).toString(),QString::fromUtf8("Jävla idiot"));
+  for (int j=0; j < 30; j++)
+    QCOMPARE(i.track(j).get(Artist).toString(),QString("Troublemakers"));
+  // comments not supported in a simple way
+  for (int j=0; j < 19; j++)
+    QCOMPARE(i.track(j).get(Comment).toString(),QString());
+
+  // Make sure it's the same when loaded from the cache again
+  c.config().setCacheLookupEnabled(true);
+  c.config().setFreedbLookupEnabled(false);
+  c.config().setMusicBrainzLookupEnabled(false);
+
+  c.lookup(list);
+
+  response = c.lookupResponse();
+  QVERIFY(response.count() > 0);
+
+  CDInfo cacheInfo(response.first());
+  QCOMPARE(i.get(Artist).toString(),cacheInfo.get(Artist).toString());
+  QCOMPARE(i.get(Title).toString(),cacheInfo.get(Title).toString());
+  QCOMPARE(i.get(Year).toInt(),cacheInfo.get(Year).toInt());
+  for (int j=0; j < 19; j++)
+  {
+    QCOMPARE(i.track(j).get(Title).toString(),cacheInfo.track(j).get(Title).toString());
+    QCOMPARE(i.track(j).get(Comment).toString(),cacheInfo.track(j).get(Comment).toString());
+  }
+}
+
+QTEST_KDEMAIN(MusicBrainzTestFullDate, NoGUI)
+
+#include "musicbrainztest-fulldate.moc"
--- /dev/null
+++ b/libkcddb/test/musicbrainztest-fulldate.h
@@ -0,0 +1,32 @@
+/*
+  Copyright (C) 2006 Richard Lärkäng <nouseforaname@home.se>
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; see the file COPYING.LIB.  If not, write to
+  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+
+#ifndef MUSICBRAINZTESTFULLDATE_H
+#define MUSICBRAINZTESTFULLDATE_H
+
+#include <QObject>
+
+class MusicBrainzTestFullDate : public QObject
+{
+  Q_OBJECT
+  private slots:
+    void testLookup();
+};
+
+#endif

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: