jukebox
All repositories: gitoria
4.3 KB
// project.hl — jukebox: THE MAP. Config, routes and the timer. A network media player for the music on loreana; this// missions: the scanner, the database and the JSON API (JB1); the library screens and playing in the browser (JB2).//// 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 audio route /stream/<id> (HTTP Range) lib/stream.hl; rows of the lists and the player queue: lib/rows.hl// the screens components/main.hl (shell + player bar), songs.hl artists.hl albums.hl artist.hl album.hl search.hl// vendored (components/SOURCE): media-player, virtual-list, icons; theme/ (layouts); all our CSS: components/styles.hlimport WebFramework from 'hl:web'import { env, exit } from 'hl:proc'import { every } from 'hl:time'import Styles from './components/styles.hl'import Songs from './components/songs.hl'import Artists from './components/artists.hl'import Albums from './components/albums.hl'import Artist from './components/artist.hl'import Album from './components/album.hl'import Search from './components/search.hl'import { needsFix, fixKeys } from './lib/migrate.hl'import { rebuildCatalog } from './lib/catalog.hl'import { ensureStorage } from './lib/settings.hl'import { armFirst, tick, applyLine, finished } from './lib/schedule.hl'import { serve as streamSong } from './lib/stream.hl'import { apiStats, apiSongs, apiArtists, apiAlbums, apiSearch, apiShuffle, apiPlayed, apiCopies, apiQueue, apiCover, apiThumb, 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/played/:id" function = apiPlayed }{ pattern = "/api/copies/:id" function = apiCopies }{ pattern = "/api/queue" function = apiQueue }{ pattern = "/api/cover/:id" function = apiCover }{ pattern = "/api/thumb/:id" function = apiThumb }{ pattern = "/stream/:id" function = streamSong }{ pattern = "/api/rescan" function = apiRescan }{ pattern = "/api/settings" function = apiSettings }{ pattern = "/" component = Songs }{ pattern = "/artists" component = Artists }{ pattern = "/albums" component = Albums }{ pattern = "/artists/:id" component = Artist }{ pattern = "/albums/:id" component = Album }{ pattern = "/search" component = Search }]// 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()if (needsFix()) {fixed = fixKeys()rebuilt = rebuildCatalog()console.log('keys fixed on ' + fixed + ' songs; ' + rebuilt.albums + ' albums, ' + rebuilt.artists + ' artists')}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) {if (e.phase == 'startup') { console.log('jukebox: startup error: ' + e.message) exit(1) }console.log('error absorbed: ' + e.message)}
Branches
Latest commits
- 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
- 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
- 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
- 04f5d9d5Merge branch 'day41' into mainJukebox
- 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