Merge branch 'master' into socket-fixes

This commit is contained in:
advplyr 2022-12-23 07:27:14 -06:00
commit 33e183b802
18 changed files with 491 additions and 134 deletions

View file

@ -230,27 +230,30 @@ class CoverManager {
}
async saveEmbeddedCoverArt(libraryItem) {
var audioFileWithCover = null
if (libraryItem.mediaType === 'book') audioFileWithCover = libraryItem.media.audioFiles.find(af => af.embeddedCoverArt)
else {
var episodeWithCover = libraryItem.media.episodes.find(ep => ep.audioFile.embeddedCoverArt)
const audioFileWithCover = null
if (libraryItem.mediaType === 'book') {
audioFileWithCover = libraryItem.media.audioFiles.find(af => af.embeddedCoverArt)
} else if (libraryItem.mediaType == 'podcast') {
const episodeWithCover = libraryItem.media.episodes.find(ep => ep.audioFile.embeddedCoverArt)
if (episodeWithCover) audioFileWithCover = episodeWithCover.audioFile
} else if (libraryItem.mediaType === 'music') {
audioFileWithCover = libraryItem.media.audioFile
}
if (!audioFileWithCover) return false
var coverDirPath = this.getCoverDirectory(libraryItem)
const coverDirPath = this.getCoverDirectory(libraryItem)
await fs.ensureDir(coverDirPath)
var coverFilename = audioFileWithCover.embeddedCoverArt === 'png' ? 'cover.png' : 'cover.jpg'
var coverFilePath = Path.join(coverDirPath, coverFilename)
const coverFilename = audioFileWithCover.embeddedCoverArt === 'png' ? 'cover.png' : 'cover.jpg'
const coverFilePath = Path.join(coverDirPath, coverFilename)
var coverAlreadyExists = await fs.pathExists(coverFilePath)
const coverAlreadyExists = await fs.pathExists(coverFilePath)
if (coverAlreadyExists) {
Logger.warn(`[CoverManager] Extract embedded cover art but cover already exists for "${libraryItem.media.metadata.title}" - bail`)
return false
}
var success = await extractCoverArt(audioFileWithCover.metadata.path, coverFilePath)
const success = await extractCoverArt(audioFileWithCover.metadata.path, coverFilePath)
if (success) {
await filePerms.setDefault(coverFilePath)

View file

@ -127,7 +127,7 @@ class PlaybackSessionManager {
const shouldDirectPlay = options.forceDirectPlay || (!options.forceTranscode && libraryItem.media.checkCanDirectPlay(options, episodeId))
const mediaPlayer = options.mediaPlayer || 'unknown'
const userProgress = user.getMediaProgress(libraryItem.id, episodeId)
const userProgress = libraryItem.isMusic ? null : user.getMediaProgress(libraryItem.id, episodeId)
let userStartTime = 0
if (userProgress) {
if (userProgress.isFinished) {