mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-23 20:34:40 +02:00
Merge branch 'master' into playlists
This commit is contained in:
commit
7aa0ddb71f
33 changed files with 601 additions and 523 deletions
|
@ -92,11 +92,15 @@ class FeedEpisode {
|
|||
const media = libraryItem.media
|
||||
const mediaMetadata = media.metadata
|
||||
|
||||
var title = audioTrack.title
|
||||
if (libraryItem.media.chapters.length) {
|
||||
// If audio track start and chapter start are within 1 seconds of eachother then use the chapter title
|
||||
var matchingChapter = libraryItem.media.chapters.find(ch => Math.abs(ch.start - audioTrack.startOffset) < 1)
|
||||
if (matchingChapter && matchingChapter.title) title = matchingChapter.title
|
||||
let title = audioTrack.title
|
||||
if (libraryItem.media.tracks.length == 1) { // If audiobook is a single file, use book title instead of chapter/file title
|
||||
title = libraryItem.media.metadata.title
|
||||
} else {
|
||||
if (libraryItem.media.chapters.length) {
|
||||
// If audio track start and chapter start are within 1 seconds of eachother then use the chapter title
|
||||
var matchingChapter = libraryItem.media.chapters.find(ch => Math.abs(ch.start - audioTrack.startOffset) < 1)
|
||||
if (matchingChapter && matchingChapter.title) title = matchingChapter.title
|
||||
}
|
||||
}
|
||||
|
||||
this.id = String(audioTrack.index)
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
const Ffmpeg = require('../libs/fluentFfmpeg')
|
||||
|
||||
const EventEmitter = require('events')
|
||||
const Path = require('path')
|
||||
const fs = require('../libs/fsExtra')
|
||||
const Logger = require('../Logger')
|
||||
const SocketAuthority = require('../SocketAuthority')
|
||||
|
||||
const fs = require('../libs/fsExtra')
|
||||
const Ffmpeg = require('../libs/fluentFfmpeg')
|
||||
|
||||
const { secondsToTimestamp } = require('../utils/index')
|
||||
const { writeConcatFile } = require('../utils/ffmpegHelpers')
|
||||
const { AudioMimeType } = require('../utils/constants')
|
||||
|
@ -10,14 +14,13 @@ const hlsPlaylistGenerator = require('../utils/hlsPlaylistGenerator')
|
|||
const AudioTrack = require('./files/AudioTrack')
|
||||
|
||||
class Stream extends EventEmitter {
|
||||
constructor(sessionId, streamPath, user, libraryItem, episodeId, startTime, clientEmitter, transcodeOptions = {}) {
|
||||
constructor(sessionId, streamPath, user, libraryItem, episodeId, startTime, transcodeOptions = {}) {
|
||||
super()
|
||||
|
||||
this.id = sessionId
|
||||
this.user = user
|
||||
this.libraryItem = libraryItem
|
||||
this.episodeId = episodeId
|
||||
this.clientEmitter = clientEmitter
|
||||
|
||||
this.transcodeOptions = transcodeOptions
|
||||
|
||||
|
@ -408,7 +411,7 @@ class Stream extends EventEmitter {
|
|||
}
|
||||
|
||||
clientEmit(evtName, data) {
|
||||
if (this.clientEmitter) this.clientEmitter(this.user.id, evtName, data)
|
||||
SocketAuthority.clientEmitter(this.user.id, evtName, data)
|
||||
}
|
||||
|
||||
getAudioTrack() {
|
||||
|
|
|
@ -63,12 +63,12 @@ class MediaProgress {
|
|||
this.isFinished = !!progress.isFinished || this.progress == 1
|
||||
this.hideFromContinueListening = !!progress.hideFromContinueListening
|
||||
this.lastUpdate = Date.now()
|
||||
this.startedAt = Date.now()
|
||||
this.finishedAt = null
|
||||
if (this.isFinished) {
|
||||
this.finishedAt = Date.now()
|
||||
this.finishedAt = progress.finishedAt || Date.now()
|
||||
this.progress = 1
|
||||
}
|
||||
this.startedAt = progress.startedAt || this.finishedAt || Date.now()
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
|
@ -95,7 +95,7 @@ class MediaProgress {
|
|||
// If time remaining is less than 5 seconds then mark as finished
|
||||
if ((this.progress >= 1 || (this.duration && !isNaN(timeRemaining) && timeRemaining < 5))) {
|
||||
this.isFinished = true
|
||||
this.finishedAt = Date.now()
|
||||
this.finishedAt = payload.finishedAt || Date.now()
|
||||
this.progress = 1
|
||||
} else if (this.progress < 1 && this.isFinished) {
|
||||
this.isFinished = false
|
||||
|
@ -103,7 +103,7 @@ class MediaProgress {
|
|||
}
|
||||
|
||||
if (!this.startedAt) {
|
||||
this.startedAt = Date.now()
|
||||
this.startedAt = this.finishedAt || Date.now()
|
||||
}
|
||||
if (hasUpdates) {
|
||||
if (payload.hideFromContinueListening === undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue