mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-09 03:04:08 -04:00
Include durationSeconds on RSS podcast episode parsed from duration
This commit is contained in:
parent
c150ed4e98
commit
7b92c15a46
@ -39,7 +39,7 @@
|
|||||||
<!-- published -->
|
<!-- published -->
|
||||||
<p class="text-xs text-gray-300 w-40">Published {{ episode.publishedAt ? $dateDistanceFromNow(episode.publishedAt) : 'Unknown' }}</p>
|
<p class="text-xs text-gray-300 w-40">Published {{ episode.publishedAt ? $dateDistanceFromNow(episode.publishedAt) : 'Unknown' }}</p>
|
||||||
<!-- duration -->
|
<!-- duration -->
|
||||||
<p v-if="episode.duration && !isNaN(episode.duration) && Number(episode.duration) > 0" class="text-xs text-gray-300 min-w-28">{{ $strings.LabelDuration }}: {{ $elapsedPretty(Number(episode.duration)) }}</p>
|
<p v-if="episode.durationSeconds && !isNaN(episode.durationSeconds)" class="text-xs text-gray-300 min-w-28">{{ $strings.LabelDuration }}: {{ $elapsedPretty(episode.durationSeconds) }}</p>
|
||||||
<!-- size -->
|
<!-- size -->
|
||||||
<p v-if="episode.enclosure?.length && !isNaN(episode.enclosure.length) && Number(episode.enclosure.length) > 0" class="text-xs text-gray-300">{{ $strings.LabelSize }}: {{ $bytesPretty(Number(episode.enclosure.length)) }}</p>
|
<p v-if="episode.enclosure?.length && !isNaN(episode.enclosure.length) && Number(episode.enclosure.length) > 0" class="text-xs text-gray-300">{{ $strings.LabelSize }}: {{ $bytesPretty(Number(episode.enclosure.length)) }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,6 +25,7 @@ const Fuse = require('../libs/fusejs')
|
|||||||
* @property {string} episode
|
* @property {string} episode
|
||||||
* @property {string} author
|
* @property {string} author
|
||||||
* @property {string} duration
|
* @property {string} duration
|
||||||
|
* @property {number|null} durationSeconds - Parsed from duration string if duration is valid
|
||||||
* @property {string} explicit
|
* @property {string} explicit
|
||||||
* @property {number} publishedAt - Unix timestamp
|
* @property {number} publishedAt - Unix timestamp
|
||||||
* @property {{ url: string, type?: string, length?: string }} enclosure
|
* @property {{ url: string, type?: string, length?: string }} enclosure
|
||||||
@ -217,8 +218,9 @@ function extractEpisodeData(item) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Extract psc:chapters if duration is set
|
// Extract psc:chapters if duration is set
|
||||||
let episodeDuration = !isNaN(episode.duration) ? timestampToSeconds(episode.duration) : null
|
episode.durationSeconds = episode.duration ? timestampToSeconds(episode.duration) : null
|
||||||
if (item['psc:chapters']?.[0]?.['psc:chapter']?.length && episodeDuration) {
|
|
||||||
|
if (item['psc:chapters']?.[0]?.['psc:chapter']?.length && episode.durationSeconds) {
|
||||||
// Example chapter:
|
// Example chapter:
|
||||||
// {"id":0,"start":0,"end":43.004286,"title":"chapter 1"}
|
// {"id":0,"start":0,"end":43.004286,"title":"chapter 1"}
|
||||||
|
|
||||||
@ -244,7 +246,7 @@ function extractEpisodeData(item) {
|
|||||||
} else {
|
} else {
|
||||||
episode.chapters = cleanedChapters.map((chapter, index) => {
|
episode.chapters = cleanedChapters.map((chapter, index) => {
|
||||||
const nextChapter = cleanedChapters[index + 1]
|
const nextChapter = cleanedChapters[index + 1]
|
||||||
const end = nextChapter ? nextChapter.start : episodeDuration
|
const end = nextChapter ? nextChapter.start : episode.durationSeconds
|
||||||
return {
|
return {
|
||||||
id: chapter.id,
|
id: chapter.id,
|
||||||
title: chapter.title,
|
title: chapter.title,
|
||||||
@ -273,6 +275,7 @@ function cleanEpisodeData(data) {
|
|||||||
episode: data.episode || '',
|
episode: data.episode || '',
|
||||||
author: data.author || '',
|
author: data.author || '',
|
||||||
duration: data.duration || '',
|
duration: data.duration || '',
|
||||||
|
durationSeconds: data.durationSeconds || null,
|
||||||
explicit: data.explicit || '',
|
explicit: data.explicit || '',
|
||||||
publishedAt,
|
publishedAt,
|
||||||
enclosure: data.enclosure,
|
enclosure: data.enclosure,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user