Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jul 2018 21:11:24 +0000 (UTC)
From:      "Jason E. Hale" <jhale@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r476022 - in head/audio/kscd-kde4: . files
Message-ID:  <201807312111.w6VLBOcH039668@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhale
Date: Tue Jul 31 21:11:24 2018
New Revision: 476022
URL: https://svnweb.freebsd.org/changeset/ports/476022

Log:
  The webservice that audio/libmusicbrainz3 interfaces with will cease operation
  on 2018-08-01. Add upstream patch to use audio/libmusicbrainz5 for track lookup
  operations instead.
  
  Reviewed by:	rakuco
  Obtained from:	KDE git repo
  MFH:		2018Q3 (runtime fix)
  Differential Revision:	https://reviews.freebsd.org/D16536

Added:
  head/audio/kscd-kde4/files/patch-libmusicbrainz5   (contents, props changed)
Modified:
  head/audio/kscd-kde4/Makefile

Modified: head/audio/kscd-kde4/Makefile
==============================================================================
--- head/audio/kscd-kde4/Makefile	Tue Jul 31 20:55:18 2018	(r476021)
+++ head/audio/kscd-kde4/Makefile	Tue Jul 31 21:11:24 2018	(r476022)
@@ -3,7 +3,7 @@
 
 PORTNAME=	kscd
 PORTVERSION=	${KDE4_VERSION}
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	audio kde kde-kde4
 
 MAINTAINER=	kde@FreeBSD.org
@@ -11,7 +11,8 @@ COMMENT=	CD Player for KDE
 
 LICENSE=	GPLv2
 
-LIB_DEPENDS=	libmusicbrainz3.so:audio/libmusicbrainz3
+LIB_DEPENDS=	libdiscid.so:audio/libdiscid \
+		libmusicbrainz5.so:audio/libmusicbrainz5
 
 USES=		cmake:outsource kde:4 qt:4 tar:xz
 USE_KDE=	kdelibs automoc4

Added: head/audio/kscd-kde4/files/patch-libmusicbrainz5
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/audio/kscd-kde4/files/patch-libmusicbrainz5	Tue Jul 31 21:11:24 2018	(r476022)
@@ -0,0 +1,563 @@
+Use libmusicbrainz5 for track lookup since libmusicbrainz3 is deprecated.
+
+From:
+https://cgit.kde.org/kscd.git/commit/?id=536b679d8a0e4d3c470366b5bdfe142edb1c9307
+https://cgit.kde.org/kscd.git/commit/?id=908815f9fc7a0d7ebeae68c14a02026464b6c935
+https://cgit.kde.org/kscd.git/commit/?id=86128bdfef49d241e6aa71f968c614b8b07462de
+
+--- CMakeLists.txt.orig	2014-07-16 08:24:20 UTC
++++ CMakeLists.txt
+@@ -11,13 +11,15 @@ include_directories(${QT_INCLUDES} ${KDE4_INCLUDES})
+ find_package(Alsa)
+ alsa_configure_file(${CMAKE_CURRENT_BINARY_DIR}/config-alsa.h)
+ 
+-find_package(MusicBrainz3 REQUIRED)
++find_package(MusicBrainz5 REQUIRED)
++find_package(DiscId REQUIRED)
+ 
+ include_directories(
+                 ${CMAKE_CURRENT_SOURCE_DIR}/gui
+ 		${CMAKE_CURRENT_SOURCE_DIR}
+ 		${CMAKE_CURRENT_BINARY_DIR}
+-		${MUSICBRAINZ3_INCLUDE_DIR}
++		${MUSICBRAINZ5_INCLUDE_DIR}
++		${DISCID_INCLUDE_DIR}
+ 		)
+ add_subdirectory(tests)
+ ########### next target ###############
+@@ -115,7 +117,8 @@ target_link_libraries(kscd
+     ${KDE4_KIO_LIBS}
+     ${KDE4_SOLID_LIBS}
+     ${KDE4_PHONON_LIBS}
+-    ${MUSICBRAINZ3_LIBRARIES}
++    ${MUSICBRAINZ5_LIBRARIES}
++    ${DISCID_LIBRARIES}
+     )
+ 
+ ########### install files ###############
+--- cmake/FindDiscId.cmake.orig	2014-07-16 08:24:20 UTC
++++ cmake/FindDiscId.cmake
+@@ -0,0 +1,20 @@
++# Module to find the discid library
++# It can be found at http://musicbrainz.org/doc/libdiscid
++#
++# It defines
++#  DISCID_INCLUDE_DIR - the include dir
++#  DISCID_LIBRARIES - the required libraries
++#  DISCID_FOUND - true if both of the above have been found
++
++# Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
++# Copyright (c) 2010 Gerd Fleischer
++#
++# Redistribution and use is allowed according to the terms of the BSD license.
++
++FIND_PATH(DISCID_INCLUDE_DIR discid/discid.h)
++
++FIND_LIBRARY(DISCID_LIBRARIES NAMES discid)
++
++include(FindPackageHandleStandardArgs)
++find_package_handle_standard_args( DiscId DEFAULT_MSG
++                                   DISCID_INCLUDE_DIR DISCID_LIBRARIES)
+--- cmake/FindMusicBrainz5.cmake.orig	2014-07-16 08:24:20 UTC
++++ cmake/FindMusicBrainz5.cmake
+@@ -0,0 +1,33 @@
++# Module to find the musicbrainz-5 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()
++
++find_path(MUSICBRAINZ5_INCLUDE_DIR musicbrainz5/Disc.h)
++
++find_library(MUSICBRAINZ5_LIBRARIES NAMES musicbrainz5cc)
++if (NOT MUSICBRAINZ5_LIBRARIES)
++    find_library(MUSICBRAINZ5_LIBRARIES NAMES musicbrainz5)
++endif()
++
++include(FindPackageHandleStandardArgs)
++find_package_handle_standard_args(MusicBrainz5 DEFAULT_MSG MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES)
++
++add_library(musicbrainz SHARED IMPORTED)
++set_target_properties(musicbrainz PROPERTIES
++    INTERFACE_INCLUDE_DIRECTORIES "${MUSICBRAINZ5_INCLUDE_DIR}"
++    IMPORTED_LOCATION "${MUSICBRAINZ5_LIBRARIES}"
++)
++
++mark_as_advanced(MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES)
+--- kscd.cpp.orig	2014-07-16 08:24:20 UTC
++++ kscd.cpp
+@@ -114,7 +114,7 @@ void KSCD::setupActions()
+ 	m_uploadAction = m_actions->addAction( QLatin1String( "Upload Info" ));
+ 	m_uploadAction->setText(i18n("Upload Info"));
+ 	addAction(m_uploadAction);
+-	connect(m_uploadAction, SIGNAL(triggered()), m_MBManager, SLOT(discUpload()));
++	connect(m_uploadAction, SIGNAL(triggered()), this, SLOT(discUpload()));
+ 
+ 	//play/pause
+ 	m_playPauseAction = m_actions->addAction( QLatin1String( "Play/Pause" ));
+@@ -246,6 +246,11 @@ void KSCD::setupActions()
+ void KSCD::discLookup()
+ {
+ 	m_MBManager->discLookup(devices->getMedia()->currentSource().deviceName());
++}
++
++void KSCD::discUpload()
++{
++	m_MBManager->discUpload(devices->getMedia()->currentSource().deviceName());
+ }
+ 
+ void KSCD::discLookupFinished()
+--- kscd.h.orig	2014-07-16 08:24:20 UTC
++++ kscd.h
+@@ -131,6 +131,7 @@ public slots:
+ 	void configureKeys();
+ 
+ 	void discLookup();
++	void discUpload();
+ 	void discLookupFinished();
+ 
+ private:
+--- mbmanager.cpp.orig	2014-07-16 08:24:20 UTC
++++ mbmanager.cpp
+@@ -34,86 +34,239 @@
+ 
+ #include <ktoolinvocation.h>
+ 
+-#include <musicbrainz3/musicbrainz.h>
+-#include <musicbrainz3/query.h>
++#include <musicbrainz5/Query.h>
++#include <musicbrainz5/Artist.h>
++#include <musicbrainz5/ArtistCredit.h>
++#include <musicbrainz5/Disc.h>
++#include <musicbrainz5/HTTPFetch.h>
++#include <musicbrainz5/Medium.h>
++#include <musicbrainz5/NameCredit.h>
++#include <musicbrainz5/NameCreditList.h>
++#include <musicbrainz5/Recording.h>
++#include <musicbrainz5/Release.h>
++#include <musicbrainz5/Track.h>
+ 
+ MBManager::MBManager():m_validInfo(true)
+ {
+-
++	m_discid = discid_new();
+ }
+ 
+ MBManager::~MBManager()
+ {
++	discid_free(m_discid);
++}
+ 
++static QString getTitle(MusicBrainz5::CRelease *release, MusicBrainz5::CMedium *medium)
++{
++	QString title;
++	if (!release)
++	{
++		return title;
++	}
++
++	title = QString::fromUtf8(release->Title().c_str());
++	if (medium && release->MediumList()->NumItems() > 1)
++	{
++		title = i18n("%1 (disc %2)", title, medium->Position());
++	}
++
++	return title;
+ }
+ 
+-void MBManager::discLookup(const QString &device)
++static QString getArtistFromArtistCredit(MusicBrainz5::CArtistCredit *artistCredit)
+ {
+-	m_validInfo = true;
++	QString artist;
++	MusicBrainz5::CNameCreditList *artistList = artistCredit->NameCreditList();
+ 
+-	MusicBrainz::WebService* ws = new MusicBrainz::WebService();
++	if (!artistList)
++	{
++		return artist;
++	}
+ 
+-	// Set the proper server to use. Defaults to mm.musicbrainz.org:80
+-	if (!qgetenv("MB_SERVER").isNull())
++	for (int i = 0; i < artistList->NumItems(); i++)
+ 	{
+-		std::string server(qgetenv("MB_SERVER"));
+-		ws->setHost(server);
+-		//kDebug() << "!! set server !!" ;
++		MusicBrainz5::CNameCredit* name = artistList->Item(i);
++		MusicBrainz5::CArtist* itemArtist = name->Artist();
++
++		if (!name->Name().empty())
++		{
++			artist += QString::fromUtf8(name->Name().c_str());
++		}
++		else
++		{
++			artist += QString::fromUtf8(itemArtist->Name().c_str());
++		}
++
++		artist += QString::fromUtf8(name->JoinPhrase().c_str());
+ 	}
+-	else
++
++	return artist;
++}
++
++static QString getArtist(MusicBrainz5::CRelease *release)
++{
++	QString artist;
++	if (!release)
+ 	{
+-		//kDebug() << "no server";
++		return artist;
+ 	}
+ 
+-	// If you need to use a proxy, uncomment/edit the following line
+-	// as appropriate
+-	//ws->setProxyHost("proxy.mydomain.com");
+-	//ws->setProxyPort(80);
++	MusicBrainz5::CArtistCredit *artistCredit = release->ArtistCredit();
++	return getArtistFromArtistCredit(artistCredit);
++}
+ 
+-	try
++static QList<MBTrackInfo> unknownTracks(QString &discArtist, DiscId *m_discid)
++{
++	QList<MBTrackInfo> tracks;
++	MBTrackInfo track;
++	for (int j = 1; j < discid_get_first_track_num(m_discid); j++)
+ 	{
+-		MusicBrainz::Disc *disc = MusicBrainz::readDisc(qPrintable(device));
++		track.Title = i18n("Unknown title");
++		track.Artist = discArtist;
++		// Not an audio track
++		track.Duration = 0;
+ 
+-		MusicBrainz::Query q(ws);
+-		MusicBrainz::ReleaseResultList results;
++		tracks << track;
++	}
++	for (int j = discid_get_first_track_num(m_discid); j <= discid_get_last_track_num(m_discid); j++)
++	{
++		track.Title = i18n("Unknown title");
++		track.Artist = discArtist;
++		// time from mb library in sectors, 75 sectors = 1 second
++		track.Duration = discid_get_track_length(m_discid, j) * 1000 / 75;
+ 
+-		try
++		tracks << track;
++	}
++
++	return tracks;
++}
++
++static QList<MBTrackInfo> getTracks(MusicBrainz5::CMedium *medium, QString &discArtist, DiscId *m_discid)
++{
++	QList<MBTrackInfo> tracks;
++	if (!medium)
++	{
++		return tracks;
++	}
++
++	MusicBrainz5::CTrackList *trackList = medium->TrackList();
++	if (!trackList)
++	{
++		return unknownTracks(discArtist, m_discid);
++	}
++
++	MBTrackInfo track;
++	for (int i = 0; i < trackList->NumItems(); i++)
++	{
++		MusicBrainz5::CTrack *itemTrack = trackList->Item(i);
++		MusicBrainz5::CRecording *recording = itemTrack->Recording();
++		if (recording && !itemTrack->ArtistCredit())
+ 		{
+-		MusicBrainz::ReleaseFilter f = MusicBrainz::ReleaseFilter().discId(disc->getId());
+-			results = q.getReleases(&f);
++			track.Artist = getArtistFromArtistCredit(recording->ArtistCredit());
++		}
++		else
++		{
++			track.Artist = getArtistFromArtistCredit(itemTrack->ArtistCredit());
++		}
+ 
+-			// Check to see how many items were returned from the server
+-			if (!results.empty())
+-			{
+-				// TODO if multiple entries found
+-				if (results.size() > 1)
+-				{
+-					kDebug() << results.size() << " entries found";
+-				}
++		if(recording && itemTrack->Title().empty())
++		{
++			track.Title = QString::fromUtf8(recording->Title().c_str());
++		}
++		else
++		{
++			track.Title = QString::fromUtf8(itemTrack->Title().c_str());
++		}
+ 
+-				MusicBrainz::ReleaseResult *result = results.front();
+-				MusicBrainz::Release *release = q.getReleaseById(result->getRelease()->getId(),
+-								&MusicBrainz::ReleaseIncludes().tracks().artist());
+-				// Sets info
+-				m_discInfo.Title = QString::fromUtf8(release->getTitle().c_str());
+-				m_discInfo.Artist = QString::fromUtf8(release->getArtist()->getName().c_str());
++		track.Duration = itemTrack->Length();
+ 
+-				m_trackList.clear();
+-				MBTrackInfo track;
+-				for (MusicBrainz::TrackList::iterator j = release->getTracks().begin();
+-								j != release->getTracks().end(); j++)
+-				{
+-					MusicBrainz::Track *t = *j;
+-					MusicBrainz::Artist *artist = t->getArtist();
+-					if (!artist)
+-						artist = release->getArtist();
++		tracks << track;
++	}
+ 
+-					track.Title = QString::fromUtf8(t->getTitle().c_str());
+-					track.Artist = QString::fromUtf8(artist->getName().c_str());
+-					track.Duration = t->getDuration();
++	return tracks;
++}
+ 
+-					m_trackList << track;
+-				}
++static MusicBrainz5::CRelease *getRelease(MusicBrainz5::CQuery &query, std::string &discId, MusicBrainz5::CMetadata &metadata, MusicBrainz5::CMetadata &fullMetadata)
++{
++	metadata = query.Query("discid", discId);
++	// Check to see how many items were returned from the server
++	if (!metadata.Disc() || !metadata.Disc()->ReleaseList())
++	{
++		return 0;
++	}
++
++	MusicBrainz5::CReleaseList *results = metadata.Disc()->ReleaseList();
++
++	// TODO if multiple entries found
++	if (results->NumItems() > 1)
++	{
++		kDebug() << results->NumItems() << " entries found";
++	}
++
++	MusicBrainz5::CRelease *release;
++	for (int i = 0; i < results->NumItems(); i++)
++	{
++		MusicBrainz5::CRelease *result = results->Item(i);
++		MusicBrainz5::CQuery::tParamMap params;
++		params["inc"] = "artists labels recordings release-groups url-rels "
++						"discids artist-credits";
++		fullMetadata = query.Query("release", result->ID(), "", params);
++
++		release = fullMetadata.Release();
++		if (release)
++		{
++			break;
++		}
++	}
++
++	return release;
++}
++
++static MusicBrainz5::CMedium *getMedium(MusicBrainz5::CRelease *release, std::string &discId, MusicBrainz5::CMediumList &mediaList)
++{
++	if (!release)
++	{
++		return 0;
++	}
++
++	// Find the specific media in the release
++	mediaList = release->MediaMatchingDiscID(discId);
++	MusicBrainz5::CMedium* medium = 0;
++
++	for (int i = 0; i < mediaList.NumItems(); i++)
++	{
++		medium = mediaList.Item(i);
++		if (medium)
++		{
++			break;
++		}
++	}
++
++	return medium;
++}
++
++void MBManager::discLookup(const QString &device)
++{
++	m_validInfo = true;
++	MusicBrainz5::CQuery query("kscd");
++	int discid_ok = discid_read_sparse(m_discid, qPrintable(device), 0);
++	if (discid_ok)
++	{
++		std::string discId(discid_get_id(m_discid));
++		try
++		{
++			MusicBrainz5::CMetadata metadata, fullMetadata;
++			MusicBrainz5::CMediumList mediaList;
++			MusicBrainz5::CRelease *release = getRelease(query, discId, metadata, fullMetadata);
++			MusicBrainz5::CMedium *medium = getMedium(release, discId, mediaList);
++
++			if (release && medium)
++			{
++				// Sets info
++				m_discInfo.Title = getTitle(release, medium);
++				m_discInfo.Artist = getArtist(release);
++
++				m_trackList = getTracks(medium, m_discInfo.Artist, m_discid);
+ 			}
+ 			else
+ 			{
+@@ -121,75 +274,57 @@ void MBManager::discLookup(const QString &device)
+ 				m_validInfo = false;
+ 			}
+ 
+-
+ 		}
+-		catch (const MusicBrainz::WebServiceError &e)
+-                {
+-			kDebug() << "Error: " << e.what();
++		catch (MusicBrainz5::CExceptionBase& error)
++		{
++			kDebug() << "Connection Exception: '" << error.what() << "'";
++			kDebug() << "LastResult: " << query.LastResult();
++			kDebug() << "LastHTTPCode: " << query.LastHTTPCode();
++			kDebug() << "LastErrorMessage: " << QString::fromUtf8(query.LastErrorMessage().c_str());
++
+ 			m_validInfo = false;
+-                }
++		}
+ 		catch (...)
+ 		{
+ 			kDebug() << "Caught Unknown Exception:";
+ 			m_validInfo = false;
+ 		}
+-
+-		if (!m_validInfo)
+-		{
+-			// If invalid data, fill the information with something
+-			// Sets info
+-			m_discInfo.Title = i18n("Unknown album");
+-			m_discInfo.Artist = i18n("Unknown artist");
+-
+-			m_trackList.clear();
+-			MBTrackInfo track;
+-			for (MusicBrainz::Disc::TrackList::iterator j = disc->getTracks().begin(); j != disc->getTracks().end(); j++)
+-			{
+-				track.Title = i18n("Unknown title");
+-				track.Artist = m_discInfo.Artist;
+-				// time from mb library in sectors, 75 sectors = 1 second
+-				track.Duration = (*j).second*1000/75;
+-
+-				m_trackList << track;
+-			}
+-		}
+-		delete disc;
+ 	}
+-        // FIXME Doesn't seem to get caught, why?
+-        catch (const MusicBrainz::DiscError &e)
+-        {
+-		kDebug() << "Error: " << e.what();
+-		m_discInfo.Title = i18n("Unknown album");
+-		m_discInfo.Artist = i18n("Unknown artist");
+-		m_discInfo.Artist = i18n( "No Disc" );
+-		m_trackList.clear();
+-        }
+-	catch(...)
++	else
+ 	{
++		m_validInfo = false;
++	}
++
++	if (!m_validInfo)
++	{
++		// If invalid data, fill the information with something
++		// Sets info
+ 		m_discInfo.Title = i18n("Unknown album");
+ 		m_discInfo.Artist = i18n("Unknown artist");
+-		m_discInfo.Artist = i18n( "No Disc" );
++
+ 		m_trackList.clear();
++		if (discid_ok)
++		{
++			m_trackList = unknownTracks(m_discInfo.Artist, m_discid);
++		}
+ 	}
+-	
++
+ 	emit discLookupFinished();
+ }
+ 
+-void MBManager::discUpload()
++void MBManager::discUpload(const QString &device)
+ {
+ 	showArtistLabel(m_discInfo.Artist);
++	const char *discid_device = device.isEmpty()? NULL : qPrintable(device);
+ 
+-	try
++	int ok = discid_read_sparse(m_discid, discid_device, 0);
++	if (ok)
+ 	{
+-		MusicBrainz::Disc *disc = MusicBrainz::readDisc();
+-		std::string url = MusicBrainz::getSubmissionUrl(disc);
+-		delete disc;
+-
+-		KToolInvocation::invokeBrowser(QString::fromUtf8(url.c_str()));
++		QString url = QString::fromUtf8(discid_get_submission_url(m_discid));
++		KToolInvocation::invokeBrowser(url);
+ 	}
+-	catch (MusicBrainz::DiscError &e)
++	else
+ 	{
+-		kDebug() << "Error: " << e.what();
++		kDebug() << "Error: " << discid_get_error_msg(m_discid);
+ 	}
+ }
+-
+--- mbmanager.h.orig	2014-07-16 08:24:20 UTC
++++ mbmanager.h
+@@ -42,6 +42,9 @@
+ #include <qstring.h>
+ #include <qlist.h>
+ 
++// musicbrainz discid
++#include <discid/discid.h>
++
+ struct DiscInfo
+ {
+ 	QString Title;
+@@ -64,6 +67,7 @@ class MBManager : public QObject (private)
+ 	QList <MBTrackInfo> m_trackList;	/// List of tracks information
+ 
+ 	bool m_validInfo;					/// Tells whether the lookup query succeeded
++	DiscId *m_discid;
+ 
+ public:
+ 	MBManager();
+@@ -82,11 +86,11 @@ public slots:
+ 	void discLookup(const QString& device);
+ 
+ 	/** Uploads information */
+-	void discUpload();
++	void discUpload(const QString& device=QString());
+ 
+ signals:
+ 	void showArtistLabel(QString&);
+-	
++
+ 	void discLookupFinished();
+ };
+ 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807312111.w6VLBOcH039668>