[mythtv] [PATCH] MythMusic metadata duplication avoidance
Corey Mutter
mutterc at nc.rr.com
Thu Jan 22 09:32:52 EST 2004
I have a patch against MythMusic 0.13.
My music collection is a rat's nest of symbolic links, to provide
by-artist, by-CD, favorites, etc. organization. When MythMusic
scans this directory, it finds more than one of each song, and the
duplicates show up in playlists, etc.
This patch will keep MythMusic from inserting a row in the metadata
table if all of the metadata (except filename) matches an existing
entry. It would be nice to make this a config option but I don't yet
understand the codebase well enough to do that.
Corey
diff -u mythmusic-0.13/metadata.cpp mythmusic/metadata.cpp
--- mythmusic-0.13/metadata.cpp 2004-01-22 09:12:24.000000000 -0500
+++ mythmusic/metadata.cpp 2004-01-22 09:23:45.000000000 -0500
@@ -124,6 +124,22 @@
QString sqlfilename = filename;
sqlfilename.replace(QRegExp("\""), QString("\\\""));
+ // Don't update the database if a song with the exact same
+ // metadata is already there
+ QString checkquery = QString("SELECT filename FROM musicmetadata WHERE "
+ "( ( artist = \"%1\" ) AND "
+ "( album = \"%2\" ) AND ( title = \"%3\" ) "
+ "AND ( genre = \"%4\" ) AND "
+ "( year = \"%5\" ) AND ( tracknum = \"%6\" ) "
+ "AND ( length = \"%7\" ) );")
+ .arg(artist.latin1()).arg(album.latin1())
+ .arg(title.latin1()).arg(genre).arg(year)
+ .arg(tracknum).arg(length).arg(sqlfilename);
+ QSqlQuery query = db->exec(checkquery);
+ if (query.isActive() && query.numRowsAffected() > 0) {
+ return;
+ }
+
QString thequery = QString("INSERT INTO musicmetadata (artist,album,title,"
"genre,year,tracknum,length,filename) VALUES "
"(\"%1\",\"%2\",\"%3\",\"%4\",%5,%6,%7,\"%8\");")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040122/20fa79b1/attachment.pgp
More information about the mythtv-dev
mailing list