Fix multi-select, add new book flag

This commit is contained in:
Mark Cooper 2021-09-01 13:47:18 -05:00
parent 234653b549
commit 0c017c4227
15 changed files with 106 additions and 36 deletions

View file

@ -30,6 +30,12 @@ class HlsController {
var streamId = req.params.stream
var fullFilePath = Path.join(this.MetadataPath, streamId, req.params.file)
// development test stream - ignore
if (streamId === 'test') {
Logger.debug('Test Stream Request', streamId, req.headers, fullFilePath)
return res.sendFile(fullFilePath)
}
var exists = await fs.pathExists(fullFilePath)
if (!exists) {
Logger.warn('File path does not exist', fullFilePath)

View file

@ -3,6 +3,7 @@ const express = require('express')
const ip = require('ip')
const Logger = require('./Logger')
// Not functional at the moment - just an idea
class RssFeeds {
constructor(Port, db) {
this.Port = Port

View file

@ -133,6 +133,7 @@ class Server {
app.use('/api', this.authMiddleware.bind(this), this.apiController.router)
app.use('/hls', this.authMiddleware.bind(this), this.hlsController.router)
// app.use('/hls', this.hlsController.router)
app.use('/feeds', this.rssFeeds.router)
app.post('/login', (req, res) => this.auth.login(req, res))
@ -142,6 +143,21 @@ class Server {
res.json({ success: true })
})
// Used in development to set-up streams without authentication
if (process.env.NODE_ENV !== 'production') {
app.use('/test-hls', this.hlsController.router)
app.get('/test-stream/:id', async (req, res) => {
var uri = await this.streamManager.openTestStream(this.MetadataPath, req.params.id)
res.send(uri)
})
app.get('/catalog.json', (req, res) => {
Logger.error('Catalog request made', req.headers)
res.json()
})
}
this.server.listen(this.Port, this.Host, () => {
Logger.info(`Running on http://${this.Host}:${this.Port}`)
})

View file

@ -1,4 +1,5 @@
const Stream = require('./Stream')
const StreamTest = require('./test/StreamTest')
const Logger = require('./Logger')
const fs = require('fs-extra')
const Path = require('path')
@ -100,6 +101,23 @@ class StreamManager {
this.db.updateUserStream(client.user.id, null)
}
async openTestStream(streamPath, audiobookId) {
Logger.info('Open Stream Test Request', audiobookId)
var audiobook = this.audiobooks.find(ab => ab.id === audiobookId)
var stream = new StreamTest(streamPath, audiobook)
stream.on('closed', () => {
console.log('Stream closed')
})
var playlistUri = await stream.generatePlaylist()
stream.start()
Logger.info('Stream Playlist', playlistUri)
Logger.info('Test Stream Opened for audiobook', audiobook.title, 'with streamId', stream.id)
return playlistUri
}
streamUpdate(socket, { currentTime, streamId }) {
var client = socket.sheepClient
if (!client || !client.stream) {