Last active
August 28, 2025 06:19
-
-
Save Vftdan/b0373716c24c44228d5ac4ca9d220fa9 to your computer and use it in GitHub Desktop.
Replace strawberry player library (songs and playlists) with existing clementine library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- () { :; }; exec sqlite3 -init "$0" # Shebang | |
| -- XXX: THIS WILL DELETE EXISTING STRAWBERRY LIBRARY!!! | |
| -- Based on instructions at <url:https://wiki.strawberrymusicplayer.org/wiki/Import_collection_library_and_playlists_from_Clementine> | |
| -- You will need to replace '~' with its expansion | |
| ATTACH '~/.local/share/strawberry/strawberry/strawberry.db' AS strawberry; | |
| ATTACH '~/.config/Clementine/clementine.db' AS clementine; | |
| BEGIN; | |
| DELETE FROM strawberry.directories; | |
| DELETE FROM strawberry.subdirectories; | |
| DELETE FROM strawberry.songs; | |
| DELETE FROM strawberry.playlists; | |
| DELETE FROM strawberry.playlist_items; | |
| INSERT INTO strawberry.directories (path, subdirs) SELECT path, subdirs FROM clementine.directories; | |
| INSERT INTO strawberry.subdirectories (directory_id, path, mtime) SELECT directory, path, mtime FROM clementine.subdirectories; | |
| INSERT INTO strawberry.songs (ROWID, title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, beginning, length, bitrate, samplerate, 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, rating) | |
| SELECT ROWID, title, album, artist, albumartist, track, disc, year, originalyear, genre, compilation, composer, performer, grouping, comment, lyrics, beginning, length, bitrate, samplerate, directory, filename, filetype, filesize, mtime, ctime, unavailable, playcount, skipcount, lastplayed, sampler, forced_compilation_on, forced_compilation_off, effective_compilation, art_automatic, art_manual, effective_albumartist, effective_originalyear, cue_path, rating FROM clementine.songs; | |
| UPDATE strawberry.songs SET source = 2; | |
| UPDATE strawberry.songs SET artist_id = ''; | |
| UPDATE strawberry.songs SET album_id = ''; | |
| UPDATE strawberry.songs SET song_id = ''; | |
| INSERT INTO strawberry.playlists (ROWID, name, last_played, special_type, ui_path, is_favorite, dynamic_playlist_type, dynamic_playlist_data, dynamic_playlist_backend) | |
| SELECT ROWID, name, last_played, special_type, ui_path, is_favorite, dynamic_playlist_type, dynamic_playlist_data, dynamic_playlist_backend FROM clementine.playlists WHERE dynamic_playlist_type ISNULL; | |
| INSERT INTO strawberry.playlist_items ( | |
| ROWID, | |
| playlist, | |
| collection_id, | |
| title, | |
| album, | |
| artist, | |
| albumartist, | |
| track, | |
| disc, | |
| year, | |
| originalyear, | |
| genre, | |
| compilation, | |
| composer, | |
| performer, | |
| grouping, | |
| comment, | |
| lyrics, | |
| beginning, | |
| length, | |
| bitrate, | |
| samplerate, | |
| 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, | |
| rating, | |
| type | |
| ) | |
| WITH t(clementine_type, strawberry_type) AS (VALUES ('File', 1), ('Library', 2), ('Stream', 5)) -- Add other options if needed, discover with `SELECT DISTINCT type FROM clementine.playlist_items;` and <url:https://github.com/strawberrymusicplayer/strawberry/blob/master/src/core/song.h#L67> | |
| SELECT pi.ROWID, | |
| pi.playlist, | |
| pi.library_id, | |
| pi.title, | |
| pi.album, | |
| pi.artist, | |
| pi.albumartist, | |
| pi.track, | |
| pi.disc, | |
| pi.year, | |
| pi.originalyear, | |
| pi.genre, | |
| pi.compilation, | |
| pi.composer, | |
| pi.performer, | |
| pi.grouping, | |
| pi.comment, | |
| pi.lyrics, | |
| pi.beginning, | |
| pi.length, | |
| pi.bitrate, | |
| pi.samplerate, | |
| pi.directory, | |
| COALESCE(pi.filename, s.filename), -- At least some Clementine versions do not store playlist_items.filename when playlist_items.type = 'Library' | |
| pi.filetype, | |
| pi.filesize, | |
| pi.mtime, | |
| pi.ctime, | |
| pi.unavailable, | |
| pi.playcount, | |
| pi.skipcount, | |
| pi.lastplayed, | |
| pi.sampler, | |
| pi.forced_compilation_on, | |
| pi.forced_compilation_off, | |
| pi.effective_compilation, | |
| pi.art_automatic, | |
| REPLACE(COALESCE(pi.art_manual, s.art_manual), '.config/Clementine/albumcovers','.local/share/strawberry/strawberry/collectionalbumcovers'), | |
| pi.effective_albumartist, | |
| pi.effective_originalyear, | |
| pi.cue_path, | |
| pi.rating, | |
| t.strawberry_type FROM clementine.playlist_items pi LEFT JOIN clementine.songs s ON pi.type = 'Library' AND pi.library_id = s.ROWID LEFT JOIN t ON pi.type = t.clementine_type; | |
| UPDATE strawberry.playlist_items SET source = type; | |
| UPDATE strawberry.playlist_items SET artist_id = ''; | |
| UPDATE strawberry.playlist_items SET album_id = ''; | |
| UPDATE strawberry.playlist_items SET song_id = ''; | |
| COMMIT; | |
| DETACH clementine; | |
| DETACH strawberry; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment