# HG changeset patch # User Chris Cannam # Date 1446638772 0 # Node ID c8e291700c0eaa10c064dbf732ba0e72efa1f8a7 # Parent d649818fc24958a9017b7e15d01339d3bf83f0b4 Write Track in RDF only if title/artist metadata present, not simply on the basis of a TrackMetadata object existing diff -r d649818fc249 -r c8e291700c0e rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Wed Nov 04 10:07:29 2015 +0000 +++ b/rdf/RDFFeatureWriter.cpp Wed Nov 04 12:06:12 2015 +0000 @@ -352,7 +352,7 @@ bool wantTrack = (userSpecifiedTrack || (m_userMakerUri != "") || - (m_metadata.find(trackId) != m_metadata.end())); + haveTitleArtistMetadata(trackId)); // cerr << "wantTrack = " << wantTrack << " (userSpecifiedTrack = " // << userSpecifiedTrack << ", m_userMakerUri = " << m_userMakerUri << ", have metadata = " << (m_metadata.find(trackId) != m_metadata.end()) << ")" << endl; @@ -367,7 +367,7 @@ // including a Track would be to assert that this was one, // which is the one thing we wouldn't know... TrackMetadata tm; - if (m_metadata.find(trackId) != m_metadata.end()) { + if (haveTitleArtistMetadata(trackId)) { tm = m_metadata[trackId]; } stream << trackURI << " a mo:Track "; diff -r d649818fc249 -r c8e291700c0e rdf/RDFFeatureWriter.h --- a/rdf/RDFFeatureWriter.h Wed Nov 04 10:07:29 2015 +0000 +++ b/rdf/RDFFeatureWriter.h Wed Nov 04 12:06:12 2015 +0000 @@ -70,6 +70,19 @@ typedef map TrackMetadataMap; TrackMetadataMap m_metadata; + bool haveTitleArtistMetadata(QString trackId) const { + // Formerly in various places we used to test whether a track + // appeared in the metadata map at all, in order to determine + // whether it had any associated metadata. That won't work any + // more because metadata now includes duration, which can + // appear even if no title/artist are given and which is not + // something whose presence indicates the involvement of a + // "publication Track". So check for artist/title explicitly. + auto mitr = m_metadata.find(trackId); + if (mitr == m_metadata.end()) return false; + return (mitr->second.title != "" || mitr->second.maker != ""); + } + QString m_fixedEventTypeURI; virtual void reviewFileForAppending(QString filename);