jukebox
All repositories: gitoria
2.8 KB
// project.hl — jukebox: THE MAP. Config, routes and the timer. A network media player for the music on loreana; this// mission is the library scanner, the mpackdb database and the JSON API (no screens yet).//// WHERE WHAT IS (README "Files"):// settings (library paths) and the storage folders lib/settings.hl// reading one file's tags into a song record lib/tags.hl (+ lib/id3.hl, lib/id3-helpers.hl, lib/mpeg.hl)// the scanner (walk, incremental, vanished files) lib/library.hl (+ lib/scan-state.hl); when it runs: lib/schedule.hl// covers cache lib/covers.hl// the database (the one place that knows mpackdb) lib/db.hl; albums and artists tables: lib/catalog.hl// pages, search, shuffle, stats lib/browse.hl (+ lib/order-cache.hl)// the JSON routes lib/api.hl (+ lib/api-helpers.hl, lib/jsoncheck.hl)// env, text folding, numbers lib/util.hl// the start page, all CSS components/home.hl, components/styles.hlimport WebFramework from 'hl:web'import { env } from 'hl:proc'import { every } from 'hl:time'import Styles from './components/styles.hl'import Home from './components/home.hl'import { ensureStorage } from './lib/settings.hl'import { armFirst, tick, applyLine, finished } from './lib/schedule.hl'import { apiStats, apiSongs, apiArtists, apiAlbums, apiSearch, apiShuffle, apiCover, apiRescan, apiSettings, apiNotFound } from './lib/api.hl'static siteName = "jukebox"appTitle = siteNamestyles = Stylesroutes = [{ pattern = "/api/stats" function = apiStats }{ pattern = "/api/songs" function = apiSongs }{ pattern = "/api/artists" function = apiArtists }{ pattern = "/api/albums" function = apiAlbums }{ pattern = "/api/search" function = apiSearch }{ pattern = "/api/shuffle" function = apiShuffle }{ pattern = "/api/cover/:id" function = apiCover }{ pattern = "/api/rescan" function = apiRescan }{ pattern = "/api/settings" function = apiSettings }{ pattern = "/" component = Home }]// JUKEBOX_PORT (default 8700, the slot's first port); HL_HOST binds a single interface; JUKEBOX_WATCH=0 = no dev watcherport = env('JUKEBOX_PORT') != null ? toNumber(env('JUKEBOX_PORT')) : 8700watching = env('JUKEBOX_WATCH') != '0'server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = 'jukeboxsid')ensureStorage()armFirst()// once a second the scheduler looks whether a scan is due or asked for (lib/schedule.hl)// the scan runs in a child process; its progress lines and its end come back hereticker = every(1)on ticker.tick() {child = tick()if (child != null) {on child.line({ line, stream }) { applyLine(line) }on child.exit({ exit, pid }) { finished(exit) }}}on Error(e) { console.log('error absorbed: ' + e.message) }
Branches
Latest commits
- 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