Ticket #1699: changes.4.1-4.2.patch

File changes.4.1-4.2.patch, 53.2 KB (added by Colin Guthrie <mythtv@…>, 15 years ago)

Additional fixes to be applied after changes.4.1.patch

  • mythmusic/mythmusic/cdrip.cpp

    Only in mythplugins/mythmusic: core.7798
    Only in mythplugins/mythmusic/i18n: dummy.o
    Only in mythplugins/mythmusic/i18n: i18n
    Only in mythplugins/mythmusic/i18n: Makefile
    Only in mythplugins/mythmusic: Makefile
    Only in mythplugins/mythmusic/mythmusic: avfdecoder.o
    Only in mythplugins/mythmusic/mythmusic: bumpscope.o
    Only in mythplugins/mythmusic/mythmusic: cddecoder.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/cdrip.cpp mythplugins/mythmusic/mythmusic/cdrip.cpp
    old new  
    284284    if (gContext->GetNumSetting("OnlyImportNewMusic",1))
    285285    {
    286286        MSqlQuery query(MSqlQuery::InitCon()); 
    287         QString queryString("SELECT filename, artist, album, title, intid "
    288                             "FROM musicmetadata WHERE artist REGEXP \'");     
    289         QString token = artist;
     287        QString queryString("SELECT filename, artist_name, album_name, name, song_id "
     288                            "FROM music_songs "
     289                            "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     290                            "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     291                            "WHERE artist_name REGEXP \'");     
     292        QString token = artist;
    290293        token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));
    291294     
    292         queryString += token + "\' AND " + "album REGEXP \'";
     295        queryString += token + "\' AND " + "album_name REGEXP \'";
    293296        token = album;
    294297        token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));
    295         queryString += token + "\' AND " + "title    REGEXP \'";
     298        queryString += token + "\' AND " + "name    REGEXP \'";
    296299        token = title;
    297300        token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));
    298         queryString += token + "\' ORDER BY artist, album, title, intid, filename";     
     301        queryString += token + "\' ORDER BY artist_name, album_name, name, song_id, filename";     
    299302        query.prepare(queryString);
    300303       
    301304        bool has_entries = true;     
     
    524527    delete decoder;
    525528}
    526529
    527 void Ripper::fillComboBox(MythComboBox &box, const QString &db_column)
     530void Ripper::fillComboBox(MythComboBox &box, const QString &field)
    528531{
    529     QString querystr = QString("SELECT DISTINCT %1 FROM musicmetadata;")
    530                                .arg(db_column);
    531      
    532532    MSqlQuery query(MSqlQuery::InitCon());
    533     query.exec(querystr);
     533    if ("artist" == field || "compilation_artist" == field)
     534    {
     535        query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;");
     536    }
     537    else if ("album" == field)
     538    {
     539        query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;");
     540    }
     541    else if ("title" == field)
     542    {
     543        query.prepare("SELECT name FROM music_songs ORDER BY name;");
     544    }
     545    else if ("genre" == field)
     546    {
     547        query.prepare("SELECT genre FROM music_genres ORDER BY genre;");
     548    }
     549    else
     550    {
     551        return;
     552    }
     553
     554    query.exec();
    534555   
    535556    QValueList<QString> list;
    536557   
  • mythmusic/mythmusic/dbcheck.cpp

    Only in mythplugins/mythmusic/mythmusic: cdrip.cpp~
    Only in mythplugins/mythmusic/mythmusic: cdrip.o
    Only in mythplugins/mythmusic/mythmusic: databasebox.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/dbcheck.cpp mythplugins/mythmusic/mythmusic/dbcheck.cpp
    old new  
    326326   
    327327   
    328328        if (dbver == "1005")
    329             {
     329        {
    330330            const QString updates[] = {
    331 "DROP TABLE musicmetadata;",
    332 "DROP TABLE musicplaylist;",
    333 "CREATE TABLE music_albums (album_id int(11) NOT NULL auto_increment, album_name varchar(255) NOT NULL default '', album_art text NOT NULL, PRIMARY KEY  (album_id));",
    334 "CREATE TABLE music_artists (artist_id int(11) NOT NULL auto_increment, artist_name varchar(255) default NULL, PRIMARY KEY  (artist_id));",
    335 "CREATE TABLE music_currentsong (song_id int(11) NOT NULL default '0', pl_id int(11) NOT NULL default '0', random tinyint(3) NOT NULL default '0');",
    336 "CREATE TABLE music_genres (genre_id int(11) NOT NULL auto_increment, genre varchar(25) NOT NULL default '', PRIMARY KEY  (genre_id));",
    337 "CREATE TABLE music_playhistory (play_id int(11) NOT NULL auto_increment, song_id int(11) default NULL, date_played datetime default NULL, PRIMARY KEY  (play_id));",
    338 "CREATE TABLE music_playlist (pl_id int(11) NOT NULL auto_increment, song_id int(11) default NULL, PRIMARY KEY  (pl_id));",
    339 "CREATE TABLE music_saved_playlists (playlist_id int(11) NOT NULL auto_increment, playlist_name varchar(255) default NULL, playlist_songs text, date_created datetime default NULL, time int(11) default NULL, songcount smallint(8) default NULL, hostname VARCHAR(255), PRIMARY KEY (playlist_id));",
    340 "CREATE TABLE music_songs (song_id int(11) NOT NULL auto_increment, artist_id int(11) NOT NULL default '0', compilationartist_id int(11) NOT NULL default '0', album_id int(11) NOT NULL default '0', genre_id int(11) NOT NULL default '0', year smallint(6) NOT NULL default '0', lastplay datetime default NULL, date_entered datetime default NULL, date_modified datetime default NULL, name varchar(255) default NULL, track smallint(6) NOT NULL default '0', length int(11) NOT NULL default '0', size int(11) NOT NULL default '0', bitrate int(11) NOT NULL default '0', type varchar(4) default NULL, numplays int(11) NOT NULL default '0', rating tinyint(4) NOT NULL default '0', filename text, format varchar(4) NOT NULL default '0', compilation tinyint default 0, PRIMARY KEY  (song_id));",
    341 "CREATE TABLE music_stats (num_artists smallint(5) unsigned NOT NULL default '0', num_albums smallint(5) unsigned NOT NULL default '0', num_songs mediumint(8) unsigned NOT NULL default '0', num_genres tinyint(3) unsigned NOT NULL default '0', total_time varchar(12) NOT NULL default '0', total_size varchar(10) NOT NULL default '0');",
     331"CREATE TABLE music_albums ("
     332"    album_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     333"    album_name varchar(255) NOT NULL default '',"
     334"    album_art text NOT NULL default '',"
     335"    INDEX idx_album_name(album_name)"
     336");",
     337"CREATE TABLE music_artists ("
     338"    artist_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     339"    artist_name varchar(255) NOT NULL default '',"
     340"    INDEX idx_artist_name(artist_name)"
     341");",
     342"CREATE TABLE music_currentsong ("
     343"    song_id int(11) unsigned NOT NULL default '0',"
     344"    pl_id int(11) unsigned NOT NULL default '0',"
     345"    random tinyint(3) NOT NULL default '0'"
     346");",
     347"CREATE TABLE music_genres ("
     348"    genre_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     349"    genre varchar(25) NOT NULL default '',"
     350"    INDEX idx_genre(genre)"
     351");",
     352"CREATE TABLE music_playhistory ("
     353"    play_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     354"    song_id int(11) unsigned NOT NULL default '0',"
     355"    date_played datetime default NULL"
     356");",
     357"CREATE TABLE music_playlist ("
     358"    pl_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     359"    song_id int(11) unsigned NOT NULL default '0'"
     360");",
     361"CREATE TABLE music_saved_playlists ("
     362"    playlist_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     363"    playlist_name varchar(255) NOT NULL default '',"
     364"    playlist_songs text NOT NULL default '',"
     365"    date_created datetime default NULL,"
     366"    time int(11) default NULL,"
     367"    songcount smallint(8) unsigned NOT NULL default '',"
     368"    hostname VARCHAR(255) NOT NULL default ''"
     369");",
     370"CREATE TABLE music_songs ("
     371"    song_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
     372"    artist_id int(11) unsigned NOT NULL default '0',"
     373"    compilationartist_id int(11) unsigned NOT NULL default '0',"
     374"    album_id int(11) unsigned NOT NULL default '0',"
     375"    genre_id int(11) unsigned NOT NULL default '0',"
     376"    year smallint(6) NOT NULL default '0',"
     377"    lastplay datetime default NULL,"
     378"    date_entered datetime default NULL,"
     379"    date_modified datetime default NULL,"
     380"    name varchar(255) NOT NULL default '',"
     381"    track smallint(6) unsigned NOT NULL default '0',"
     382"    length int(11) unsigned NOT NULL default '0',"
     383"    size int(11) unsigned NOT NULL default '0',"
     384"    bitrate int(11) unsigned NOT NULL default '0',"
     385"    type varchar(4) default NULL,"
     386"    numplays int(11) unsigned NOT NULL default '0',"
     387"    rating tinyint(4) unsigned NOT NULL default '0',"
     388"    filename text NOT NULL default '',"
     389"    format varchar(4) NOT NULL default '0',"
     390"    compilation tinyint(1) unsigned NOT NULL default '0',"
     391"    mythdigest VARCHAR(255),"
     392"    description VARCHAR(255),"
     393"    comment VARCHAR(255),"
     394"    disc_count SMALLINT(5) UNSIGNED DEFAULT '0',"
     395"    disc_number SMALLINT(5) UNSIGNED DEFAULT '0',"
     396"    track_count SMALLINT(5) UNSIGNED DEFAULT '0',"
     397"    start_time INT(10) UNSIGNED DEFAULT '0',"
     398"    stop_time INT(10) UNSIGNED,"
     399"    eq_preset VARCHAR(255),"
     400"    relative_volume TINYINT DEFAULT '0',"
     401"    bpm SMALLINT(5) UNSIGNED,"
     402//   The following field is temporary for schema conversion and is removed in a later query.
     403"    compilation_artist VARCHAR(128) NOT NULL,"
     404"    INDEX idx_tmp(compilation_artist),"
     405//   The rest is standard
     406"    INDEX idx_name(name),"
     407"    INDEX idx_mythdigest(mythdigest)"
     408");",
     409"CREATE TABLE music_stats ("
     410"    num_artists smallint(5) unsigned NOT NULL default '0',"
     411"    num_albums smallint(5) unsigned NOT NULL default '0',"
     412"    num_songs mediumint(8) unsigned NOT NULL default '0',"
     413"    num_genres tinyint(3) unsigned NOT NULL default '0',"
     414"    total_time varchar(12) NOT NULL default '0',"
     415"    total_size varchar(10) NOT NULL default '0'"
     416");",
    342417"RENAME TABLE smartplaylist TO music_smartplaylist;",
    343418"RENAME TABLE smartplaylistitem TO music_smartplaylistitem;",
    344419"RENAME TABLE smartplaylistcategory TO music_smartplaylistcategory;",
     420// Run necessary SQL to migrate the table structure
     421"INSERT INTO music_artists (artist_name) SELECT DISTINCT artist FROM musicmetadata;",
     422"INSERT INTO music_albums (album_name) SELECT DISTINCT album FROM musicmetadata;",
     423"INSERT INTO music_genres (genre) SELECT DISTINCT genre FROM musicmetadata;",
     424"INSERT INTO music_songs "
     425"   (song_id, artist_id, compilationartist_id, album_id, genre_id, year, lastplay,"
     426"    date_entered, date_modified, name, track, length, size, numplays,"
     427"    rating, filename, compilation, compilation_artist)"
     428"  SELECT intid, ma.artist_id, 0, mb.album_id, mg.genre_id, year, lastplay,"
     429"         date_added, date_modified, title, tracknum, length, IFNULL(size,0), playcount,"
     430"         rating, filename, compilation, compilation_artist"
     431"  FROM musicmetadata AS mmd, music_artists AS ma, music_albums AS mb, music_genres AS mg"
     432"  WHERE mmd.artist=ma.artist_name AND mmd.album=mb.album_name AND mmd.genre=mg.genre;",
     433"UPDATE music_songs AS ms, music_artists AS ma "
     434"  SET ms.compilationartist_id=ma.artist_id, compilation_artist=''"
     435"  WHERE ms.compilation_artist=ma.artist_name;",
     436"INSERT INTO music_artists (artist_name)"
     437"  SELECT DISTINCT compilation_artist FROM music_songs"
     438"  WHERE compilation_artist <> '';",
     439"UPDATE music_songs AS ms,music_artists AS ma"
     440"  SET ms.compilationartist_id=ma.artist_id, compilation_artist=''"
     441"  WHERE ms.compilation_artist=ma.artist_name;",
     442"ALTER TABLE music_songs DROP COLUMN compilation_artist;",
     443"INSERT INTO music_saved_playlists"
     444"  (playlist_name,playlist_songs,date_created,hostname)"
     445"  SELECT name AS playlist_name, songlist AS playlist_songs,NOW() AS date_created,hostname"
     446"  FROM musicplaylist;",
     447//"DROP TABLE musicmetadata;",
     448//"DROP TABLE musicplaylist;",
    345449""
    346450};
    347451        performActualUpdate(updates, "1006", dbver);
    348452    }
    349 
    350         if (dbver == "1006")
    351             {
    352             //Database Updates for use in the MFD
    353             const QString updates[] = {
    354 "ALTER TABLE music_songs ADD mythdigest      VARCHAR(255);",
    355 "ALTER TABLE music_songs ADD description     VARCHAR(255);",
    356 "ALTER TABLE music_songs ADD comment         VARCHAR(255);",
    357 "ALTER TABLE music_songs ADD disc_count      SMALLINT UNSIGNED DEFAULT 0;",
    358 "ALTER TABLE music_songs ADD disc_number     SMALLINT UNSIGNED DEFAULT 0;",
    359 "ALTER TABLE music_songs ADD track_count     SMALLINT UNSIGNED DEFAULT 0;",
    360 "ALTER TABLE music_songs ADD start_time      INT UNSIGNED DEFAULT 0;",
    361 "ALTER TABLE music_songs ADD stop_time       INT UNSIGNED;",
    362 "ALTER TABLE music_songs ADD eq_preset       VARCHAR(255);",
    363 "ALTER TABLE music_songs ADD relative_volume TINYINT DEFAULT 0;",
    364 "ALTER TABLE music_songs ADD bpm             SMALLINT UNSIGNED;",
    365 "ALTER TABLE music_songs ADD INDEX (mythdigest);",
    366 ""
    367 };
    368         performActualUpdate(updates, "1007", dbver);
    369     }
    370 
    371453}
    372454
  • mythmusic/mythmusic/editmetadata.cpp

    Only in mythplugins/mythmusic/mythmusic: dbcheck.cpp~
    Only in mythplugins/mythmusic/mythmusic: dbcheck.o
    Only in mythplugins/mythmusic/mythmusic: decoder.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/editmetadata.cpp mythplugins/mythmusic/mythmusic/editmetadata.cpp
    old new  
    368368{
    369369    searchList.clear();
    370370   
    371     QString querystr;
    372     querystr = QString("SELECT DISTINCT %1 FROM musicmetadata ORDER BY %2").arg(field).arg(field);
    373          
    374371    MSqlQuery query(MSqlQuery::InitCon());
    375     query.exec(querystr);
    376 
    377     if (query.isActive() && query.size())
     372    if ("artist" == field || "compilation_artist" == field)
     373    {
     374        query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;");
     375    }
     376    else if ("album" == field)
     377    {
     378        query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;");
     379    }
     380    else if ("title" == field)
     381    {
     382        query.prepare("SELECT name FROM music_songs ORDER BY name;");
     383    }
     384    else if ("genre" == field)
     385    {
     386        query.prepare("SELECT genre FROM music_genres ORDER BY genre;");
     387    }
     388    else
     389    {
     390        return;
     391    }
     392       
     393    if (query.exec() && query.isActive() && query.size())
    378394    {
    379395        while (query.next())
    380396        {
  • mythmusic/mythmusic/metadata.cpp

    Only in mythplugins/mythmusic/mythmusic: editmetadata.cpp~
    Only in mythplugins/mythmusic/mythmusic: editmetadata.o
    Only in mythplugins/mythmusic/mythmusic: encoder.o
    Only in mythplugins/mythmusic/mythmusic: filters.o
    Only in mythplugins/mythmusic/mythmusic: flacdecoder.o
    Only in mythplugins/mythmusic/mythmusic: flacencoder.o
    Only in mythplugins/mythmusic/mythmusic: genres.o
    Only in mythplugins/mythmusic/mythmusic: globalsettings.o
    Only in mythplugins/mythmusic/mythmusic: goom_core.o
    Only in mythplugins/mythmusic/mythmusic: graphic.o
    Only in mythplugins/mythmusic/mythmusic: ifs_display.o
    Only in mythplugins/mythmusic/mythmusic: ifs.o
    Only in mythplugins/mythmusic/mythmusic: lameencoder.o
    Only in mythplugins/mythmusic/mythmusic: libmythmusic.so
    Only in mythplugins/mythmusic/mythmusic: lines.o
    Only in mythplugins/mythmusic/mythmusic: maddecoder.o
    Only in mythplugins/mythmusic/mythmusic: main.o
    Only in mythplugins/mythmusic/mythmusic: mainvisual.o
    Only in mythplugins/mythmusic/mythmusic: Makefile
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/metadata.cpp mythplugins/mythmusic/mythmusic/metadata.cpp
    old new  
    100100    QString sqlfilename = filename.remove(0, m_startdir.length());
    101101
    102102    MSqlQuery query(MSqlQuery::InitCon());
    103     query.prepare("SELECT music_artists.artist_name, music_artists_1.artist_name AS compilation_artist, "
     103    query.prepare("SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
    104104                  "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
    105                   "music_songs.track, music_songs.length, music_songs.song_id, music_songs.rating, "
     105                  "music_songs.track, music_songs.length, music_songs.song_id, music_songs.rating, "
    106106                  "music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
    107                   "music_songs.format FROM (((music_songs INNER JOIN music_artists ON "
    108                   "music_songs.artist_id = music_artists.artist_id) INNER JOIN music_albums ON "
    109                   "music_songs.album_id = music_albums.album_id) INNER JOIN music_genres ON "
    110                   "music_songs.genre_id = music_genres.genre_id) INNER JOIN music_artists AS "
    111                   "music_artists_1 ON music_albums.artist_id = music_artists_1.artist_id WHERE "
    112                   "(((music_songs.filename)= :FILENAME ));");
     107                  "music_songs.format "
     108                  "FROM music_songs "
     109                  "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     110                  "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
     111                  "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     112                  "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
     113                  "WHERE music_songs.filename = :FILENAME ;");
    113114    query.bindValue(":FILENAME", sqlfilename.utf8());
    114115
    115116    if (query.exec() && query.isActive() && query.size() > 0)
     
    155156    // Don't update the database if a song with the exact same
    156157    // metadata is already there
    157158    MSqlQuery query(MSqlQuery::InitCon());
    158     query.prepare("SELECT music_songs.filename FROM (((music_songs "
    159                   "INNER JOIN music_artists ON music_songs.artist_id = "
    160                   "music_artists.artist_id) INNER JOIN music_albums ON "
    161                   "music_songs.album_id = music_albums.album_id) INNER "
    162                   "JOIN music_artists AS music_artists_1 ON music_albums.compilationartist_id "
    163                   "= music_artists_1.artist_id) INNER JOIN music_genres ON "
    164                   "music_songs.genre_id = music_genres.genre_id WHERE "
    165                   "(((music_artists.artist_name)=:ARTIST) AND "
    166                   "((music_artists_1.artist_id)=:COMPILATION_ARTIST) "
    167                   "AND ((music_albums.album_name)=:ALBUM) AND "
    168                   "((music_songs.name)=:TITLE) AND "
    169                   "((music_genres.genre)=:GENRE) AND ((music_songs.year)=:YEAR) "
    170                   "AND ((music_songs.track)=:TRACKNUM) AND "
    171                   "((music_songs.length)=:LENGTH) AND "
    172                   "((music_songs.format)=:FORMAT));");
     159    query.prepare("SELECT music_songs.filename "
     160                  "FROM music_songs "
     161                  "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     162                  "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
     163                  "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     164                  "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
     165                  "WHERE music_artists.artist_name = :ARTIST"
     166                  " AND music_comp_artists.artist_name = :COMPILATION_ARTIST"
     167                  " AND music_albums.album_name = :ALBUM"
     168                  " AND music_songs.name = :TITLE"
     169                  " AND music_genres.genre = :GENRE"
     170                  " AND music_songs.year = :YEAR"
     171                  " AND music_songs.track = :TRACKNUM"
     172                  " AND music_songs.length = :LENGTH"
     173                  " AND music_songs.format = :FORMAT ;");
    173174   
    174175    query.bindValue(":ARTIST", artist.utf8());
    175176    query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8());
     
    184185    if (query.exec() && query.isActive() && query.size() > 0)
    185186        return;
    186187
    187 //Genrecheck
    188 //Albumcheck
    189 //Artist
    190     int ArtistID;
    191     query.prepare("SELECT music_artists.artist_id FROM music_artists "
    192                   " WHERE (((music_artists.artist_name)=:ARTIST));");
     188    // Load the artist id or insert it and get the id
     189    unsigned int artistId;
     190    query.prepare("SELECT artist_id FROM music_artists "
     191                  "WHERE artist_name = :ARTIST ;");
    193192    query.bindValue(":ARTIST", artist.utf8());
    194     query.exec();
    195 //    cout << query.executedQuery() << endl;
     193
     194    if (!query.exec() || !query.isActive())
     195    {
     196        MythContext::DBError("music select artist id", query);
     197        return;
     198    }
    196199    if (query.size() > 0)
    197         {
    198         query.next();
    199         ArtistID = query.value(0).toInt();
    200         }
     200    {
     201        query.next();
     202        artistId = query.value(0).toInt();
     203    }
    201204    else
    202         {
    203         query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);");
    204         query.bindValue(":ARTIST", artist.utf8());
    205         query.exec();
    206 //      cout << query.executedQuery() << endl;
    207         query.prepare("SELECT music_artists.artist_id FROM music_artists "
    208                   " WHERE (((music_artists.artist_name)=:ARTIST));");
    209         query.bindValue(":ARTIST", artist.utf8());
    210         query.exec();
    211 //      cout << query.executedQuery() << endl;
    212         query.next();
    213         ArtistID = query.value(0).toInt();     
    214         }
    215 
    216 //Compilation Artist   
    217     int CoArtistID;
    218     query.prepare("SELECT music_artists.artist_id FROM music_artists "
    219                   " WHERE (((music_artists.artist_name)=:ARTIST));");
     205    {
     206        query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);");
     207        query.bindValue(":ARTIST", artist.utf8());
     208
     209        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
     210        {
     211            MythContext::DBError("music insert artist", query);
     212            return;
     213        }
     214        artistId = query.lastInsertId().toInt();
     215    }
     216
     217    // Compilation Artist       
     218    unsigned int compilationArtistId;
     219    query.prepare("SELECT artist_id FROM music_artists "
     220                  "WHERE artist_name = :ARTIST ;");
    220221    query.bindValue(":ARTIST", compilation_artist.utf8());
    221     query.exec();
    222 //    cout << query.executedQuery() << endl;
     222    if (!query.exec() || !query.isActive())
     223    {
     224        MythContext::DBError("music select compilation artist id", query);
     225        return;
     226    }
    223227    if (query.size() > 0)
    224         {
    225         query.next();
    226         CoArtistID = query.value(0).toInt();
    227         }
     228    {
     229        query.next();
     230        compilationArtistId = query.value(0).toInt();
     231    }
    228232    else
    229         {
    230         query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);");
    231         query.bindValue(":ARTIST", compilation_artist.utf8());
    232         query.exec();
    233 //      cout << query.executedQuery() << endl;
    234         query.prepare("SELECT music_artists.artist_id FROM music_artists "
    235                   " WHERE (((music_artists.artist_name)=:ARTIST));");
    236         query.bindValue(":ARTIST", compilation_artist.utf8());
    237         query.exec();
    238 //      cout << query.executedQuery() << endl;
    239         query.next();
    240         CoArtistID = query.value(0).toInt();   
    241         }
    242 
    243 //Album
    244     int AlbumID;
    245     query.prepare("SELECT music_albums.album_id FROM music_albums "
    246                   " WHERE (((music_albums.album_name)=:ALBUM));");
     233    {
     234        query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);");
     235        query.bindValue(":ARTIST", compilation_artist.utf8());
     236
     237        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
     238        {
     239            MythContext::DBError("music insert compilation artist", query);
     240            return;
     241        }
     242        compilationArtistId = query.lastInsertId().toInt();
     243    }
     244
     245    // Album
     246    unsigned int albumId;
     247    query.prepare("SELECT album_id FROM music_albums "
     248                  "WHERE album_name = :ALBUM ;");
    247249    query.bindValue(":ALBUM", album.utf8());
    248     query.exec();
    249 //    cout << query.executedQuery() << endl;
     250    if (!query.exec() || !query.isActive())
     251    {
     252        MythContext::DBError("music select album id", query);
     253        return;
     254    }
    250255    if (query.size() > 0)
    251         {
    252         query.next();
    253         AlbumID = query.value(0).toInt();
    254         }
     256    {
     257        query.next();
     258        albumId = query.value(0).toInt();
     259    }
    255260    else
    256         {
     261    {
    257262        query.prepare("INSERT INTO music_albums (album_name) VALUES (:ALBUM);");
    258263        query.bindValue(":ALBUM", album.utf8());
    259         query.exec();
    260 //      cout << query.executedQuery() << endl;
    261        
    262         query.prepare("SELECT music_albums.album_id FROM music_albums "
    263                   " WHERE (((music_albums.album_name)=:ALBUM));");
    264         query.bindValue(":ALBUM", album.utf8());
    265         query.exec();
    266 //      cout << query.executedQuery() << endl;
    267         query.next();
    268 
    269         AlbumID = query.value(0).toInt();       
    270         }
    271 
    272 //Genres
    273     int GenreID;
    274     query.prepare("SELECT music_genres.genre_id FROM music_genres "
    275                   " WHERE (((music_genres.genre)=:GENRE));");
     264
     265        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
     266        {
     267            MythContext::DBError("music insert album", query);
     268            return;
     269        }
     270        albumId = query.lastInsertId().toInt();
     271    }
     272
     273    // Genres
     274    unsigned int genreId;
     275    query.prepare("SELECT genre_id FROM music_genres "
     276                  "WHERE genre = :GENRE ;");
    276277    query.bindValue(":GENRE", genre.utf8());
    277     query.exec();
    278 //    cout << query.executedQuery() << endl;
     278    if (!query.exec() || !query.isActive())
     279    {
     280        MythContext::DBError("music select genre id", query);
     281        return;
     282    }
    279283    if (query.size() > 0)
    280         {
    281         query.next();
    282         GenreID = query.value(0).toInt();
    283         }
     284    {
     285        query.next();
     286        genreId = query.value(0).toInt();
     287    }
    284288    else
    285         {
    286         query.prepare("INSERT INTO music_genres (genre) VALUES (:GENRE);");
    287         query.bindValue(":GENRE", genre.utf8());
    288         query.exec();
    289 //        cout << query.executedQuery() << endl;
    290        
    291         query.prepare("SELECT music_genres.genre_id FROM music_genres "
    292                   " WHERE (((music_genres.genre)=:GENRE));");
    293         query.bindValue(":GENRE", genre.utf8());
    294         query.exec();
    295 //      cout << query.executedQuery() << endl;
    296         query.next();
    297         GenreID = query.value(0).toInt();       
    298         }
    299 
    300 //Song hinzufgen
    301 
    302    query.prepare("INSERT INTO music_songs "
    303                   "(artist_id,   album_id, compilationartist_id,     name,  "
    304                   " genre_id,    year,               track,   length, "
    305                   " filename, compilation,        date_entered, date_modified, "
    306                   " format, size, bitrate ) "
     289    {
     290        query.prepare("INSERT INTO music_genres (genre) VALUES (:GENRE);");
     291        query.bindValue(":GENRE", genre.utf8());
     292
     293        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
     294        {
     295            MythContext::DBError("music insert genre", query);
     296            return;
     297        }
     298        genreId = query.lastInsertId().toInt();
     299    }
     300
     301    // We have all the id's now. We can insert it.
     302    query.prepare("INSERT INTO music_songs "
     303                  "  (artist_id, album_id,     compilationartist_id, name,"
     304                  "   genre_id,  year,         track,                length,"
     305                  "   filename,  compilation,  date_entered,         date_modified,"
     306                  "   format,    size,         bitrate) "
    307307                  "VALUES "
    308                   "(:ARTIST,  :ALBUM, :COMPILATION_ARTIST,    :TITLE,   "
    309                   " :GENRE,   :YEAR,              :TRACKNUM,  :LENGTH,  "
    310                   " :FILENAME,:COMPILATION,       :DATE_ADDED,:DATE_MOD,"
    311                   " :FORMAT, :FILESIZE, :BITRATE)");
    312     query.bindValue(":ARTIST", ArtistID);
    313     query.bindValue(":COMPILATION_ARTIST", CoArtistID);
    314     query.bindValue(":ALBUM", AlbumID);
     308                  "  (:ARTIST,   :ALBUM,       :COMPILATION_ARTIST,  :TITLE,"
     309                  "   :GENRE,    :YEAR,        :TRACKNUM,            :LENGTH,"
     310                  "   :FILENAME, :COMPILATION, :DATE_ADDED,          :DATE_MOD,"
     311                  "   :FORMAT,   :FILESIZE,    :BITRATE)"
     312                  );
     313
     314    query.bindValue(":ARTIST", artistId);
     315    query.bindValue(":COMPILATION_ARTIST", compilationArtistId);
     316    query.bindValue(":ALBUM", albumId);
    315317    query.bindValue(":TITLE", title.utf8());
    316     query.bindValue(":GENRE", GenreID);
     318    query.bindValue(":GENRE", genreId);
    317319    query.bindValue(":YEAR", year);
    318320    query.bindValue(":TRACKNUM", tracknum);
    319321    query.bindValue(":LENGTH", length);
     
    327329   
    328330   
    329331    query.exec();
    330 //    cout << query.executedQuery() << endl;
    331     // easiest way to ensure we've got 'id' filled.
    332     fillData();
     332
     333    if (query.isActive() && 1 == query.numRowsAffected())
     334        id = query.lastInsertId().toInt();
    333335}
    334336
    335337// Default values for formats
     
    562564    if (title == "")
    563565        return;
    564566
    565 //    QString thequery = "SELECT artist,compilation_artist,album,title,genre,year,tracknum,length,"
    566 //                       "filename,song_id,rating,playcount,lastplay,compilation,format "
    567 //                       "FROM musicmetadata WHERE title = :TITLE";
    568     QString thequery = "SELECT music_artists.artist_name, music_artists_1.artist_name AS compilation_artist, "
    569                        "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
    570                        "music_songs.track, music_songs.length, music_songs.filename, music_songs.song_id, "
    571                        "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
    572                        "music_songs.format FROM music_artists AS music_artists_1 INNER JOIN (((music_songs INNER "
    573                        "JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN "
    574                        "music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN "
    575                        "music_genres ON music_songs.genre_id = music_genres.genre_id) ON "
    576                        "music_artists_1.artist_id = music_songs.compilationartist_id WHERE name = :TITLE";
     567    QString thequery =  "SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
     568                        "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
     569                        "music_songs.track, music_songs.length, music_songs.filename, music_songs.song_id, "
     570                        "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
     571                        "music_songs.format "
     572                        "FROM music_songs "
     573                        "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     574                        "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
     575                        "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     576                        "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
     577                        "WHERE music_songs.name = :TITLE";
    577578
    578579    if (album != "")
    579         thequery += " AND album_name = :ALBUM";
     580        thequery += " AND music_albums.album_name = :ALBUM";
    580581    if (artist != "")
    581         thequery += " AND artist_name = :ARTIST";
     582        thequery += " AND music_artists.artist_name = :ARTIST";
    582583    if (compilation_artist != "")
    583         thequery += " AND compilation_artist = :COMPILATION_ARTIST";
     584        thequery += " AND music_comp_artists.artist_name = :COMPILATION_ARTIST";
    584585
    585586    thequery += ";";
    586587
     
    622623        return;
    623624       
    624625    MSqlQuery query(MSqlQuery::InitCon());
    625 //    query.prepare("SELECT title,artist,compilation_artist,album,title,genre,year,tracknum,"
    626 //                  "length,filename,rating,playcount,lastplay,compilation,format FROM "
    627 //                  "musicmetadata WHERE song_id = :ID ;");
    628     query.prepare("SELECT music_songs.name, music_artists.artist_name, music_artists_1.artist_name AS "
    629                   "compilation_artist, music_albums.album_name, music_genres.genre, music_songs.year, "
    630                   "music_songs.track, music_songs.length, music_songs.filename, music_songs.rating, "
    631                   "music_songs.numplays, music_songs.lastplay, music_songs.compilation, music_songs.format "
    632                   "FROM music_artists AS music_artists_1 INNER JOIN (((music_songs INNER JOIN music_artists "
    633                   "ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_albums ON "
    634                   "music_songs.album_id = music_albums.album_id) INNER JOIN music_genres ON "
    635                   "music_songs.genre_id = music_genres.genre_id) ON music_artists_1.artist_id = "
    636                   "music_songs.compilationartist_id WHERE (((music_songs.song_id) = :ID ));");           
     626    query.prepare("SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
     627                  "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
     628                  "music_songs.track, music_songs.length, music_songs.filename, "
     629                  "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
     630                  "music_songs.format "
     631                  "FROM music_songs "
     632                  "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     633                  "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
     634                  "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     635                  "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
     636                  "WHERE music_songs.song_id = :ID;");           
    637637    query.bindValue(":ID", id);
    638638       
    639639    if (query.exec() && query.isActive() && query.numRowsAffected() > 0)
    640640    {
    641641        query.next();
    642642
    643         title = QString::fromUtf8(query.value(0).toString());
    644         artist = QString::fromUtf8(query.value(1).toString());
    645         compilation_artist = QString::fromUtf8(query.value(2).toString());
    646         album = QString::fromUtf8(query.value(3).toString());
     643        artist = QString::fromUtf8(query.value(0).toString());
     644        compilation_artist = QString::fromUtf8(query.value(1).toString());
     645        album = QString::fromUtf8(query.value(2).toString());
     646        title = QString::fromUtf8(query.value(3).toString());
    647647        genre = QString::fromUtf8(query.value(4).toString());
    648648        year = query.value(5).toInt();
    649649        tracknum = query.value(6).toInt();
     
    796796void AllMusic::resync()
    797797{
    798798    done_loading = false;
    799 //    QString aquery =    "SELECT song_id, artist, compilation_artist, album, title, genre, "
    800 //                        "year, tracknum, length, filename, rating, "
    801 //                        "lastplay, playcount, compilation, format "
    802 //                        "FROM music_songs "
    803 //                        "ORDER BY song_id;";
    804 
    805     QString aquery =    "SELECT music_songs.song_id, music_artists.artist_name, "
    806                         "music_artists_1.artist_name AS compilation_artist, music_albums.album_name, "
    807                         "music_songs.name, music_genres.genre, music_songs.year, music_songs.track, "
    808                         "music_songs.length, music_songs.filename, music_songs.rating, "
    809                         "music_songs.lastplay, music_songs.numplays, music_songs.compilation, "
    810                         "music_songs.format, music_songs.bitrate, music_songs.size FROM music_artists AS music_artists_1 INNER JOIN "
    811                         "(((music_songs INNER JOIN music_artists ON music_songs.artist_id = "
    812                         "music_artists.artist_id) INNER JOIN music_genres ON music_songs.genre_id = "
    813                         "music_genres.genre_id) INNER JOIN music_albums ON music_songs.album_id = "
    814                         "music_albums.album_id) ON music_artists_1.artist_id = "
    815                         "music_songs.compilationartist_id ORDER BY music_songs.song_id;";
    816799
     800    QString aquery = "SELECT music_songs.song_id, music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
     801                     "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
     802                     "music_songs.track, music_songs.length, music_songs.filename, "
     803                     "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
     804                     "music_songs.format, music_songs.bitrate, music_songs.size "
     805                     "FROM music_songs "
     806                     "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     807                     "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
     808                     "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     809                     "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
     810                     "ORDER BY music_songs.song_id;";
    817811
    818812    QString filename, artist, album, title;
    819813
     
    857851                query.value(7).toInt(),
    858852                query.value(8).toInt(),
    859853                query.value(0).toInt(),
    860                 query.value(10).toInt(),
     854                query.value(11).toInt(),
    861855                query.value(12).toInt(),
    862                 query.value(15).toInt(), //bitrate
    863                 query.value(16).toInt(), //filesize
    864                 query.value(11).toString(),
     856                query.value(15).toInt(), //bitrate
     857                query.value(16).toInt(), //filesize
     858                query.value(10).toString(),
    865859                (query.value(13).toInt() > 0),
    866860                query.value(14).toString());
    867861           
  • mythmusic/mythmusic/playbackbox.cpp

    Only in mythplugins/mythmusic/mythmusic: metadata.cpp~
    Only in mythplugins/mythmusic/mythmusic: metadata.o
    Only in mythplugins/mythmusic/mythmusic: metaioavfcomment.o
    Only in mythplugins/mythmusic/mythmusic: metaioflacvorbiscomment.o
    Only in mythplugins/mythmusic/mythmusic: metaioid3v2.o
    Only in mythplugins/mythmusic/mythmusic: metaio_libid3hack.o
    Only in mythplugins/mythmusic/mythmusic: metaio.o
    Only in mythplugins/mythmusic/mythmusic: metaiooggvorbiscomment.o
    Only in mythplugins/mythmusic/mythmusic: moc_cdrip.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_cdrip.o
    Only in mythplugins/mythmusic/mythmusic: moc_databasebox.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_databasebox.o
    Only in mythplugins/mythmusic/mythmusic: moc_editmetadata.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_editmetadata.o
    Only in mythplugins/mythmusic/mythmusic: moc_mainvisual.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_mainvisual.o
    Only in mythplugins/mythmusic/mythmusic: moc_playbackbox.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_playbackbox.o
    Only in mythplugins/mythmusic/mythmusic: moc_search.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_search.o
    Only in mythplugins/mythmusic/mythmusic: moc_smartplaylist.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_smartplaylist.o
    Only in mythplugins/mythmusic/mythmusic: moc_streaminput.cpp
    Only in mythplugins/mythmusic/mythmusic: moc_streaminput.o
    Only in mythplugins/mythmusic/mythmusic: mythgoom.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/playbackbox.cpp mythplugins/mythmusic/mythmusic/playbackbox.cpp
    old new  
    537537        return;
    538538
    539539   closePlaylistPopup();
    540    updatePlaylistFromQuickPlaylist("ORDER BY artist, album, tracknum");
     540   updatePlaylistFromQuickPlaylist("ORDER BY artist_name, album_name, track");
    541541}
    542542
    543543void PlaybackBoxMusic::fromCD()
     
    593593        return;
    594594
    595595    QString value = formattedFieldValue(curMeta->Artist().utf8());
    596     QString whereClause = "WHERE artist = " + value +
    597                           " ORDER BY album, tracknum";
     596    QString whereClause = "WHERE artist_name = " + value +
     597                          " ORDER BY album_name, track";
    598598
    599599    closePlaylistPopup();
    600600    updatePlaylistFromQuickPlaylist(whereClause);
     
    606606        return;
    607607
    608608    QString value = formattedFieldValue(curMeta->Album().utf8());
    609     QString whereClause = "WHERE album = " + value +
    610                           " ORDER BY tracknum";
     609    QString whereClause = "WHERE album_name = " + value +
     610                          " ORDER BY track";
    611611    closePlaylistPopup();
    612612    updatePlaylistFromQuickPlaylist(whereClause);
    613613}
     
    619619
    620620    QString value = formattedFieldValue(curMeta->Genre().utf8());
    621621    QString whereClause = "WHERE genre = " + value +
    622                           " ORDER BY artist, album, tracknum";   
     622                          " ORDER BY artist_name, album_name, track";   
    623623    closePlaylistPopup();
    624624    updatePlaylistFromQuickPlaylist(whereClause);
    625625}
     
    631631
    632632    QString value = formattedFieldValue(curMeta->Year());
    633633    QString whereClause = "WHERE year = " + value +
    634                           " ORDER BY artist, album, tracknum";
     634                          " ORDER BY artist_name, album_name, track";
    635635    closePlaylistPopup();
    636636    updatePlaylistFromQuickPlaylist(whereClause);
    637637}
  • mythmusic/mythmusic/playlist.cpp

    Only in mythplugins/mythmusic/mythmusic: playbackbox.cpp~
    Only in mythplugins/mythmusic/mythmusic: playbackbox.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/playlist.cpp mythplugins/mythmusic/mythmusic/playlist.cpp
    old new  
    326326    all_other_playlists->clear();
    327327
    328328    MSqlQuery query(MSqlQuery::InitCon());
    329     query.prepare("SELECT playlist_id FROM music_saved_playlists WHERE playlist_name != :DEFAULT AND playlist_name != :BACKUP ORDER BY playlist_id;");
     329    query.prepare("SELECT playlist_id FROM music_saved_playlists "
     330                  "WHERE playlist_name != :DEFAULT"
     331                  " AND playlist_name != :BACKUP "
     332                  "ORDER BY playlist_id;");
    330333    query.bindValue(":DEFAULT", "default_playlist_storage");
    331334    query.bindValue(":BACKUP", "backup_playlist_storage");
    332335
     
    467470
    468471    if (name == "default_playlist_storage" || name == "backup_playlist_storage")
    469472    {
    470         query.prepare("SELECT playlist_id, playlist_name, playlist_songs FROM "
    471                       "music_saved_playlists WHERE playlist_name = :NAME AND hostname = :HOST;");
     473        query.prepare("SELECT playlist_id, playlist_name, playlist_songs "
     474                      "FROM  music_saved_playlists "
     475                      "WHERE playlist_name = :NAME"
     476                      " AND hostname = :HOST;");
    472477        query.bindValue(":NAME", a_name);
    473478        query.bindValue(":HOST", a_host);
    474479    }
    475480    else
    476481    {
    477         query.prepare("SELECT playlist_id, playlist_name, playlist_songs FROM "
    478                       "music_saved_playlists WHERE playlist_name = :NAME;");
     482        query.prepare("SELECT playlist_id, playlist_name, playlist_songs "
     483                      "FROM music_saved_playlists "
     484                      "WHERE playlist_name = :NAME;");
    479485        query.bindValue(":NAME", a_name);
    480486    }
    481487
     
    503509void Playlist::loadPlaylistByID(int id, QString a_host)
    504510{
    505511    MSqlQuery query(MSqlQuery::InitCon());
    506     query.prepare("SELECT playlist_id, playlist_name, playlist_songs FROM "
    507                   "music_saved_playlists WHERE playlist_id = :ID;");
     512    query.prepare("SELECT playlist_id, playlist_name, playlist_songs "
     513                  "FROM music_saved_playlists "
     514                  "WHERE playlist_id = :ID;");
    508515    query.bindValue(":ID", id);
    509516//    query.bindValue(":HOST", a_host);
    510517
     
    607614
    608615    QString theQuery;
    609616
    610     theQuery = "SELECT song_id FROM music_songs ";
     617    theQuery = "SELECT song_id FROM music_songs "
     618               "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     619               "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     620               "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id ";
    611621
    612622    if (whereClause.length() > 0)
    613623      theQuery += whereClause;
     
    721731    QString orderBy;
    722732    int limitTo;
    723733   
    724     query.prepare("SELECT music_smartplaylistid, matchtype, orderby, limitto "
    725                   "FROM smartplaylist WHERE categoryid = :CATEGORYID AND name = :NAME;");
     734    query.prepare("SELECT smartplaylistid, matchtype, orderby, limitto "
     735                  "FROM music_smartplaylist WHERE categoryid = :CATEGORYID AND name = :NAME;");
    726736    query.bindValue(":NAME", name.utf8());
    727737    query.bindValue(":CATEGORYID", categoryID);
    728738       
  • mythmusic/mythmusic/search.cpp

    Only in mythplugins/mythmusic/mythmusic: playlist.cpp~
    Only in mythplugins/mythmusic/mythmusic: playlist.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/search.cpp mythplugins/mythmusic/mythmusic/search.cpp
    old new  
    6666
    6767void SearchDialog::runQuery(QString searchText)
    6868{
    69     // This method will perform a search in the 'musicmetadata' table and fill
     69    // This method will perform a search in the various music_* tables and fill
    7070    // the 'listbox' widget with the results.
    7171    // The following columns are searched: filename, artist, album, title.
    7272    // To facilitate usage with a remote, two search modes exist and
     
    103103
    104104    MSqlQuery query(MSqlQuery::InitCon());
    105105
    106     QString queryString("SELECT filename, artist, album, title, intid "
    107                         "FROM musicmetadata ");
     106    QString queryString("SELECT filename, artist_name, album_name, name, song_id "
     107                        "FROM music_songs "
     108                        "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     109                        "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id ");     
    108110
    109111    QStringList list = QStringList::split(QRegExp("[>,]"), searchText);
    110112    whereClause = "";
     
    117119                 QString stxt = list[i];
    118120                 whereClause += (i) ? " AND ( " : "WHERE (";
    119121                 whereClause +=
    120                     "filename LIKE '%" + stxt + "%' OR "
    121                     "artist  LIKE '%" + stxt + "%' OR "
    122                     "album    LIKE '%" + stxt + "%' OR "
    123                     "title    LIKE '%" + stxt + "%')";
     122                    "filename    LIKE '%" + stxt + "%' OR "
     123                    "artist_name LIKE '%" + stxt + "%' OR "
     124                    "album_name  LIKE '%" + stxt + "%' OR "
     125                    "name    LIKE '%" + stxt + "%')";
    124126             }
    125127             VERBOSE(VB_GENERAL, QString("alpha whereClause " + whereClause ));
    126128        }
     
    131133                QString stxt = list[i].stripWhiteSpace();
    132134                whereClause += (i) ? " AND ( " : "WHERE (";
    133135                whereClause +=
    134                     "filename REGEXP '" + stxt + "' OR "
    135                     "artist  REGEXP '" + stxt + "' OR "
    136                     "album    REGEXP '" + stxt + "' OR "
    137                     "title    REGEXP '" + stxt + "')";
     136                    "filename    REGEXP '" + stxt + "' OR "
     137                    "artist_name REGEXP '" + stxt + "' OR "
     138                    "album_name  REGEXP '" + stxt + "' OR "
     139                    "name        REGEXP '" + stxt + "')";
    138140            }
    139141            VERBOSE(VB_GENERAL,QString("numeric whereClause " + whereClause ));
    140142        }
    141143    }
    142144
    143145    queryString += whereClause;
    144     queryString += " ORDER BY artist, album, title, intid, filename ";
     146    queryString += " ORDER BY artist_name, album_name, name, song_id, filename ";
    145147
    146148    query.prepare(queryString);
    147149
     
    217219void SearchDialog::itemSelected(int i)
    218220{
    219221    unsigned int id = ((SearchListBoxItem*)listbox->item(i))->getId();
    220     whereClause = QString("WHERE intid='%1';").arg(id);
     222    whereClause = QString("WHERE song_id='%1';").arg(id);
    221223    done(0);
    222224}
    223225
  • mythmusic/mythmusic/smartplaylist.cpp

    Only in mythplugins/mythmusic/mythmusic: search.cpp~
    Only in mythplugins/mythmusic/mythmusic: search.o
    diff -u -r mythplugins.joggi-4.1/mythmusic/mythmusic/smartplaylist.cpp mythplugins/mythmusic/mythmusic/smartplaylist.cpp
    old new  
    3333static SmartPLField SmartPLFields[] =
    3434{
    3535    { "",              "",                               ftString,   0,    0,    0 },
    36     { "Artist",        "music_artists.artist_name",                         ftString,   0,    0,    0 },
    37     { "Album",         "album_name",                          ftString,   0,    0,    0 },
    38     { "Title",         "name",                          ftString,   0,    0,    0 },
    39     { "Genre",         "genre",                          ftString,   0,    0,    0 },
    40     { "Year",          "year",                           ftNumeric,  1900, 2099, 2000 },
    41     { "Track No.",     "track",                       ftNumeric,  0,    99,   0 },
    42     { "Rating",        "rating",                         ftNumeric,  0,    10,   0 },
    43     { "Play Count",    "numplays",                      ftNumeric,  0,    9999, 0 },
    44     { "Compilation",   "compilation",                    ftBoolean,  0,    0,    0 },
    45     { "Comp. Artist",  "music_artists_1.artist_name",             ftString,   0,    0,    0 },
    46     { "Last Play",     "FROM_DAYS(TO_DAYS(lastplay))",   ftDate,     0,    0,    0 },
    47     { "Date Imported", "FROM_DAYS(TO_DAYS(date_added))", ftDate,     0,    0,    0 },
     36    { "Artist",        "music_artists.artist_name",      ftString,   0,    0,    0 },
     37    { "Album",         "music_songs.album_name",         ftString,   0,    0,    0 },
     38    { "Title",         "music_songs.name",               ftString,   0,    0,    0 },
     39    { "Genre",         "music_genres.genre",             ftString,   0,    0,    0 },
     40    { "Year",          "music_songs.year",               ftNumeric,  1900, 2099, 2000 },
     41    { "Track No.",     "music_songs.track",              ftNumeric,  0,    99,   0 },
     42    { "Rating",        "music_songs.rating",             ftNumeric,  0,    10,   0 },
     43    { "Play Count",    "music_songs.numplays",           ftNumeric,  0,    9999, 0 },
     44    { "Compilation",   "music_songs.compilation",        ftBoolean,  0,    0,    0 },
     45    { "Comp. Artist",  "music_comp_artists.artist_name", ftString,   0,    0,    0 },
     46    { "Last Play",     "FROM_DAYS(TO_DAYS(music_songs.lastplay))",   
     47                                                         ftDate,     0,    0,    0 },
     48    { "Date Imported", "FROM_DAYS(TO_DAYS(music_songs.date_added))",   
     49                                                         ftDate,     0,    0,    0 },
    4850};       
    4951
    5052struct SmartPLOperator
     
    655657    searchList.clear();
    656658   
    657659    MSqlQuery query(MSqlQuery::InitCon());
    658     QString querystr;
    659     querystr = QString("SELECT DISTINCT %1 FROM FROM music_artists AS music_artists_1 INNER JOIN (((music_songs INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_genres ON music_songs.genre_id = music_genres.genre_id) ON music_artists_1.artist_id = music_songs.compilationartist_id ORDER BY %2").arg(field).arg(field);
     660    if ("artist" == field || "compilation_artist" == field)
     661    {
     662        query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;");
     663    }
     664    else if ("album" == field)
     665    {
     666        query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;");
     667    }
     668    else if ("title" == field)
     669    {
     670        query.prepare("SELECT name FROM music_songs ORDER BY name;");
     671    }
     672    else if ("genre" == field)
     673    {
     674        query.prepare("SELECT genre FROM music_genres ORDER BY genre;");
     675    }
     676    else
     677    {
     678        return;
     679    }
    660680       
    661     query.exec(querystr);
    662     if (query.isActive() && query.numRowsAffected())
     681    if (query.exec() && query.isActive() && query.numRowsAffected())
    663682    {
    664683        while (query.next())
    665684        {
     
    14581477QString SmartPlaylistEditor::getSQL(QString fields)
    14591478{
    14601479    QString sql, whereClause, orderByClause, limitClause;
    1461    
    1462     sql = "SELECT " + fields + " FROM music_artists AS music_artists_1 INNER JOIN (((music_songs INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_genres ON music_songs.genre_id = music_genres.genre_id) ON music_artists_1.artist_id = music_songs.compilationartist_id ";
     1480    sql = "SELECT " + fields + " FROM music_songs "
     1481          "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
     1482          "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
     1483          "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     1484          "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id ";
     1485
    14631486    whereClause = getWhereClause();
    14641487    orderByClause = getOrderByClause();
    14651488    if (limitSpinEdit->value() > 0)
     
    15061529
    15071530void SmartPlaylistEditor::showResultsClicked(void)
    15081531{
    1509     QString sql = getSQL("song_id, artist_name, album_name, name, genre, year, track");
     1532    QString sql = getSQL("song_id, music_artists.artist_name, album_name, name, genre, year, track");
    15101533   
    15111534    SmartPLResultViewer *resultViewer = new SmartPLResultViewer(gContext->GetMainWindow(), "resultviewer");
    15121535    resultViewer->setSQL(sql);