Created
September 9, 2025 07:53
-
-
Save WildRikku/15b645d236b2d4edf32c01c9603a2c86 to your computer and use it in GitHub Desktop.
Very primitive script to save the most important tags from a Quod Libet "database" (pickled dict) to an SQLite database
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
| import quodlibet.library | |
| from quodlibet.query import Query | |
| from quodlibet import app | |
| import sqlite3 | |
| # you need a Quod Libet dev environment https://quodlibet.readthedocs.io/en/latest/development/devenv.html | |
| # this script and your QL songs file need to be placed at the root of your Quod Libet git checkout | |
| # the SQLite file will also be placed there | |
| dbcon = sqlite3.connect("songs.db") | |
| dbcur = dbcon.cursor() | |
| tableName = "songs" # name of QL songs file and table in SQLite | |
| dbcur.execute(f"""CREATE TABLE "{tableName}" ( | |
| "title" TEXT, | |
| "artist" TEXT, | |
| "album" TEXT, | |
| "version" TEXT, | |
| "playCount" INTEGER, | |
| "skipCount" INTEGER, | |
| "added" INTEGER, | |
| "lastplayed" INTEGER, | |
| "laststarted" INTEGER | |
| )""") | |
| library = quodlibet.library.init('../' + tableName) | |
| app.library = library | |
| for song in Query('').filter(app.library): | |
| songDict = {'title': song.get('title', None), | |
| 'artist': song.get('artist', None), | |
| 'album': song.get('album', None), | |
| 'version': song.get('version', None), | |
| 'playcount': song.get('~#playcount', None), | |
| 'skipcount': song.get('~#skipcount', None), | |
| 'added': song.get('~#added', None), | |
| 'lastplayed': song.get('~#lastplayed', None), | |
| 'laststarted': song.get('~#laststarted', None)} | |
| dbcur.execute( | |
| f"INSERT INTO {tableName} ('title', 'artist', 'album', 'version', 'playcount', 'skipcount', 'added', 'lastplayed', 'laststarted') VALUES (:title, :artist, :album, :version, :playcount, :skipcount, :added, :lastplayed, :laststarted)", | |
| songDict) | |
| dbcon.commit() | |
| dbcon.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment