gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2a4cfc552a4cfc55jukebox: library screens (songs, artists, albums, artist, album, search, favourites), compact player bar, /stream with Range, thumbnails, virtual list vendored, ui gate and real-library checkmre2a4cfc55/tools/make-test-db.hl

3.3 KB

  1. // tools/make-test-db.hl — A TEST DATABASE OF 13,449 GENERATED SONGS (not the real library) for the screens' gate: the same record shape the scanner writes,
  2. // made up from numbers. Every song points at one real small mp3 (the first argument), so that streaming and playing work; 40 % of the albums have the
  3. // cover (the second argument, a picture file). One known song for the search check: "Zebra Fixture Anthem" by "Quentin Fixture", album "Known Album" (played 9 times).
  4. // JUKEBOX_STORAGE=/abs/storage ./bin/hybriel tools/make-test-db.hl /abs/song.mp3 /abs/cover.jpg [count]
  5. import { args } from 'hl:proc'
  6. import { readBytes } from 'hl:fs'
  7. import { ensureStorage } from '../lib/settings.hl'
  8. import { songsTable } from '../lib/db.hl'
  9. import { rebuildCatalog } from '../lib/catalog.hl'
  10. import { storeCoverFile } from '../lib/covers.hl'
  11. import { fold, safeKey, padNumber, SEP } from '../lib/util.hl'
  12. ensureStorage()
  13. given = args()
  14. mp3 = given[0]
  15. size = readBytes(mp3).length
  16. cover = storeCoverFile(given[1])
  17. total = given.length > 2 ? toNumber(given[2]) : 13449
  18. firstNames = ['Alma', 'Bruno', 'Clara', 'Dario', 'Edda', 'Fritz', 'Greta', 'Hugo', 'Ines', 'Jonas', 'Karla', 'Leo', 'Mira', 'Nils', 'Olga', 'Paul', 'Rosa', 'Sven', 'Tilda', 'Ulf']
  19. lastNames = ['Amber', 'Birch', 'Cobalt', 'Dune', 'Ember', 'Fjord', 'Grove', 'Harbor', 'Iris', 'Juniper', 'Kestrel', 'Lagoon', 'Meadow', 'Nectar', 'Orchid']
  20. words = ['Night', 'River', 'Glass', 'Paper', 'Silver', 'Winter', 'Garden', 'Signal', 'Harbour', 'Letter', 'Mirror', 'Engine', 'Orchard', 'Thunder', 'Velvet', 'Window']
  21. record = (n) => {
  22. artistNo = n % 300
  23. artist = firstNames[artistNo % 20] + ' ' + lastNames[(artistNo - artistNo % 20) / 20 % 15] + ' ' + artistNo
  24. albumNo = (n - n % 12) / 12 % 7
  25. album = words[(artistNo + albumNo) % 16] + ' ' + words[(albumNo * 3 + 5) % 16] + ' ' + albumNo
  26. track = (n - n % 300) / 300 + 1
  27. title = words[n % 16] + ' ' + words[(n * 7 + 3) % 16] + ' ' + n
  28. plays = (n * 7 + (n - n % 5) / 5) % 13
  29. folder = '/test/' + artistNo + '/' + album
  30. return build(n, artist, album, title, track, plays, folder, albumNo)
  31. }
  32. build = (n, artist, album, title, track, plays, folder, albumNo) => {
  33. albumKey = safeKey(fold(artist) + '|' + fold(album) + '|' + folder)
  34. return {
  35. path = mp3 folder = folder title = title artist = artist albumArtist = artist album = album
  36. track = track trackTotal = 12 disc = 1 discTotal = 1 year = 1990 + n % 30
  37. genre = 'Test' duration = 60 + n % 240 format = 'mp3' kind = 'audio'
  38. size = size changeTime = 1700000000000 playCount = plays popm = [] rating = 0
  39. stars = 0 coverId = albumNo % 5 < 2 ? cover : null
  40. albumKey = albumKey artistKey = safeKey(fold(artist))
  41. search = fold(artist + ' ' + title + ' ' + album + ' Test')
  42. sortArtist = safeKey(fold(artist) + SEP + fold(album) + SEP + padNumber(1, 2) + SEP + padNumber(track, 3) + SEP + fold(title))
  43. sortAlbum = safeKey(fold(album) + SEP + fold(artist) + SEP + padNumber(1, 2) + SEP + padNumber(track, 3) + SEP + fold(title))
  44. sortTitle = safeKey(fold(title) + SEP + fold(artist) + SEP + fold(album))
  45. addedAt = 1700000000000
  46. }
  47. }
  48. let n = 0
  49. while (n < total) {
  50. songsTable.put(record(n))
  51. n = n + 1
  52. }
  53. known = build(total, 'Quentin Fixture', 'Known Album', 'Zebra Fixture Anthem', 1, 9, '/test/known', 1)
  54. songsTable.put(known)
  55. r = rebuildCatalog()
  56. console.log('songs: ' + (total + 1) + ' albums: ' + r.albums + ' artists: ' + r.artists)

Branches

Latest commits

  • 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