jukebox
All repositories: gitoria
1.7 KB
// lib/migrate.hl — KEYS FROM AN EARLIER VERSION. Until JB3 an album key held the folder and "CD 1" stayed in the album name, so one album sat in the database twice. `fixKeys` goes// through the songs of a database made before, folds the disc marker out of the album name, gives the song its disc number and rewrites the album key and the two sort keys// (from the stored fields, no file is read). The state is a one-line file `keys-version` in storage/: the work runs once, and is checked again after every change of the rule.import { readFile, writeFile, exists } from 'hl:fs'import { songsTable, replaceSong } from './db.hl'import { storageRoot } from './util.hl'import { splitDisc, albumKeyOf, discFor, sortKeys } from './albums.hl'static version = '3'static marker = storageRoot + '/keys-version'static needsFix = () => {if (!exists(marker)) { return true }return readFile(marker).trim() != version}// answers how many songs changedstatic fixKeys = () => {let changed = 0rows = []for (s of songsTable.iterate(null, null)) { rows.push(s) }for (s of rows) {parts = splitDisc(s.album)disc = discFor(s.disc == 1 && parts.disc == null ? null : s.disc, parts.disc)key = albumKeyOf(s.albumArtist, parts.name)keys = sortKeys(s.albumArtist, parts.name, disc, s.track == null ? 0 : s.track, s.title)if (key == s.albumKey && parts.name == s.album && disc == s.disc && keys.sortArtist == s.sortArtist && keys.sortAlbum == s.sortAlbum) { continue }rec = {}for (k in s) {if (k != 'id') { rec[k] = s[k] }}rec.album = parts.namerec.albumKey = keyrec.disc = discrec.sortArtist = keys.sortArtistrec.sortAlbum = keys.sortAlbumreplaceSong(s.id, rec)changed = changed + 1}writeFile(marker, version, 420)return changed}
Branches
Latest commits
- c5b8fde9jukebox JB3b: keyboard gap repro as a reportmre
- 9daebb4bjukebox JB3b: shuffle, now-playing overlay, next and previous, play counting, media session, gates; keyboard left open (Hybriel gap)mre
- 59c1373ejukebox JB3 (work in progress): albums without folder and with disc markers folded, compilations, duplicate songs, own play counter, server-side shuffle queuemre
- 2a4cfc55jukebox: library screens (songs, artists, albums, artist, album, search, favourites), compact player bar, /stream with Range, thumbnails, virtual list vendored, ui gate and real-library checkmre
- 93a44212jukebox: report, numbers of the full scan, notes on the index key rulemre
- bf5167dajukebox: index keys without commas (mpackdb loses them after a reopen), comma fixture and gate checksmre
- 28a82fa2jukebox: README, STATUS, LOG, DECISIONSmre
- d13987dfjukebox: library scanner, ID3 reader, mpackdb database and JSON API, with fixtures and a gatemre