Ticket #3154: mythmusic_isnewtune.diff
File mythmusic_isnewtune.diff, 2.4 KB (added by , 17 years ago) |
---|
-
mythmusic/mythmusic/cdrip.cpp
754 754 // static function to determin if there is already a similar track in the database 755 755 bool Ripper::isNewTune(const QString& artist, const QString& album, const QString& title) 756 756 { 757 758 QString matchartist = artist; 759 QString matchalbum = album; 760 QString matchtitle = title; 761 762 if (! matchartist.isEmpty()) 763 { 764 matchartist.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("_")); 765 } 766 767 if (! matchalbum.isEmpty()) 768 { 769 matchalbum.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("_")); 770 } 771 772 if (! matchtitle.isEmpty()) 773 { 774 matchtitle.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("_")); 775 } 776 757 777 MSqlQuery query(MSqlQuery::InitCon()); 758 778 QString queryString("SELECT filename, artist_name, album_name, name, song_id " 759 779 "FROM music_songs " 760 780 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 761 781 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 762 "WHERE artist_name REGEXP \'"); 763 QString token = artist; 764 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString(".")); 782 "WHERE artist_name LIKE :ARTIST " 783 "AND album_name LIKE :ALBUM " 784 "AND name LIKE :TITLE " 785 "ORDER BY artist_name, album_name, name, song_id, filename"); 765 786 766 queryString += token + "\' AND " + "album_name REGEXP \'";767 token = album;768 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));769 queryString += token + "\' AND " + "name REGEXP \'";770 token = title;771 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));772 queryString += token + "\' ORDER BY artist_name, album_name, name, song_id, filename";773 787 query.prepare(queryString); 774 788 789 query.bindValue(":ARTIST", matchartist); 790 query.bindValue(":ALBUM", matchalbum); 791 query.bindValue(":TITLE", matchtitle); 792 775 793 if (!query.exec() || !query.isActive()) 776 794 { 777 795 MythContext::DBError("Search music database", query);