gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchday418ed6da45|||PR README: media-player pin df9e7dfmreday41/project.hl

4.3 KB

  1. // project.hl — jukebox: THE MAP. Config, routes and the timer. A network media player for the music on loreana; this
  2. // missions: the scanner, the database and the JSON API (JB1); the library screens and playing in the browser (JB2).
  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 audio route /stream/<id> (HTTP Range) lib/stream.hl; rows of the lists and the player queue: lib/rows.hl
  14. // the screens components/main.hl (shell + player bar), songs.hl artists.hl albums.hl artist.hl album.hl search.hl
  15. // vendored (components/SOURCE): media-player, virtual-list, icons; theme/ (layouts); all our CSS: components/styles.hl
  16. import WebFramework from 'hl:web'
  17. import { env, exit } from 'hl:proc'
  18. import { every } from 'hl:time'
  19. import Styles from './components/styles.hl'
  20. import Songs from './components/songs.hl'
  21. import Artists from './components/artists.hl'
  22. import Albums from './components/albums.hl'
  23. import Artist from './components/artist.hl'
  24. import Album from './components/album.hl'
  25. import Search from './components/search.hl'
  26. import { needsFix, fixKeys } from './lib/migrate.hl'
  27. import { rebuildCatalog } from './lib/catalog.hl'
  28. import { ensureStorage } from './lib/settings.hl'
  29. import { armFirst, tick, applyLine, finished } from './lib/schedule.hl'
  30. import { serve as streamSong } from './lib/stream.hl'
  31. import { apiStats, apiSongs, apiArtists, apiAlbums, apiSearch, apiShuffle, apiPlayed, apiCopies, apiQueue, apiCover, apiThumb, apiRescan, apiSettings, apiNotFound } from './lib/api.hl'
  32. static siteName = "jukebox"
  33. appTitle = siteName
  34. styles = Styles
  35. routes = [
  36. { pattern = "/api/stats" function = apiStats }
  37. { pattern = "/api/songs" function = apiSongs }
  38. { pattern = "/api/artists" function = apiArtists }
  39. { pattern = "/api/albums" function = apiAlbums }
  40. { pattern = "/api/search" function = apiSearch }
  41. { pattern = "/api/shuffle" function = apiShuffle }
  42. { pattern = "/api/played/:id" function = apiPlayed }
  43. { pattern = "/api/copies/:id" function = apiCopies }
  44. { pattern = "/api/queue" function = apiQueue }
  45. { pattern = "/api/cover/:id" function = apiCover }
  46. { pattern = "/api/thumb/:id" function = apiThumb }
  47. { pattern = "/stream/:id" function = streamSong }
  48. { pattern = "/api/rescan" function = apiRescan }
  49. { pattern = "/api/settings" function = apiSettings }
  50. { pattern = "/" component = Songs }
  51. { pattern = "/artists" component = Artists }
  52. { pattern = "/albums" component = Albums }
  53. { pattern = "/artists/:id" component = Artist }
  54. { pattern = "/albums/:id" component = Album }
  55. { pattern = "/search" component = Search }
  56. ]
  57. // JUKEBOX_PORT (default 8700, the slot's first port); HL_HOST binds a single interface; JUKEBOX_WATCH=0 = no dev watcher
  58. port = env('JUKEBOX_PORT') != null ? toNumber(env('JUKEBOX_PORT')) : 8700
  59. watching = env('JUKEBOX_WATCH') != '0'
  60. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = 'jukeboxsid')
  61. ensureStorage()
  62. if (needsFix()) {
  63. fixed = fixKeys()
  64. rebuilt = rebuildCatalog()
  65. console.log('keys fixed on ' + fixed + ' songs; ' + rebuilt.albums + ' albums, ' + rebuilt.artists + ' artists')
  66. }
  67. armFirst()
  68. // once a second the scheduler looks whether a scan is due or asked for (lib/schedule.hl)
  69. // the scan runs in a child process; its progress lines and its end come back here
  70. ticker = every(1)
  71. on ticker.tick() {
  72. child = tick()
  73. if (child != null) {
  74. on child.line({ line, stream }) { applyLine(line) }
  75. on child.exit({ exit, pid }) { finished(exit) }
  76. }
  77. }
  78. on Error(e) {
  79. if (e.phase == 'startup') { console.log('jukebox: startup error: ' + e.message) exit(1) }
  80. console.log('error absorbed: ' + e.message)
  81. }

Branches

Latest commits

  • 8ed6da45|||PR README: media-player pin df9e7dfmre
  • d5d45fc3|||PR media-player df9e7df (repeat-one fix), sync pin and SOURCEmre
  • 89cdabb1Vendor Hybriel day41 (57054d9e): plugin dirs, set .somre
  • 1fecd6a7Merge branch 'records-day39' into mainJukebox
  • d6b3e068|||PR Records: day39 live (PR #2), mission 011 PR step, statusmre
  • 5fa19e89Merge branch 'day39' into mainJukebox
  • cfe95440|||PR day39 re-vendor: Hybriel 51e921d7 (bin 6b481aa7), ids kebab-case since hybriel#256: quoted state rule and tests use jb-shuffle / jb-repeatmre
  • f3614c9bRe-vendor to Hybriel day39 (51e921d7, bin 6b481aa7)mre
  • 9f5c6532Merge branch 'status-22-pr' into mainJukebox
  • 5838d6c7|||PR STATUS: #22 pending decision, PR-only rulemre
  • 29d2029cRecords: PR-only rule (Kunibert)mre
  • adacb0abRecords: neutral ticket rule, #22 decision recordedmre
  • b2d6f121Records: #308 hold liftedmre
  • 7ab67533Records: day39 on hold (hybriel#308)mre
  • 22f21739Records: note rebase before mergemre
  • f7368ea3Records: mission 011 day39, waits for lisbethmre
  • 9515d2cdRecords: jb20 livemre
  • 019f6601ui gate: comment names the open bug components#27 (workaround, not fixed)mre
  • 277a2722README: provenance linemre
  • 4169ca6aREADME: sync pinmre