gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd13987dfd13987dfjukebox: library scanner, ID3 reader, mpackdb database and JSON API, with fixtures and a gatemred13987df/project.hl

2.8 KB

  1. // project.hl — jukebox: THE MAP. Config, routes and the timer. A network media player for the music on loreana; this
  2. // mission is the library scanner, the mpackdb database and the JSON API (no screens yet).
  3. //
  4. // WHERE WHAT IS (README "Files"):
  5. // settings (library paths) and the storage folders lib/settings.hl
  6. // reading one file's tags into a song record lib/tags.hl (+ lib/id3.hl, lib/id3-helpers.hl, lib/mpeg.hl)
  7. // the scanner (walk, incremental, vanished files) lib/library.hl (+ lib/scan-state.hl); when it runs: lib/schedule.hl
  8. // covers cache lib/covers.hl
  9. // the database (the one place that knows mpackdb) lib/db.hl; albums and artists tables: lib/catalog.hl
  10. // pages, search, shuffle, stats lib/browse.hl (+ lib/order-cache.hl)
  11. // the JSON routes lib/api.hl (+ lib/api-helpers.hl, lib/jsoncheck.hl)
  12. // env, text folding, numbers lib/util.hl
  13. // the start page, all CSS components/home.hl, components/styles.hl
  14. import WebFramework from 'hl:web'
  15. import { env } from 'hl:proc'
  16. import { every } from 'hl:time'
  17. import Styles from './components/styles.hl'
  18. import Home from './components/home.hl'
  19. import { ensureStorage } from './lib/settings.hl'
  20. import { armFirst, tick, applyLine, finished } from './lib/schedule.hl'
  21. import { apiStats, apiSongs, apiArtists, apiAlbums, apiSearch, apiShuffle, apiCover, apiRescan, apiSettings, apiNotFound } from './lib/api.hl'
  22. static siteName = "jukebox"
  23. appTitle = siteName
  24. styles = Styles
  25. routes = [
  26. { pattern = "/api/stats" function = apiStats }
  27. { pattern = "/api/songs" function = apiSongs }
  28. { pattern = "/api/artists" function = apiArtists }
  29. { pattern = "/api/albums" function = apiAlbums }
  30. { pattern = "/api/search" function = apiSearch }
  31. { pattern = "/api/shuffle" function = apiShuffle }
  32. { pattern = "/api/cover/:id" function = apiCover }
  33. { pattern = "/api/rescan" function = apiRescan }
  34. { pattern = "/api/settings" function = apiSettings }
  35. { pattern = "/" component = Home }
  36. ]
  37. // JUKEBOX_PORT (default 8700, the slot's first port); HL_HOST binds a single interface; JUKEBOX_WATCH=0 = no dev watcher
  38. port = env('JUKEBOX_PORT') != null ? toNumber(env('JUKEBOX_PORT')) : 8700
  39. watching = env('JUKEBOX_WATCH') != '0'
  40. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = 'jukeboxsid')
  41. ensureStorage()
  42. armFirst()
  43. // once a second the scheduler looks whether a scan is due or asked for (lib/schedule.hl)
  44. // the scan runs in a child process; its progress lines and its end come back here
  45. ticker = every(1)
  46. on ticker.tick() {
  47. child = tick()
  48. if (child != null) {
  49. on child.line({ line, stream }) { applyLine(line) }
  50. on child.exit({ exit, pid }) { finished(exit) }
  51. }
  52. }
  53. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • d13987dfjukebox: library scanner, ID3 reader, mpackdb database and JSON API, with fixtures and a gatemre