From 9d222e2c5745da5306a1d537aa307cd68cd908b9 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 20 Jun 2019 02:14:44 +0200 Subject: [PATCH] Rename filename to url, change album_id to string and recreate songs tables (#182) --- data/data.qrc | 1 + data/schema/device-schema.sql | 4 +- data/schema/schema-8.sql | 595 +++++++++++++++++++++++++++ data/schema/schema.sql | 42 +- src/collection/collectionbackend.cpp | 12 +- src/collection/collectionmodel.cpp | 2 +- src/core/database.cpp | 2 +- src/core/song.cpp | 21 +- src/core/song.h | 3 +- src/internet/internetsearchmodel.cpp | 4 +- src/qobuz/qobuzfavoriterequest.cpp | 8 +- src/qobuz/qobuzrequest.cpp | 1 + src/subsonic/subsonicrequest.cpp | 4 +- src/subsonic/subsonicrequest.h | 6 +- src/tidal/tidalbaserequest.cpp | 2 +- src/tidal/tidalfavoriterequest.cpp | 14 +- src/tidal/tidalrequest.cpp | 6 +- src/tidal/tidalrequest.h | 6 +- src/tidal/tidalservice.cpp | 12 +- 19 files changed, 673 insertions(+), 72 deletions(-) create mode 100644 data/schema/schema-8.sql diff --git a/data/data.qrc b/data/data.qrc index f85e63311..170a49a37 100644 --- a/data/data.qrc +++ b/data/data.qrc @@ -8,6 +8,7 @@ schema/schema-5.sql schema/schema-6.sql schema/schema-7.sql + schema/schema-8.sql schema/device-schema.sql style/strawberry.css html/playing-tooltip-plain.html diff --git a/data/schema/device-schema.sql b/data/schema/device-schema.sql index 886e706bc..4b8604cd0 100644 --- a/data/schema/device-schema.sql +++ b/data/schema/device-schema.sql @@ -28,7 +28,7 @@ CREATE TABLE device_%deviceid_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -40,7 +40,7 @@ CREATE TABLE device_%deviceid_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, diff --git a/data/schema/schema-8.sql b/data/schema/schema-8.sql new file mode 100644 index 000000000..10214b092 --- /dev/null +++ b/data/schema/schema-8.sql @@ -0,0 +1,595 @@ +ALTER TABLE songs RENAME TO songs_old; + +ALTER TABLE playlist_items RENAME TO playlist_items_old; + +ALTER TABLE tidal_artists_songs RENAME TO tidal_artists_songs_old; + +ALTER TABLE tidal_albums_songs RENAME TO tidal_albums_songs_old; + +ALTER TABLE tidal_songs RENAME TO tidal_songs_old; + +ALTER TABLE qobuz_artists_songs RENAME TO qobuz_artists_songs_old; + +ALTER TABLE qobuz_albums_songs RENAME TO qobuz_albums_songs_old; + +ALTER TABLE qobuz_songs RENAME TO qobuz_songs_old; + +ALTER TABLE subsonic_songs RENAME TO subsonic_songs_old; + +DROP INDEX idx_filename; + +CREATE TABLE songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE tidal_artists_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE tidal_albums_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE tidal_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE subsonic_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE qobuz_artists_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE qobuz_albums_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE qobuz_songs ( + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER NOT NULL, + url TEXT NOT NULL, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER NOT NULL DEFAULT 0, + mtime INTEGER NOT NULL DEFAULT 0, + ctime INTEGER NOT NULL DEFAULT 0, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +CREATE TABLE playlist_items ( + + playlist INTEGER NOT NULL, + type INTEGER NOT NULL DEFAULT 0, + collection_id INTEGER, + playlist_url TEXT, + + title TEXT NOT NULL, + album TEXT NOT NULL, + artist TEXT NOT NULL, + albumartist TEXT NOT NULL, + track INTEGER NOT NULL DEFAULT -1, + disc INTEGER NOT NULL DEFAULT -1, + year INTEGER NOT NULL DEFAULT -1, + originalyear INTEGER NOT NULL DEFAULT 0, + genre TEXT NOT NULL, + compilation INTEGER NOT NULL DEFAULT -1, + composer TEXT NOT NULL, + performer TEXT NOT NULL, + grouping TEXT NOT NULL, + comment TEXT NOT NULL, + lyrics TEXT NOT NULL, + + artist_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, + song_id INTEGER NOT NULL DEFAULT -1, + + beginning INTEGER NOT NULL DEFAULT 0, + length INTEGER NOT NULL DEFAULT 0, + + bitrate INTEGER NOT NULL DEFAULT 0, + samplerate INTEGER NOT NULL DEFAULT 0, + bitdepth INTEGER NOT NULL DEFAULT 0, + + source INTEGER NOT NULL DEFAULT 0, + directory_id INTEGER, + url TEXT, + filetype INTEGER NOT NULL DEFAULT 0, + filesize INTEGER, + mtime INTEGER, + ctime INTEGER, + unavailable INTEGER DEFAULT 0, + + playcount INTEGER NOT NULL DEFAULT 0, + skipcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER NOT NULL DEFAULT 0, + + compilation_detected INTEGER DEFAULT 0, + compilation_on INTEGER NOT NULL DEFAULT 0, + compilation_off INTEGER NOT NULL DEFAULT 0, + compilation_effective INTEGER NOT NULL DEFAULT 0, + + art_automatic TEXT, + art_manual TEXT, + + effective_albumartist TEXT, + effective_originalyear INTEGER NOT NULL DEFAULT 0, + + cue_path TEXT + +); + +INSERT INTO songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM songs_old; + +DROP TABLE songs_old; + +INSERT INTO tidal_artists_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM tidal_artists_songs_old; + +DROP TABLE tidal_artists_songs_old; + +INSERT INTO tidal_albums_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM tidal_albums_songs_old; + +DROP TABLE tidal_albums_songs_old; + +INSERT INTO tidal_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM tidal_songs_old; + +DROP TABLE tidal_songs_old; + +INSERT INTO qobuz_artists_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM qobuz_artists_songs_old; + +DROP TABLE qobuz_artists_songs_old; + +INSERT INTO qobuz_albums_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM qobuz_albums_songs_old; + +DROP TABLE qobuz_albums_songs_old; + +INSERT INTO qobuz_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM qobuz_songs_old; + +DROP TABLE qobuz_songs_old; + +INSERT INTO subsonic_songs (title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM subsonic_songs_old; + +DROP TABLE subsonic_songs_old; + +INSERT INTO playlist_items (playlist, type, collection_id, playlist_url, title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, url, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path) +SELECT playlist, type, collection_id, url, title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, artist_id, album_id, song_id, beginning, length, bitrate, samplerate, bitdepth, source, directory_id, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, compilation_detected, compilation_on, compilation_off, compilation_effective, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path +FROM playlist_items_old; + +DROP TABLE playlist_items_old; + +CREATE INDEX idx_url ON songs (url); + +UPDATE schema_version SET version=8; diff --git a/data/schema/schema.sql b/data/schema/schema.sql index 67f0d0b87..14293f356 100644 --- a/data/schema/schema.sql +++ b/data/schema/schema.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS schema_version ( DELETE FROM schema_version; -INSERT INTO schema_version (version) VALUES (7); +INSERT INTO schema_version (version) VALUES (8); CREATE TABLE IF NOT EXISTS directories ( path TEXT NOT NULL, @@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -48,7 +48,7 @@ CREATE TABLE IF NOT EXISTS songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -93,7 +93,7 @@ CREATE TABLE IF NOT EXISTS tidal_artists_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS tidal_artists_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -150,7 +150,7 @@ CREATE TABLE IF NOT EXISTS tidal_albums_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -162,7 +162,7 @@ CREATE TABLE IF NOT EXISTS tidal_albums_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -207,7 +207,7 @@ CREATE TABLE IF NOT EXISTS tidal_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -219,7 +219,7 @@ CREATE TABLE IF NOT EXISTS tidal_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -264,7 +264,7 @@ CREATE TABLE IF NOT EXISTS subsonic_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -276,7 +276,7 @@ CREATE TABLE IF NOT EXISTS subsonic_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -321,7 +321,7 @@ CREATE TABLE IF NOT EXISTS qobuz_artists_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -333,7 +333,7 @@ CREATE TABLE IF NOT EXISTS qobuz_artists_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -378,7 +378,7 @@ CREATE TABLE IF NOT EXISTS qobuz_albums_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -390,7 +390,7 @@ CREATE TABLE IF NOT EXISTS qobuz_albums_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -435,7 +435,7 @@ CREATE TABLE IF NOT EXISTS qobuz_songs ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -447,7 +447,7 @@ CREATE TABLE IF NOT EXISTS qobuz_songs ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER NOT NULL, - filename TEXT NOT NULL, + url TEXT NOT NULL, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER NOT NULL DEFAULT 0, mtime INTEGER NOT NULL DEFAULT 0, @@ -489,7 +489,7 @@ CREATE TABLE IF NOT EXISTS playlist_items ( playlist INTEGER NOT NULL, type INTEGER NOT NULL DEFAULT 0, collection_id INTEGER, - url TEXT, + playlist_url TEXT, title TEXT NOT NULL, album TEXT NOT NULL, @@ -508,7 +508,7 @@ CREATE TABLE IF NOT EXISTS playlist_items ( lyrics TEXT NOT NULL, artist_id INTEGER NOT NULL DEFAULT -1, - album_id INTEGER NOT NULL DEFAULT -1, + album_id TEXT NOT NULL, song_id INTEGER NOT NULL DEFAULT -1, beginning INTEGER NOT NULL DEFAULT 0, @@ -520,7 +520,7 @@ CREATE TABLE IF NOT EXISTS playlist_items ( source INTEGER NOT NULL DEFAULT 0, directory_id INTEGER, - filename TEXT, + url TEXT, filetype INTEGER NOT NULL DEFAULT 0, filesize INTEGER, mtime INTEGER, @@ -556,7 +556,7 @@ CREATE TABLE IF NOT EXISTS devices ( transcode_format NOT NULL DEFAULT 5 ); -CREATE INDEX IF NOT EXISTS idx_filename ON songs (filename); +CREATE INDEX IF NOT EXISTS idx_url ON songs (url); CREATE INDEX IF NOT EXISTS idx_comp_artist ON songs (compilation_effective, artist); diff --git a/src/collection/collectionbackend.cpp b/src/collection/collectionbackend.cpp index b8005ce26..579f0440f 100644 --- a/src/collection/collectionbackend.cpp +++ b/src/collection/collectionbackend.cpp @@ -136,7 +136,7 @@ void CollectionBackend::ChangeDirPath(int id, const QString &old_path, const QSt // Do the songs table { QSqlQuery q(db); - q.prepare(QString("UPDATE %1 SET filename=:path || substr(filename, %2) WHERE directory=:id").arg(songs_table_).arg(path_len)); + q.prepare(QString("UPDATE %1 SET url=:path || substr(url, %2) WHERE directory=:id").arg(songs_table_).arg(path_len)); q.bindValue(":path", new_url); q.bindValue(":id", id); q.exec(); @@ -748,7 +748,7 @@ Song CollectionBackend::GetSongByUrl(const QUrl &url, qint64 beginning) { CollectionQuery query; query.SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec); - query.AddWhere("filename", url.toString()); + query.AddWhere("url", url.toString()); query.AddWhere("beginning", beginning); Song song; @@ -763,7 +763,7 @@ SongList CollectionBackend::GetSongsByUrl(const QUrl &url) { CollectionQuery query; query.SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec); - query.AddWhere("filename", url.toString()); + query.AddWhere("url", url.toString()); SongList songlist; if (ExecQuery(&query)) { @@ -860,7 +860,7 @@ void CollectionBackend::UpdateCompilations() { // Look for albums that have songs by more than one 'effective album artist' in the same directory QSqlQuery q(db); - q.prepare(QString("SELECT effective_albumartist, album, filename, compilation_detected FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_)); + q.prepare(QString("SELECT effective_albumartist, album, url, compilation_detected FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_)); q.exec(); if (db_->CheckErrors(q)) return; @@ -948,7 +948,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, AlbumList ret; CollectionQuery query(opt); - query.SetColumnSpec("album, artist, albumartist, compilation, compilation_detected, art_automatic, art_manual, filename"); + query.SetColumnSpec("album, artist, albumartist, compilation, compilation_detected, art_automatic, art_manual, url"); query.SetOrderBy("album"); if (compilation) { @@ -1000,7 +1000,7 @@ CollectionBackend::Album CollectionBackend::GetAlbumArt(const QString &artist, c ret.album_artist = albumartist; CollectionQuery query = CollectionQuery(QueryOptions()); - query.SetColumnSpec("art_automatic, art_manual, filename"); + query.SetColumnSpec("art_automatic, art_manual, url"); if (!albumartist.isEmpty()) { query.AddWhere("albumartist", albumartist); } diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 0bf6790d1..aa31f4336 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -1011,7 +1011,7 @@ CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool c item->key = row.value(0).toString(); item->display_text = TextOrUnknown(item->key); item->sort_text = SortTextForArtist(item->key); - item->metadata.set_album_id(row.value(1).toInt()); + item->metadata.set_album_id(row.value(1).toString()); break; case GroupBy_OriginalYear:{ diff --git a/src/core/database.cpp b/src/core/database.cpp index 7364f5684..1d8ac1f83 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -52,7 +52,7 @@ #include "scopedtransaction.h" const char *Database::kDatabaseFilename = "strawberry.db"; -const int Database::kSchemaVersion = 7; +const int Database::kSchemaVersion = 8; const char *Database::kMagicAllSongsTables = "%allsongstables"; int Database::sNextConnectionId = 1; diff --git a/src/core/song.cpp b/src/core/song.cpp index 0c18f0b1f..75743b38a 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -102,7 +102,7 @@ const QStringList Song::kColumns = QStringList() << "title" << "source" << "directory_id" - << "filename" + << "url" << "filetype" << "filesize" << "mtime" @@ -177,7 +177,7 @@ struct Song::Private : public QSharedData { QString lyrics_; qint64 artist_id_; - qint64 album_id_; + QString album_id_; qint64 song_id_; qint64 beginning_; @@ -230,7 +230,6 @@ Song::Private::Private(Song::Source source) compilation_(false), artist_id_(-1), - album_id_(-1), song_id_(-1), beginning_(0), @@ -275,7 +274,7 @@ bool Song::is_unavailable() const { return d->unavailable_; } int Song::id() const { return d->id_; } qint64 Song::artist_id() const { return d->artist_id_; } -qint64 Song::album_id() const { return d->album_id_; } +QString Song::album_id() const { return d->album_id_; } qint64 Song::song_id() const { return d->song_id_; } const QString &Song::title() const { return d->title_; } @@ -342,7 +341,8 @@ void Song::set_id(int id) { d->id_ = id; } void Song::set_valid(bool v) { d->valid_ = v; } void Song::set_artist_id(qint64 v) { d->artist_id_ = v; } -void Song::set_album_id(qint64 v) { d->album_id_ = v; } +void Song::set_album_id(qint64 v) { d->album_id_ = QString::number(v); } +void Song::set_album_id(const QString &v) { d->album_id_ = v; } void Song::set_song_id(qint64 v) { d->song_id_ = v; } void Song::set_title(const QString &v) { d->title_ = v; } @@ -774,7 +774,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) { d->artist_id_ = tolonglong(x); } else if (Song::kColumns.value(i) == "album_id") { - d->album_id_ = tolonglong(x); + d->album_id_ = tostr(x); } else if (Song::kColumns.value(i) == "song_id") { d->song_id_ = tolonglong(x); @@ -803,7 +803,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) { else if (Song::kColumns.value(i) == "directory_id") { d->directory_id_ = toint(x); } - else if (Song::kColumns.value(i) == "filename") { + else if (Song::kColumns.value(i) == "url") { set_url(QUrl::fromEncoded(tostr(x).toUtf8())); d->basefilename_ = QFileInfo(d->url_.toLocalFile()).fileName(); } @@ -944,7 +944,8 @@ void Song::InitFromItdb(const Itdb_Track *track, const QString &prefix) { filename.replace(':', '/'); if (prefix.contains("://")) { set_url(QUrl(prefix + filename)); - } else { + } + else { set_url(QUrl::fromLocalFile(prefix + filename)); } d->basefilename_ = QFileInfo(filename).fileName(); @@ -1130,7 +1131,7 @@ void Song::BindToQuery(QSqlQuery *query) const { query->bindValue(":lyrics", strval(d->lyrics_)); query->bindValue(":artist_id", intval(d->artist_id_)); - query->bindValue(":album_id", intval(d->album_id_)); + query->bindValue(":album_id", strval(d->album_id_)); query->bindValue(":song_id", intval(d->song_id_)); query->bindValue(":beginning", d->beginning_); @@ -1152,7 +1153,7 @@ void Song::BindToQuery(QSqlQuery *query) const { url = d->url_.toEncoded(); } } - query->bindValue(":filename", url); + query->bindValue(":url", url); query->bindValue(":filetype", d->filetype_); query->bindValue(":filesize", notnullintval(d->filesize_)); diff --git a/src/core/song.h b/src/core/song.h index 0f5a35a67..c183da88f 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -200,7 +200,7 @@ class Song { const QString &lyrics() const; qint64 artist_id() const; - qint64 album_id() const; + QString album_id() const; qint64 song_id() const; qint64 beginning_nanosec() const; @@ -291,6 +291,7 @@ class Song { void set_artist_id(qint64 v); void set_album_id(qint64 v); + void set_album_id(const QString &v); void set_song_id(qint64 v); void set_beginning_nanosec(qint64 v); diff --git a/src/internet/internetsearchmodel.cpp b/src/internet/internetsearchmodel.cpp index cf3dd944b..777e3562e 100644 --- a/src/internet/internetsearchmodel.cpp +++ b/src/internet/internetsearchmodel.cpp @@ -85,7 +85,7 @@ QStandardItem *InternetSearchModel::BuildContainers(const Song &s, QStandardItem bool has_album_icon = false; QString display_text; QString sort_text; - int unique_tag = -1; + QString unique_tag; int year = 0; switch (group_by_[level]) { @@ -222,7 +222,7 @@ QStandardItem *InternetSearchModel::BuildContainers(const Song &s, QStandardItem if (sort_text.isEmpty()) sort_text = "Unknown"; // Find a container for this level - key->group_[level] = display_text + QString::number(unique_tag); + key->group_[level] = display_text + unique_tag; QStandardItem *container = containers_[*key]; if (!container) { container = new QStandardItem(display_text); diff --git a/src/qobuz/qobuzfavoriterequest.cpp b/src/qobuz/qobuzfavoriterequest.cpp index 7db24a487..72fc52de8 100644 --- a/src/qobuz/qobuzfavoriterequest.cpp +++ b/src/qobuz/qobuzfavoriterequest.cpp @@ -108,8 +108,8 @@ void QobuzFavoriteRequest::AddFavorites(const FavoriteType type, const SongList id = QString::number(song.artist_id()); break; case FavoriteType_Albums: - if (song.album_id() <= 0) continue; - id = QString::number(song.album_id()); + if (song.album_id().isEmpty()) continue; + id = song.album_id(); break; case FavoriteType_Songs: if (song.song_id() <= 0) continue; @@ -215,8 +215,8 @@ void QobuzFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi id = QString::number(song.artist_id()); break; case FavoriteType_Albums: - if (song.album_id() <= 0) continue; - id = QString::number(song.album_id()); + if (song.album_id().isEmpty()) continue; + id = song.album_id(); break; case FavoriteType_Songs: if (song.song_id() <= 0) continue; diff --git a/src/qobuz/qobuzrequest.cpp b/src/qobuz/qobuzrequest.cpp index 79d2de513..d75ced32a 100644 --- a/src/qobuz/qobuzrequest.cpp +++ b/src/qobuz/qobuzrequest.cpp @@ -1027,6 +1027,7 @@ int QobuzRequest::ParseSong(Song &song, const QJsonObject &json_obj, qint64 arti song.set_source(Song::Source_Qobuz); song.set_song_id(song_id); + song.set_album_id(album_id); song.set_artist_id(artist_id); song.set_album(album); song.set_artist(album_artist); diff --git a/src/subsonic/subsonicrequest.cpp b/src/subsonic/subsonicrequest.cpp index c3afaf404..1340a582f 100644 --- a/src/subsonic/subsonicrequest.cpp +++ b/src/subsonic/subsonicrequest.cpp @@ -628,13 +628,13 @@ void SubsonicRequest::FlushAlbumCoverRequests() { QNetworkReply *reply = network_->get(req); album_cover_replies_ << reply; - NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumCoverReceived(QNetworkReply*, const qint64, const QUrl&, const QString&)), reply, request.album_id, request.url, request.filename); + NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumCoverReceived(QNetworkReply*, const QString&, const QUrl&, const QString&)), reply, request.album_id, request.url, request.filename); } } -void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const qint64 album_id, const QUrl &url, const QString &filename) { +void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url, const QString &filename) { if (album_cover_replies_.contains(reply)) { album_cover_replies_.removeAll(reply); diff --git a/src/subsonic/subsonicrequest.h b/src/subsonic/subsonicrequest.h index 5c063300a..90181e949 100644 --- a/src/subsonic/subsonicrequest.h +++ b/src/subsonic/subsonicrequest.h @@ -69,7 +69,7 @@ class SubsonicRequest : public SubsonicBaseRequest { void AlbumsReplyReceived(QNetworkReply *reply, const int offset_requested); void AlbumSongsReplyReceived(QNetworkReply *reply, const qint64 artist_id, const qint64 album_id, const QString &album_artist); - void AlbumCoverReceived(QNetworkReply *reply, const qint64 album_id, const QUrl &url, const QString &filename); + void AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url, const QString &filename); private: typedef QPair Param; @@ -85,7 +85,7 @@ class SubsonicRequest : public SubsonicBaseRequest { }; struct AlbumCoverRequest { qint64 artist_id = 0; - qint64 album_id = 0; + QString album_id = 0; QUrl url; QString filename; }; @@ -127,7 +127,7 @@ class SubsonicRequest : public SubsonicBaseRequest { QQueue album_cover_requests_queue_; QHash album_songs_requests_pending_; - QMultiMap album_covers_requests_sent_; + QMultiMap album_covers_requests_sent_; int albums_requests_active_; diff --git a/src/tidal/tidalbaserequest.cpp b/src/tidal/tidalbaserequest.cpp index b18df8d08..c8c9b26c0 100644 --- a/src/tidal/tidalbaserequest.cpp +++ b/src/tidal/tidalbaserequest.cpp @@ -61,7 +61,7 @@ TidalBaseRequest::~TidalBaseRequest() { QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, const QList ¶ms_provided) { ParamList params = ParamList() << params_provided - << Param("countryCode", country_code()); + << Param("countryCode", country_code()); QUrlQuery url_query; for (const Param& param : params) { diff --git a/src/tidal/tidalfavoriterequest.cpp b/src/tidal/tidalfavoriterequest.cpp index 6e5041e69..72431db0c 100644 --- a/src/tidal/tidalfavoriterequest.cpp +++ b/src/tidal/tidalfavoriterequest.cpp @@ -109,8 +109,8 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList id = QString::number(song.artist_id()); break; case FavoriteType_Albums: - if (song.album_id() <= 0) continue; - id = QString::number(song.album_id()); + if (song.album_id().isEmpty()) continue; + id = song.album_id(); break; case FavoriteType_Songs: if (song.song_id() <= 0) continue; @@ -201,18 +201,18 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi if (songs.isEmpty()) return; - QList ids; - QMultiMap songs_map; + QList ids; + QMultiMap songs_map; for (const Song &song : songs) { - int id = -1; + qint64 id = -1; switch (type) { case FavoriteType_Artists: if (song.artist_id() <= 0) continue; id = song.artist_id(); break; case FavoriteType_Albums: - if (song.album_id() <= 0) continue; - id = song.album_id(); + if (song.album_id().isEmpty()) continue; + id = song.album_id().toLongLong(); break; case FavoriteType_Songs: if (song.song_id() <= 0) continue; diff --git a/src/tidal/tidalrequest.cpp b/src/tidal/tidalrequest.cpp index ae4239854..7e6f68033 100644 --- a/src/tidal/tidalrequest.cpp +++ b/src/tidal/tidalrequest.cpp @@ -1033,13 +1033,13 @@ void TidalRequest::FlushAlbumCoverRequests() { QNetworkRequest req(request.url); QNetworkReply *reply = network_->get(req); album_cover_replies_ << reply; - NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumCoverReceived(QNetworkReply*, const qint64, const QUrl&)), reply, request.album_id, request.url); + NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumCoverReceived(QNetworkReply*, const QString&, const QUrl&)), reply, request.album_id, request.url); } } -void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const qint64 album_id, const QUrl &url) { +void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url) { if (album_cover_replies_.contains(reply)) { album_cover_replies_.removeAll(reply); @@ -1083,7 +1083,7 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const qint64 album_i QDir dir; if (dir.mkpath(service_->CoverCacheDir())) { - QString filename(service_->CoverCacheDir() + "/" + QString::number(album_id) + "-" + url.fileName()); + QString filename(service_->CoverCacheDir() + "/" + album_id + "-" + url.fileName()); if (image.save(filename, "JPG")) { while (album_covers_requests_sent_.contains(album_id)) { Song *song = album_covers_requests_sent_.take(album_id); diff --git a/src/tidal/tidalrequest.h b/src/tidal/tidalrequest.h index 37bf91405..afcb1c874 100644 --- a/src/tidal/tidalrequest.h +++ b/src/tidal/tidalrequest.h @@ -85,7 +85,7 @@ class TidalRequest : public TidalBaseRequest { void ArtistAlbumsReplyReceived(QNetworkReply *reply, const qint64 artist_id, const int offset_requested); void AlbumSongsReplyReceived(QNetworkReply *reply, const qint64 artist_id, const qint64 album_id, const int offset_requested, const QString &album_artist); - void AlbumCoverReceived(QNetworkReply *reply, const qint64 album_id, const QUrl &url); + void AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url); private: typedef QPair Param; @@ -101,7 +101,7 @@ class TidalRequest : public TidalBaseRequest { }; struct AlbumCoverRequest { qint64 artist_id = 0; - qint64 album_id = 0; + QString album_id = 0; QUrl url; }; @@ -176,7 +176,7 @@ class TidalRequest : public TidalBaseRequest { QList artist_albums_requests_pending_; QHash album_songs_requests_pending_; - QMultiMap album_covers_requests_sent_; + QMultiMap album_covers_requests_sent_; int artists_requests_active_; int artists_total_; diff --git a/src/tidal/tidalservice.cpp b/src/tidal/tidalservice.cpp index 072daeb7a..23311ec3f 100644 --- a/src/tidal/tidalservice.cpp +++ b/src/tidal/tidalservice.cpp @@ -204,8 +204,6 @@ void TidalService::ReloadSettings() { if (client_id_.isEmpty()) client_id_ = QString::fromUtf8(QByteArray::fromBase64(kClientIdB64)); api_token_ = s.value("api_token").toString(); if (api_token_.isEmpty()) api_token_ = QString::fromUtf8(QByteArray::fromBase64(kApiTokenB64)); - user_id_ = s.value("user_id", 0).toInt(); - country_code_ = s.value("country_code", "US").toString(); username_ = s.value("username").toString(); QByteArray password = s.value("password").toByteArray(); @@ -222,6 +220,8 @@ void TidalService::ReloadSettings() { cache_album_covers_ = s.value("cachealbumcovers", true).toBool(); stream_url_method_ = static_cast(s.value("streamurl").toInt()); + user_id_ = s.value("user_id").toInt(); + country_code_ = s.value("country_code", "US").toString(); access_token_ = s.value("access_token").toString(); refresh_token_ = s.value("refresh_token").toString(); session_id_ = s.value("session_id").toString(); @@ -559,12 +559,12 @@ void TidalService::HandleAuthReply(QNetworkReply *reply) { QSettings s; s.beginGroup(TidalSettingsPage::kSettingsGroup); - s.setValue("user_id", user_id_); - s.setValue("session_id", session_id_); - s.setValue("country_code", country_code_); s.remove("access_token"); s.remove("refresh_token"); s.remove("expiry_time"); + s.setValue("user_id", user_id_); + s.setValue("session_id", session_id_); + s.setValue("country_code", country_code_); s.endGroup(); qLog(Debug) << "Tidal: Login successful" << "user id" << user_id_ << "session id" << session_id_ << "country code" << country_code_; @@ -585,6 +585,8 @@ void TidalService::Logout() { QSettings s; s.beginGroup(TidalSettingsPage::kSettingsGroup); + s.remove("user_id"); + s.remove("country_code"); s.remove("access_token"); s.remove("session_id"); s.remove("expiry_time");