From 392bb4e290cd439d6080539589e42f16b632b757 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sat, 6 Jun 2026 09:36:43 -0700 Subject: [PATCH 1/9] update --- .github/workflows/docker-build.yml | 16 +-- .../components/modals/item/tabs/Schedule.vue | 20 +++- client/components/modals/podcast/NewModal.vue | 7 +- client/strings/en-us.json | 2 + server/controllers/LibraryItemController.js | 14 +++ server/managers/PodcastManager.js | 90 ++++++++++++++++ ...36.0-podcast-add-fetch-episode-metadata.js | 68 ++++++++++++ server/models/LibraryItem.js | 14 +++ server/models/Podcast.js | 11 ++ server/scanner/PodcastScanner.js | 101 ++++++++++++++++++ .../utils/generators/abmetadataGenerator.js | 33 ++++++ 11 files changed, 362 insertions(+), 14 deletions(-) create mode 100644 server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fdb57fbc5..dea55c1f9 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: tags: - description: 'Docker Tag' + description: 'Docker Tag (e.g. latest)' required: true default: 'latest' push: @@ -22,7 +22,7 @@ on: jobs: build: - if: ${{ !contains(github.event.head_commit.message, 'skip ci') && github.repository == 'advplyr/audiobookshelf' }} + if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} runs-on: ubuntu-24.04 steps: @@ -33,8 +33,9 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: advplyr/audiobookshelf,ghcr.io/${{ github.repository_owner }}/audiobookshelf + images: entree3000/audiobookshelf tags: | + type=edge,branch=main type=edge,branch=master type=semver,pattern={{version}} @@ -58,17 +59,10 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Login to ghcr - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PASSWORD }} - - name: Build image uses: docker/build-push-action@v6 with: - tags: ${{ github.event.inputs.tags || steps.meta.outputs.tags }} + tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: . platforms: linux/amd64,linux/arm64 diff --git a/client/components/modals/item/tabs/Schedule.vue b/client/components/modals/item/tabs/Schedule.vue index 0faa29630..d66874c56 100644 --- a/client/components/modals/item/tabs/Schedule.vue +++ b/client/components/modals/item/tabs/Schedule.vue @@ -31,9 +31,16 @@ + + -
+
{{ isUpdated ? $strings.ButtonSave : $strings.MessageNoUpdatesWereNecessary }} @@ -54,6 +61,7 @@ export default { data() { return { enableAutoDownloadEpisodes: false, + enableFetchEpisodeMetadata: false, cronExpression: null, newMaxEpisodesToKeep: 0, newMaxNewEpisodesToDownload: 0 @@ -94,6 +102,9 @@ export default { autoDownloadEpisodes() { return !!this.media.autoDownloadEpisodes }, + fetchEpisodeMetadata() { + return !!this.media.fetchEpisodeMetadata + }, autoDownloadSchedule() { return this.media.autoDownloadSchedule }, @@ -104,7 +115,7 @@ export default { return this.media.maxNewEpisodesToDownload }, isUpdated() { - return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) + return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) || this.fetchEpisodeMetadata !== this.enableFetchEpisodeMetadata } }, methods: { @@ -152,6 +163,10 @@ export default { updatePayload.maxNewEpisodesToDownload = this.newMaxNewEpisodesToDownload } + if (this.enableFetchEpisodeMetadata !== this.fetchEpisodeMetadata) { + updatePayload.fetchEpisodeMetadata = this.enableFetchEpisodeMetadata + } + this.updateDetails(updatePayload) }, async updateDetails(updatePayload) { @@ -175,6 +190,7 @@ export default { }, init() { this.enableAutoDownloadEpisodes = this.autoDownloadEpisodes + this.enableFetchEpisodeMetadata = this.fetchEpisodeMetadata this.cronExpression = this.autoDownloadSchedule this.newMaxEpisodesToKeep = this.maxEpisodesToKeep this.newMaxNewEpisodesToDownload = this.maxNewEpisodesToDownload diff --git a/client/components/modals/podcast/NewModal.vue b/client/components/modals/podcast/NewModal.vue index 33e6dbc4b..02b783985 100644 --- a/client/components/modals/podcast/NewModal.vue +++ b/client/components/modals/podcast/NewModal.vue @@ -56,6 +56,9 @@
+
+ +
{{ $strings.ButtonSubmit }}
@@ -94,6 +97,7 @@ export default { itunesId: '', itunesArtistId: '', autoDownloadEpisodes: false, + fetchEpisodeMetadata: false, language: '', explicit: false, type: '' @@ -196,7 +200,8 @@ export default { explicit: this.podcast.explicit, type: this.podcast.type }, - autoDownloadEpisodes: this.podcast.autoDownloadEpisodes + autoDownloadEpisodes: this.podcast.autoDownloadEpisodes, + fetchEpisodeMetadata: this.podcast.fetchEpisodeMetadata } } console.log('Podcast payload', podcastPayload) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index fb2bcb281..c02bc4455 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -191,6 +191,7 @@ "HeaderRemoveEpisodes": "Remove {0} Episodes", "HeaderSavedMediaProgress": "Saved Media Progress", "HeaderSchedule": "Schedule", + "HeaderEpisodeMetadata": "Episode Metadata", "HeaderScheduleEpisodeDownloads": "Schedule Automatic Episode Downloads", "HeaderScheduleLibraryScans": "Schedule Automatic Library Scans", "HeaderSession": "Session", @@ -256,6 +257,7 @@ "LabelAuthorLastFirst": "Author (Last, First)", "LabelAuthors": "Authors", "LabelAutoDownloadEpisodes": "Auto Download Episodes", + "LabelFetchEpisodeMetadata": "Store episode metadata from RSS feed", "LabelAutoFetchMetadata": "Auto Fetch Metadata", "LabelAutoFetchMetadataHelp": "Fetches metadata for title, author, and series to streamline uploading. Additional metadata may have to be matched after upload.", "LabelAutoLaunch": "Auto Launch", diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 07b4ee67f..7fcf57911 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -215,6 +215,7 @@ class LibraryItemController { // Podcast specific let isPodcastAutoDownloadUpdated = false + let isFetchEpisodeMetadataEnabled = false if (req.libraryItem.isPodcast) { if (mediaPayload.autoDownloadEpisodes !== undefined && req.libraryItem.media.autoDownloadEpisodes !== mediaPayload.autoDownloadEpisodes) { isPodcastAutoDownloadUpdated = true @@ -226,6 +227,11 @@ class LibraryItemController { Logger.error(`[LibraryItemController] Invalid auto download schedule cron expression "${mediaPayload.autoDownloadSchedule}" for library item "${req.libraryItem.media.title}"`) return res.status(400).send('Invalid auto download schedule cron expression') } + + // Check if fetchEpisodeMetadata is being toggled on + if (mediaPayload.fetchEpisodeMetadata && !req.libraryItem.media.fetchEpisodeMetadata) { + isFetchEpisodeMetadataEnabled = true + } } let hasUpdates = (await req.libraryItem.media.updateFromRequest(mediaPayload)) || mediaPayload.url @@ -276,6 +282,14 @@ class LibraryItemController { this.cronManager.checkUpdatePodcastCron(req.libraryItem) } + // Fetch and populate episode metadata from RSS when toggle is turned on + if (isFetchEpisodeMetadataEnabled) { + const episodesUpdated = await this.podcastManager.populateEpisodeMetadataFromFeed(req.libraryItem) + if (episodesUpdated) { + await req.libraryItem.saveMetadataFile() + } + } + Logger.debug(`[LibraryItemController] Updated library item media ${req.libraryItem.media.title}`) SocketAuthority.libraryItemEmitter('item_updated', req.libraryItem) } diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index bdf6fc764..c9d8026c1 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -250,6 +250,11 @@ class PodcastManager { await libraryItem.media.save() } + // Save episode metadata to metadata.json if fetchEpisodeMetadata is enabled + if (libraryItem.media.fetchEpisodeMetadata) { + await libraryItem.saveMetadataFile() + } + SocketAuthority.libraryItemEmitter('item_updated', libraryItem) const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id) podcastEpisodeExpanded.libraryItem = libraryItem.toOldJSONExpanded() @@ -739,5 +744,90 @@ class PodcastManager { TaskManager.taskFinished(task) Logger.info(`[PodcastManager] createPodcastsFromFeedUrls: Finished OPML import. Created ${numPodcastsAdded} podcasts out of ${rssFeedUrls.length} RSS feed URLs`) } + + /** + * Fetch episode metadata from RSS feed and backfill missing fields on existing episodes + * + * @param {import('../models/LibraryItem')} libraryItem - must have media.podcastEpisodes loaded + * @returns {Promise} - true if any episodes were updated + */ + async populateEpisodeMetadataFromFeed(libraryItem) { + const podcast = libraryItem.media + if (!podcast.feedURL) { + Logger.warn(`[PodcastManager] Cannot fetch episode metadata - no feed URL for "${podcast.title}"`) + return false + } + + const feed = await getPodcastFeed(podcast.feedURL).catch((error) => { + Logger.error(`[PodcastManager] Failed to fetch feed for episode metadata population`, error) + return null + }) + if (!feed?.episodes?.length) { + Logger.warn(`[PodcastManager] No episodes found in feed for "${podcast.title}"`) + return false + } + + const episodes = podcast.podcastEpisodes || [] + let hasUpdates = false + + for (const episode of episodes) { + // Match by GUID first, then by title + const guid = episode.extraData?.guid + let matched = null + if (guid) { + matched = feed.episodes.find((fe) => fe.guid === guid) + } + if (!matched) { + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + matched = feed.episodes.find((fe) => (fe.title || '').trim().toLowerCase() === episodeTitle) + } + } + + if (!matched) continue + + let episodeUpdated = false + if (!episode.description && matched.description) { + episode.description = matched.description + episodeUpdated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + episodeUpdated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + episodeUpdated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + episodeUpdated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + episodeUpdated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + episodeUpdated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + episode.changed('extraData', true) + episodeUpdated = true + } + + if (episodeUpdated) { + await episode.save() + hasUpdates = true + } + } + + if (hasUpdates) { + Logger.info(`[PodcastManager] Populated episode metadata from feed for "${podcast.title}"`) + } + + return hasUpdates + } } module.exports = PodcastManager diff --git a/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js new file mode 100644 index 000000000..4bd69df4d --- /dev/null +++ b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js @@ -0,0 +1,68 @@ +/** + * @typedef MigrationContext + * @property {import('sequelize').QueryInterface} queryInterface - a Sequelize QueryInterface object. + * @property {import('../Logger')} logger - a Logger object. + * + * @typedef MigrationOptions + * @property {MigrationContext} context - an object containing the migration context. + */ + +const migrationVersion = '2.36.0' +const migrationName = `${migrationVersion}-podcast-add-fetch-episode-metadata` +const loggerPrefix = `[${migrationVersion} migration]` + +/** + * This migration script adds the fetchEpisodeMetadata column to the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function up({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} UPGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (!tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Adding fetchEpisodeMetadata column to podcasts table`) + await queryInterface.addColumn('podcasts', 'fetchEpisodeMetadata', { + type: queryInterface.sequelize.Sequelize.DataTypes.BOOLEAN, + defaultValue: false, + allowNull: false + }) + logger.info(`${loggerPrefix} Added fetchEpisodeMetadata column to podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column already exists in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} UPGRADE END: ${migrationName}`) +} + +/** + * This migration script removes the fetchEpisodeMetadata column from the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function down({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} DOWNGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Removing fetchEpisodeMetadata column from podcasts table`) + await queryInterface.removeColumn('podcasts', 'fetchEpisodeMetadata') + logger.info(`${loggerPrefix} Removed fetchEpisodeMetadata column from podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column does not exist in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} DOWNGRADE END: ${migrationName}`) +} + +module.exports = { up, down } diff --git a/server/models/LibraryItem.js b/server/models/LibraryItem.js index b33fa585c..2adeaf0b8 100644 --- a/server/models/LibraryItem.js +++ b/server/models/LibraryItem.js @@ -672,6 +672,20 @@ class LibraryItem extends Model { explicit: !!mediaExpanded.explicit, podcastType: mediaExpanded.podcastType } + + if (mediaExpanded.fetchEpisodeMetadata && mediaExpanded.podcastEpisodes?.length) { + jsonObject.episodes = mediaExpanded.podcastEpisodes.map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } } return fsExtra diff --git a/server/models/Podcast.js b/server/models/Podcast.js index 6dbe1cd19..3f5fcbf15 100644 --- a/server/models/Podcast.js +++ b/server/models/Podcast.js @@ -44,6 +44,8 @@ class Podcast extends Model { /** @type {boolean} */ this.explicit /** @type {boolean} */ + this.fetchEpisodeMetadata + /** @type {boolean} */ this.autoDownloadEpisodes /** @type {string} */ this.autoDownloadSchedule @@ -108,6 +110,7 @@ class Podcast extends Model { language: typeof payload.metadata.language === 'string' ? payload.metadata.language : null, podcastType: typeof payload.metadata.type === 'string' ? payload.metadata.type : null, explicit: !!payload.metadata.explicit, + fetchEpisodeMetadata: !!payload.fetchEpisodeMetadata, autoDownloadEpisodes: !!payload.autoDownloadEpisodes, autoDownloadSchedule: autoDownloadSchedule || global.ServerSettings.podcastEpisodeSchedule, lastEpisodeCheck: new Date(), @@ -146,6 +149,7 @@ class Podcast extends Model { podcastType: DataTypes.STRING, explicit: DataTypes.BOOLEAN, + fetchEpisodeMetadata: DataTypes.BOOLEAN, autoDownloadEpisodes: DataTypes.BOOLEAN, autoDownloadSchedule: DataTypes.STRING, lastEpisodeCheck: DataTypes.DATE, @@ -269,6 +273,10 @@ class Podcast extends Model { hasUpdates = true } + if (payload.fetchEpisodeMetadata !== undefined && payload.fetchEpisodeMetadata !== this.fetchEpisodeMetadata) { + this.fetchEpisodeMetadata = !!payload.fetchEpisodeMetadata + hasUpdates = true + } if (payload.autoDownloadEpisodes !== undefined && payload.autoDownloadEpisodes !== this.autoDownloadEpisodes) { this.autoDownloadEpisodes = !!payload.autoDownloadEpisodes hasUpdates = true @@ -443,6 +451,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((episode) => episode.toOldJSON(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -459,6 +468,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], numEpisodes: this.podcastEpisodes?.length || 0, + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -483,6 +493,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((e) => e.toOldJSONExpanded(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, diff --git a/server/scanner/PodcastScanner.js b/server/scanner/PodcastScanner.js index f3241d536..a56a42600 100644 --- a/server/scanner/PodcastScanner.js +++ b/server/scanner/PodcastScanner.js @@ -12,6 +12,71 @@ const fsExtra = require('../libs/fsExtra') const PodcastEpisode = require('../models/PodcastEpisode') const AbsMetadataFileScanner = require('./AbsMetadataFileScanner') const htmlSanitizer = require('../utils/htmlSanitizer') +const Logger = require('../Logger') + +/** + * Match a podcast episode to an entry in the metadata episodes array + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object[]} metadataEpisodes - episodes array from metadata.json + * @returns {Object|null} + */ +function matchEpisodeMetadata(episode, metadataEpisodes) { + // Prefer GUID match + const guid = episode.extraData?.guid + if (guid) { + const match = metadataEpisodes.find((me) => me.guid === guid) + if (match) return match + } + // Fall back to title match (case-insensitive, trimmed) + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + const match = metadataEpisodes.find((me) => (me.title || '').trim().toLowerCase() === episodeTitle) + if (match) return match + } + return null +} + +/** + * Backfill null episode fields from matched metadata + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object} matched - matched metadata entry + * @returns {boolean} whether any fields were updated + */ +function applyEpisodeMetadata(episode, matched) { + let updated = false + if (!episode.description && matched.description) { + episode.description = matched.description + updated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + updated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + updated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + updated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + updated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + updated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + if (typeof episode.changed === 'function') { + episode.changed('extraData', true) + } + updated = true + } + return updated +} /** * Metadata for podcasts pulled from files @@ -232,6 +297,17 @@ class PodcastScanner { } } + // Backfill episode metadata from metadata.json if fetchEpisodeMetadata is enabled + if (media.fetchEpisodeMetadata && podcastMetadata.episodes?.length) { + for (const episode of existingPodcastEpisodes) { + const matched = matchEpisodeMetadata(episode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(episode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${episode.title}" from metadata.json`) + await episode.save() + } + } + } + existingLibraryItem.media = media let libraryItemUpdated = false @@ -312,6 +388,16 @@ class PodcastScanner { podcastMetadata.podcastType = 'episodic' } + // Backfill episode metadata from metadata.json if episodes data exists + if (podcastMetadata.episodes?.length) { + for (const newEpisode of newPodcastEpisodes) { + const matched = matchEpisodeMetadata(newEpisode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(newEpisode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${newEpisode.title}" from metadata.json`) + } + } + } + const podcastObject = { ...podcastMetadata, autoDownloadEpisodes: false, @@ -445,6 +531,21 @@ class PodcastScanner { explicit: !!libraryItem.media.explicit, podcastType: libraryItem.media.podcastType } + + if (libraryItem.media.fetchEpisodeMetadata && libraryItem.media.podcastEpisodes?.length) { + jsonObject.episodes = libraryItem.media.podcastEpisodes.map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } + return fsExtra .writeFile(metadataFilePath, JSON.stringify(jsonObject, null, 2)) .then(async () => { diff --git a/server/utils/generators/abmetadataGenerator.js b/server/utils/generators/abmetadataGenerator.js index d0d278752..7bb30e265 100644 --- a/server/utils/generators/abmetadataGenerator.js +++ b/server/utils/generators/abmetadataGenerator.js @@ -84,6 +84,16 @@ function parseJsonMetadataText(text, mediaType) { validated.series = validated.series.map((series) => parseSeriesString.parse(series)).filter(Boolean) } + if (mediaType === 'podcast' && 'episodes' in abmetadataData) { + if (abmetadataData.episodes === null) { + validated.episodes = [] + } else if (Array.isArray(abmetadataData.episodes)) { + validated.episodes = cleanEpisodesArray(abmetadataData.episodes) + } else { + Logger.warn(`[abmetadataGenerator] Invalid metadata key "episodes" expected array, got ${typeof abmetadataData.episodes}`) + } + } + if (mediaType === 'book' && 'chapters' in abmetadataData) { if (abmetadataData.chapters === null) { validated.chapters = [] @@ -148,6 +158,29 @@ function validateMetadataValue(key, value, expectedType) { return undefined } +/** + * @param {Object[]} episodesArray + * @returns {Object[]} + */ +function cleanEpisodesArray(episodesArray) { + const episodes = [] + for (const ep of episodesArray) { + if (!ep.title || typeof ep.title !== 'string') continue + episodes.push({ + title: ep.title, + description: typeof ep.description === 'string' ? ep.description : null, + season: typeof ep.season === 'string' ? ep.season : null, + episode: typeof ep.episode === 'string' ? ep.episode : null, + episodeType: typeof ep.episodeType === 'string' ? ep.episodeType : null, + pubDate: typeof ep.pubDate === 'string' ? ep.pubDate : null, + guid: typeof ep.guid === 'string' ? ep.guid : null, + subtitle: typeof ep.subtitle === 'string' ? ep.subtitle : null, + duration: typeof ep.duration === 'string' ? ep.duration : null + }) + } + return episodes +} + /** * @param {Object[]} chaptersArray * @param {string} mediaTitle From cce9f992b4abe39f96293785a911f92c98c44717 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sat, 6 Jun 2026 09:40:40 -0700 Subject: [PATCH 2/9] update --- .github/workflows/docker-build.yml | 16 +-- .../components/modals/item/tabs/Schedule.vue | 4 +- client/components/modals/podcast/NewModal.vue | 7 +- .../components/widgets/PodcastDetailsEdit.vue | 13 ++- client/strings/en-us.json | 2 + server/controllers/LibraryItemController.js | 14 +++ server/managers/PodcastManager.js | 90 ++++++++++++++++ ...36.0-podcast-add-fetch-episode-metadata.js | 68 ++++++++++++ server/models/LibraryItem.js | 14 +++ server/models/Podcast.js | 11 ++ server/scanner/PodcastScanner.js | 101 ++++++++++++++++++ .../utils/generators/abmetadataGenerator.js | 33 ++++++ 12 files changed, 358 insertions(+), 15 deletions(-) create mode 100644 server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fdb57fbc5..dea55c1f9 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: tags: - description: 'Docker Tag' + description: 'Docker Tag (e.g. latest)' required: true default: 'latest' push: @@ -22,7 +22,7 @@ on: jobs: build: - if: ${{ !contains(github.event.head_commit.message, 'skip ci') && github.repository == 'advplyr/audiobookshelf' }} + if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} runs-on: ubuntu-24.04 steps: @@ -33,8 +33,9 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: advplyr/audiobookshelf,ghcr.io/${{ github.repository_owner }}/audiobookshelf + images: entree3000/audiobookshelf tags: | + type=edge,branch=main type=edge,branch=master type=semver,pattern={{version}} @@ -58,17 +59,10 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Login to ghcr - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PASSWORD }} - - name: Build image uses: docker/build-push-action@v6 with: - tags: ${{ github.event.inputs.tags || steps.meta.outputs.tags }} + tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: . platforms: linux/amd64,linux/arm64 diff --git a/client/components/modals/item/tabs/Schedule.vue b/client/components/modals/item/tabs/Schedule.vue index 0faa29630..4b7d5d966 100644 --- a/client/components/modals/item/tabs/Schedule.vue +++ b/client/components/modals/item/tabs/Schedule.vue @@ -31,6 +31,7 @@ +
@@ -104,8 +105,7 @@ export default { return this.media.maxNewEpisodesToDownload }, isUpdated() { - return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) - } + return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) } }, methods: { updatedMaxEpisodesToKeep() { diff --git a/client/components/modals/podcast/NewModal.vue b/client/components/modals/podcast/NewModal.vue index 33e6dbc4b..02b783985 100644 --- a/client/components/modals/podcast/NewModal.vue +++ b/client/components/modals/podcast/NewModal.vue @@ -56,6 +56,9 @@
+
+ +
{{ $strings.ButtonSubmit }}
@@ -94,6 +97,7 @@ export default { itunesId: '', itunesArtistId: '', autoDownloadEpisodes: false, + fetchEpisodeMetadata: false, language: '', explicit: false, type: '' @@ -196,7 +200,8 @@ export default { explicit: this.podcast.explicit, type: this.podcast.type }, - autoDownloadEpisodes: this.podcast.autoDownloadEpisodes + autoDownloadEpisodes: this.podcast.autoDownloadEpisodes, + fetchEpisodeMetadata: this.podcast.fetchEpisodeMetadata } } console.log('Podcast payload', podcastPayload) diff --git a/client/components/widgets/PodcastDetailsEdit.vue b/client/components/widgets/PodcastDetailsEdit.vue index 0be67df32..f92fad1f1 100644 --- a/client/components/widgets/PodcastDetailsEdit.vue +++ b/client/components/widgets/PodcastDetailsEdit.vue @@ -43,6 +43,11 @@
+
+
+ +
+
@@ -73,7 +78,8 @@ export default { language: null, type: null }, - newTags: [] + newTags: [], + enableFetchEpisodeMetadata: false } }, watch: { @@ -223,6 +229,10 @@ export default { updatePayload.tags = [...this.newTags] } + if (this.enableFetchEpisodeMetadata !== !!this.media.fetchEpisodeMetadata) { + updatePayload.fetchEpisodeMetadata = this.enableFetchEpisodeMetadata + } + return { updatePayload, hasChanges: !!Object.keys(updatePayload).length @@ -244,6 +254,7 @@ export default { this.details.type = this.mediaMetadata.type || 'episodic' this.newTags = [...(this.media.tags || [])] + this.enableFetchEpisodeMetadata = !!this.media.fetchEpisodeMetadata }, submitForm() { this.$emit('submit') diff --git a/client/strings/en-us.json b/client/strings/en-us.json index fb2bcb281..aa0d91926 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -191,6 +191,7 @@ "HeaderRemoveEpisodes": "Remove {0} Episodes", "HeaderSavedMediaProgress": "Saved Media Progress", "HeaderSchedule": "Schedule", + "HeaderEpisodeMetadata": "Episode Metadata", "HeaderScheduleEpisodeDownloads": "Schedule Automatic Episode Downloads", "HeaderScheduleLibraryScans": "Schedule Automatic Library Scans", "HeaderSession": "Session", @@ -256,6 +257,7 @@ "LabelAuthorLastFirst": "Author (Last, First)", "LabelAuthors": "Authors", "LabelAutoDownloadEpisodes": "Auto Download Episodes", + "LabelFetchEpisodeMetadata": "Store Episode Metadata", "LabelAutoFetchMetadata": "Auto Fetch Metadata", "LabelAutoFetchMetadataHelp": "Fetches metadata for title, author, and series to streamline uploading. Additional metadata may have to be matched after upload.", "LabelAutoLaunch": "Auto Launch", diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 07b4ee67f..7fcf57911 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -215,6 +215,7 @@ class LibraryItemController { // Podcast specific let isPodcastAutoDownloadUpdated = false + let isFetchEpisodeMetadataEnabled = false if (req.libraryItem.isPodcast) { if (mediaPayload.autoDownloadEpisodes !== undefined && req.libraryItem.media.autoDownloadEpisodes !== mediaPayload.autoDownloadEpisodes) { isPodcastAutoDownloadUpdated = true @@ -226,6 +227,11 @@ class LibraryItemController { Logger.error(`[LibraryItemController] Invalid auto download schedule cron expression "${mediaPayload.autoDownloadSchedule}" for library item "${req.libraryItem.media.title}"`) return res.status(400).send('Invalid auto download schedule cron expression') } + + // Check if fetchEpisodeMetadata is being toggled on + if (mediaPayload.fetchEpisodeMetadata && !req.libraryItem.media.fetchEpisodeMetadata) { + isFetchEpisodeMetadataEnabled = true + } } let hasUpdates = (await req.libraryItem.media.updateFromRequest(mediaPayload)) || mediaPayload.url @@ -276,6 +282,14 @@ class LibraryItemController { this.cronManager.checkUpdatePodcastCron(req.libraryItem) } + // Fetch and populate episode metadata from RSS when toggle is turned on + if (isFetchEpisodeMetadataEnabled) { + const episodesUpdated = await this.podcastManager.populateEpisodeMetadataFromFeed(req.libraryItem) + if (episodesUpdated) { + await req.libraryItem.saveMetadataFile() + } + } + Logger.debug(`[LibraryItemController] Updated library item media ${req.libraryItem.media.title}`) SocketAuthority.libraryItemEmitter('item_updated', req.libraryItem) } diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index bdf6fc764..c9d8026c1 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -250,6 +250,11 @@ class PodcastManager { await libraryItem.media.save() } + // Save episode metadata to metadata.json if fetchEpisodeMetadata is enabled + if (libraryItem.media.fetchEpisodeMetadata) { + await libraryItem.saveMetadataFile() + } + SocketAuthority.libraryItemEmitter('item_updated', libraryItem) const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id) podcastEpisodeExpanded.libraryItem = libraryItem.toOldJSONExpanded() @@ -739,5 +744,90 @@ class PodcastManager { TaskManager.taskFinished(task) Logger.info(`[PodcastManager] createPodcastsFromFeedUrls: Finished OPML import. Created ${numPodcastsAdded} podcasts out of ${rssFeedUrls.length} RSS feed URLs`) } + + /** + * Fetch episode metadata from RSS feed and backfill missing fields on existing episodes + * + * @param {import('../models/LibraryItem')} libraryItem - must have media.podcastEpisodes loaded + * @returns {Promise} - true if any episodes were updated + */ + async populateEpisodeMetadataFromFeed(libraryItem) { + const podcast = libraryItem.media + if (!podcast.feedURL) { + Logger.warn(`[PodcastManager] Cannot fetch episode metadata - no feed URL for "${podcast.title}"`) + return false + } + + const feed = await getPodcastFeed(podcast.feedURL).catch((error) => { + Logger.error(`[PodcastManager] Failed to fetch feed for episode metadata population`, error) + return null + }) + if (!feed?.episodes?.length) { + Logger.warn(`[PodcastManager] No episodes found in feed for "${podcast.title}"`) + return false + } + + const episodes = podcast.podcastEpisodes || [] + let hasUpdates = false + + for (const episode of episodes) { + // Match by GUID first, then by title + const guid = episode.extraData?.guid + let matched = null + if (guid) { + matched = feed.episodes.find((fe) => fe.guid === guid) + } + if (!matched) { + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + matched = feed.episodes.find((fe) => (fe.title || '').trim().toLowerCase() === episodeTitle) + } + } + + if (!matched) continue + + let episodeUpdated = false + if (!episode.description && matched.description) { + episode.description = matched.description + episodeUpdated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + episodeUpdated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + episodeUpdated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + episodeUpdated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + episodeUpdated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + episodeUpdated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + episode.changed('extraData', true) + episodeUpdated = true + } + + if (episodeUpdated) { + await episode.save() + hasUpdates = true + } + } + + if (hasUpdates) { + Logger.info(`[PodcastManager] Populated episode metadata from feed for "${podcast.title}"`) + } + + return hasUpdates + } } module.exports = PodcastManager diff --git a/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js new file mode 100644 index 000000000..4bd69df4d --- /dev/null +++ b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js @@ -0,0 +1,68 @@ +/** + * @typedef MigrationContext + * @property {import('sequelize').QueryInterface} queryInterface - a Sequelize QueryInterface object. + * @property {import('../Logger')} logger - a Logger object. + * + * @typedef MigrationOptions + * @property {MigrationContext} context - an object containing the migration context. + */ + +const migrationVersion = '2.36.0' +const migrationName = `${migrationVersion}-podcast-add-fetch-episode-metadata` +const loggerPrefix = `[${migrationVersion} migration]` + +/** + * This migration script adds the fetchEpisodeMetadata column to the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function up({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} UPGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (!tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Adding fetchEpisodeMetadata column to podcasts table`) + await queryInterface.addColumn('podcasts', 'fetchEpisodeMetadata', { + type: queryInterface.sequelize.Sequelize.DataTypes.BOOLEAN, + defaultValue: false, + allowNull: false + }) + logger.info(`${loggerPrefix} Added fetchEpisodeMetadata column to podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column already exists in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} UPGRADE END: ${migrationName}`) +} + +/** + * This migration script removes the fetchEpisodeMetadata column from the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function down({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} DOWNGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Removing fetchEpisodeMetadata column from podcasts table`) + await queryInterface.removeColumn('podcasts', 'fetchEpisodeMetadata') + logger.info(`${loggerPrefix} Removed fetchEpisodeMetadata column from podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column does not exist in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} DOWNGRADE END: ${migrationName}`) +} + +module.exports = { up, down } diff --git a/server/models/LibraryItem.js b/server/models/LibraryItem.js index b33fa585c..2adeaf0b8 100644 --- a/server/models/LibraryItem.js +++ b/server/models/LibraryItem.js @@ -672,6 +672,20 @@ class LibraryItem extends Model { explicit: !!mediaExpanded.explicit, podcastType: mediaExpanded.podcastType } + + if (mediaExpanded.fetchEpisodeMetadata && mediaExpanded.podcastEpisodes?.length) { + jsonObject.episodes = mediaExpanded.podcastEpisodes.map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } } return fsExtra diff --git a/server/models/Podcast.js b/server/models/Podcast.js index 6dbe1cd19..3f5fcbf15 100644 --- a/server/models/Podcast.js +++ b/server/models/Podcast.js @@ -44,6 +44,8 @@ class Podcast extends Model { /** @type {boolean} */ this.explicit /** @type {boolean} */ + this.fetchEpisodeMetadata + /** @type {boolean} */ this.autoDownloadEpisodes /** @type {string} */ this.autoDownloadSchedule @@ -108,6 +110,7 @@ class Podcast extends Model { language: typeof payload.metadata.language === 'string' ? payload.metadata.language : null, podcastType: typeof payload.metadata.type === 'string' ? payload.metadata.type : null, explicit: !!payload.metadata.explicit, + fetchEpisodeMetadata: !!payload.fetchEpisodeMetadata, autoDownloadEpisodes: !!payload.autoDownloadEpisodes, autoDownloadSchedule: autoDownloadSchedule || global.ServerSettings.podcastEpisodeSchedule, lastEpisodeCheck: new Date(), @@ -146,6 +149,7 @@ class Podcast extends Model { podcastType: DataTypes.STRING, explicit: DataTypes.BOOLEAN, + fetchEpisodeMetadata: DataTypes.BOOLEAN, autoDownloadEpisodes: DataTypes.BOOLEAN, autoDownloadSchedule: DataTypes.STRING, lastEpisodeCheck: DataTypes.DATE, @@ -269,6 +273,10 @@ class Podcast extends Model { hasUpdates = true } + if (payload.fetchEpisodeMetadata !== undefined && payload.fetchEpisodeMetadata !== this.fetchEpisodeMetadata) { + this.fetchEpisodeMetadata = !!payload.fetchEpisodeMetadata + hasUpdates = true + } if (payload.autoDownloadEpisodes !== undefined && payload.autoDownloadEpisodes !== this.autoDownloadEpisodes) { this.autoDownloadEpisodes = !!payload.autoDownloadEpisodes hasUpdates = true @@ -443,6 +451,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((episode) => episode.toOldJSON(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -459,6 +468,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], numEpisodes: this.podcastEpisodes?.length || 0, + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -483,6 +493,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((e) => e.toOldJSONExpanded(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, diff --git a/server/scanner/PodcastScanner.js b/server/scanner/PodcastScanner.js index f3241d536..a56a42600 100644 --- a/server/scanner/PodcastScanner.js +++ b/server/scanner/PodcastScanner.js @@ -12,6 +12,71 @@ const fsExtra = require('../libs/fsExtra') const PodcastEpisode = require('../models/PodcastEpisode') const AbsMetadataFileScanner = require('./AbsMetadataFileScanner') const htmlSanitizer = require('../utils/htmlSanitizer') +const Logger = require('../Logger') + +/** + * Match a podcast episode to an entry in the metadata episodes array + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object[]} metadataEpisodes - episodes array from metadata.json + * @returns {Object|null} + */ +function matchEpisodeMetadata(episode, metadataEpisodes) { + // Prefer GUID match + const guid = episode.extraData?.guid + if (guid) { + const match = metadataEpisodes.find((me) => me.guid === guid) + if (match) return match + } + // Fall back to title match (case-insensitive, trimmed) + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + const match = metadataEpisodes.find((me) => (me.title || '').trim().toLowerCase() === episodeTitle) + if (match) return match + } + return null +} + +/** + * Backfill null episode fields from matched metadata + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object} matched - matched metadata entry + * @returns {boolean} whether any fields were updated + */ +function applyEpisodeMetadata(episode, matched) { + let updated = false + if (!episode.description && matched.description) { + episode.description = matched.description + updated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + updated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + updated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + updated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + updated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + updated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + if (typeof episode.changed === 'function') { + episode.changed('extraData', true) + } + updated = true + } + return updated +} /** * Metadata for podcasts pulled from files @@ -232,6 +297,17 @@ class PodcastScanner { } } + // Backfill episode metadata from metadata.json if fetchEpisodeMetadata is enabled + if (media.fetchEpisodeMetadata && podcastMetadata.episodes?.length) { + for (const episode of existingPodcastEpisodes) { + const matched = matchEpisodeMetadata(episode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(episode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${episode.title}" from metadata.json`) + await episode.save() + } + } + } + existingLibraryItem.media = media let libraryItemUpdated = false @@ -312,6 +388,16 @@ class PodcastScanner { podcastMetadata.podcastType = 'episodic' } + // Backfill episode metadata from metadata.json if episodes data exists + if (podcastMetadata.episodes?.length) { + for (const newEpisode of newPodcastEpisodes) { + const matched = matchEpisodeMetadata(newEpisode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(newEpisode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${newEpisode.title}" from metadata.json`) + } + } + } + const podcastObject = { ...podcastMetadata, autoDownloadEpisodes: false, @@ -445,6 +531,21 @@ class PodcastScanner { explicit: !!libraryItem.media.explicit, podcastType: libraryItem.media.podcastType } + + if (libraryItem.media.fetchEpisodeMetadata && libraryItem.media.podcastEpisodes?.length) { + jsonObject.episodes = libraryItem.media.podcastEpisodes.map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } + return fsExtra .writeFile(metadataFilePath, JSON.stringify(jsonObject, null, 2)) .then(async () => { diff --git a/server/utils/generators/abmetadataGenerator.js b/server/utils/generators/abmetadataGenerator.js index d0d278752..7bb30e265 100644 --- a/server/utils/generators/abmetadataGenerator.js +++ b/server/utils/generators/abmetadataGenerator.js @@ -84,6 +84,16 @@ function parseJsonMetadataText(text, mediaType) { validated.series = validated.series.map((series) => parseSeriesString.parse(series)).filter(Boolean) } + if (mediaType === 'podcast' && 'episodes' in abmetadataData) { + if (abmetadataData.episodes === null) { + validated.episodes = [] + } else if (Array.isArray(abmetadataData.episodes)) { + validated.episodes = cleanEpisodesArray(abmetadataData.episodes) + } else { + Logger.warn(`[abmetadataGenerator] Invalid metadata key "episodes" expected array, got ${typeof abmetadataData.episodes}`) + } + } + if (mediaType === 'book' && 'chapters' in abmetadataData) { if (abmetadataData.chapters === null) { validated.chapters = [] @@ -148,6 +158,29 @@ function validateMetadataValue(key, value, expectedType) { return undefined } +/** + * @param {Object[]} episodesArray + * @returns {Object[]} + */ +function cleanEpisodesArray(episodesArray) { + const episodes = [] + for (const ep of episodesArray) { + if (!ep.title || typeof ep.title !== 'string') continue + episodes.push({ + title: ep.title, + description: typeof ep.description === 'string' ? ep.description : null, + season: typeof ep.season === 'string' ? ep.season : null, + episode: typeof ep.episode === 'string' ? ep.episode : null, + episodeType: typeof ep.episodeType === 'string' ? ep.episodeType : null, + pubDate: typeof ep.pubDate === 'string' ? ep.pubDate : null, + guid: typeof ep.guid === 'string' ? ep.guid : null, + subtitle: typeof ep.subtitle === 'string' ? ep.subtitle : null, + duration: typeof ep.duration === 'string' ? ep.duration : null + }) + } + return episodes +} + /** * @param {Object[]} chaptersArray * @param {string} mediaTitle From 79338e5465e6699fb6a85594fe419f4665f49a97 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sat, 6 Jun 2026 09:43:24 -0700 Subject: [PATCH 3/9] update --- .github/workflows/docker-build.yml | 16 +-- .../components/modals/item/tabs/Schedule.vue | 4 +- client/components/modals/podcast/NewModal.vue | 7 +- .../components/widgets/PodcastDetailsEdit.vue | 13 ++- client/strings/en-us.json | 2 + server/controllers/LibraryItemController.js | 14 +++ server/managers/PodcastManager.js | 90 ++++++++++++++++ ...36.0-podcast-add-fetch-episode-metadata.js | 68 ++++++++++++ server/models/LibraryItem.js | 14 +++ server/models/Podcast.js | 11 ++ server/scanner/PodcastScanner.js | 101 ++++++++++++++++++ .../utils/generators/abmetadataGenerator.js | 33 ++++++ 12 files changed, 358 insertions(+), 15 deletions(-) create mode 100644 server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fdb57fbc5..dea55c1f9 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: tags: - description: 'Docker Tag' + description: 'Docker Tag (e.g. latest)' required: true default: 'latest' push: @@ -22,7 +22,7 @@ on: jobs: build: - if: ${{ !contains(github.event.head_commit.message, 'skip ci') && github.repository == 'advplyr/audiobookshelf' }} + if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} runs-on: ubuntu-24.04 steps: @@ -33,8 +33,9 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: advplyr/audiobookshelf,ghcr.io/${{ github.repository_owner }}/audiobookshelf + images: entree3000/audiobookshelf tags: | + type=edge,branch=main type=edge,branch=master type=semver,pattern={{version}} @@ -58,17 +59,10 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Login to ghcr - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PASSWORD }} - - name: Build image uses: docker/build-push-action@v6 with: - tags: ${{ github.event.inputs.tags || steps.meta.outputs.tags }} + tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: . platforms: linux/amd64,linux/arm64 diff --git a/client/components/modals/item/tabs/Schedule.vue b/client/components/modals/item/tabs/Schedule.vue index 0faa29630..4b7d5d966 100644 --- a/client/components/modals/item/tabs/Schedule.vue +++ b/client/components/modals/item/tabs/Schedule.vue @@ -31,6 +31,7 @@ +
@@ -104,8 +105,7 @@ export default { return this.media.maxNewEpisodesToDownload }, isUpdated() { - return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) - } + return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) } }, methods: { updatedMaxEpisodesToKeep() { diff --git a/client/components/modals/podcast/NewModal.vue b/client/components/modals/podcast/NewModal.vue index 33e6dbc4b..02b783985 100644 --- a/client/components/modals/podcast/NewModal.vue +++ b/client/components/modals/podcast/NewModal.vue @@ -56,6 +56,9 @@
+
+ +
{{ $strings.ButtonSubmit }}
@@ -94,6 +97,7 @@ export default { itunesId: '', itunesArtistId: '', autoDownloadEpisodes: false, + fetchEpisodeMetadata: false, language: '', explicit: false, type: '' @@ -196,7 +200,8 @@ export default { explicit: this.podcast.explicit, type: this.podcast.type }, - autoDownloadEpisodes: this.podcast.autoDownloadEpisodes + autoDownloadEpisodes: this.podcast.autoDownloadEpisodes, + fetchEpisodeMetadata: this.podcast.fetchEpisodeMetadata } } console.log('Podcast payload', podcastPayload) diff --git a/client/components/widgets/PodcastDetailsEdit.vue b/client/components/widgets/PodcastDetailsEdit.vue index 0be67df32..f92fad1f1 100644 --- a/client/components/widgets/PodcastDetailsEdit.vue +++ b/client/components/widgets/PodcastDetailsEdit.vue @@ -43,6 +43,11 @@
+
+
+ +
+
@@ -73,7 +78,8 @@ export default { language: null, type: null }, - newTags: [] + newTags: [], + enableFetchEpisodeMetadata: false } }, watch: { @@ -223,6 +229,10 @@ export default { updatePayload.tags = [...this.newTags] } + if (this.enableFetchEpisodeMetadata !== !!this.media.fetchEpisodeMetadata) { + updatePayload.fetchEpisodeMetadata = this.enableFetchEpisodeMetadata + } + return { updatePayload, hasChanges: !!Object.keys(updatePayload).length @@ -244,6 +254,7 @@ export default { this.details.type = this.mediaMetadata.type || 'episodic' this.newTags = [...(this.media.tags || [])] + this.enableFetchEpisodeMetadata = !!this.media.fetchEpisodeMetadata }, submitForm() { this.$emit('submit') diff --git a/client/strings/en-us.json b/client/strings/en-us.json index fb2bcb281..aa0d91926 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -191,6 +191,7 @@ "HeaderRemoveEpisodes": "Remove {0} Episodes", "HeaderSavedMediaProgress": "Saved Media Progress", "HeaderSchedule": "Schedule", + "HeaderEpisodeMetadata": "Episode Metadata", "HeaderScheduleEpisodeDownloads": "Schedule Automatic Episode Downloads", "HeaderScheduleLibraryScans": "Schedule Automatic Library Scans", "HeaderSession": "Session", @@ -256,6 +257,7 @@ "LabelAuthorLastFirst": "Author (Last, First)", "LabelAuthors": "Authors", "LabelAutoDownloadEpisodes": "Auto Download Episodes", + "LabelFetchEpisodeMetadata": "Store Episode Metadata", "LabelAutoFetchMetadata": "Auto Fetch Metadata", "LabelAutoFetchMetadataHelp": "Fetches metadata for title, author, and series to streamline uploading. Additional metadata may have to be matched after upload.", "LabelAutoLaunch": "Auto Launch", diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 07b4ee67f..7fcf57911 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -215,6 +215,7 @@ class LibraryItemController { // Podcast specific let isPodcastAutoDownloadUpdated = false + let isFetchEpisodeMetadataEnabled = false if (req.libraryItem.isPodcast) { if (mediaPayload.autoDownloadEpisodes !== undefined && req.libraryItem.media.autoDownloadEpisodes !== mediaPayload.autoDownloadEpisodes) { isPodcastAutoDownloadUpdated = true @@ -226,6 +227,11 @@ class LibraryItemController { Logger.error(`[LibraryItemController] Invalid auto download schedule cron expression "${mediaPayload.autoDownloadSchedule}" for library item "${req.libraryItem.media.title}"`) return res.status(400).send('Invalid auto download schedule cron expression') } + + // Check if fetchEpisodeMetadata is being toggled on + if (mediaPayload.fetchEpisodeMetadata && !req.libraryItem.media.fetchEpisodeMetadata) { + isFetchEpisodeMetadataEnabled = true + } } let hasUpdates = (await req.libraryItem.media.updateFromRequest(mediaPayload)) || mediaPayload.url @@ -276,6 +282,14 @@ class LibraryItemController { this.cronManager.checkUpdatePodcastCron(req.libraryItem) } + // Fetch and populate episode metadata from RSS when toggle is turned on + if (isFetchEpisodeMetadataEnabled) { + const episodesUpdated = await this.podcastManager.populateEpisodeMetadataFromFeed(req.libraryItem) + if (episodesUpdated) { + await req.libraryItem.saveMetadataFile() + } + } + Logger.debug(`[LibraryItemController] Updated library item media ${req.libraryItem.media.title}`) SocketAuthority.libraryItemEmitter('item_updated', req.libraryItem) } diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index bdf6fc764..c9d8026c1 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -250,6 +250,11 @@ class PodcastManager { await libraryItem.media.save() } + // Save episode metadata to metadata.json if fetchEpisodeMetadata is enabled + if (libraryItem.media.fetchEpisodeMetadata) { + await libraryItem.saveMetadataFile() + } + SocketAuthority.libraryItemEmitter('item_updated', libraryItem) const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id) podcastEpisodeExpanded.libraryItem = libraryItem.toOldJSONExpanded() @@ -739,5 +744,90 @@ class PodcastManager { TaskManager.taskFinished(task) Logger.info(`[PodcastManager] createPodcastsFromFeedUrls: Finished OPML import. Created ${numPodcastsAdded} podcasts out of ${rssFeedUrls.length} RSS feed URLs`) } + + /** + * Fetch episode metadata from RSS feed and backfill missing fields on existing episodes + * + * @param {import('../models/LibraryItem')} libraryItem - must have media.podcastEpisodes loaded + * @returns {Promise} - true if any episodes were updated + */ + async populateEpisodeMetadataFromFeed(libraryItem) { + const podcast = libraryItem.media + if (!podcast.feedURL) { + Logger.warn(`[PodcastManager] Cannot fetch episode metadata - no feed URL for "${podcast.title}"`) + return false + } + + const feed = await getPodcastFeed(podcast.feedURL).catch((error) => { + Logger.error(`[PodcastManager] Failed to fetch feed for episode metadata population`, error) + return null + }) + if (!feed?.episodes?.length) { + Logger.warn(`[PodcastManager] No episodes found in feed for "${podcast.title}"`) + return false + } + + const episodes = podcast.podcastEpisodes || [] + let hasUpdates = false + + for (const episode of episodes) { + // Match by GUID first, then by title + const guid = episode.extraData?.guid + let matched = null + if (guid) { + matched = feed.episodes.find((fe) => fe.guid === guid) + } + if (!matched) { + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + matched = feed.episodes.find((fe) => (fe.title || '').trim().toLowerCase() === episodeTitle) + } + } + + if (!matched) continue + + let episodeUpdated = false + if (!episode.description && matched.description) { + episode.description = matched.description + episodeUpdated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + episodeUpdated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + episodeUpdated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + episodeUpdated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + episodeUpdated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + episodeUpdated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + episode.changed('extraData', true) + episodeUpdated = true + } + + if (episodeUpdated) { + await episode.save() + hasUpdates = true + } + } + + if (hasUpdates) { + Logger.info(`[PodcastManager] Populated episode metadata from feed for "${podcast.title}"`) + } + + return hasUpdates + } } module.exports = PodcastManager diff --git a/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js new file mode 100644 index 000000000..4bd69df4d --- /dev/null +++ b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js @@ -0,0 +1,68 @@ +/** + * @typedef MigrationContext + * @property {import('sequelize').QueryInterface} queryInterface - a Sequelize QueryInterface object. + * @property {import('../Logger')} logger - a Logger object. + * + * @typedef MigrationOptions + * @property {MigrationContext} context - an object containing the migration context. + */ + +const migrationVersion = '2.36.0' +const migrationName = `${migrationVersion}-podcast-add-fetch-episode-metadata` +const loggerPrefix = `[${migrationVersion} migration]` + +/** + * This migration script adds the fetchEpisodeMetadata column to the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function up({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} UPGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (!tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Adding fetchEpisodeMetadata column to podcasts table`) + await queryInterface.addColumn('podcasts', 'fetchEpisodeMetadata', { + type: queryInterface.sequelize.Sequelize.DataTypes.BOOLEAN, + defaultValue: false, + allowNull: false + }) + logger.info(`${loggerPrefix} Added fetchEpisodeMetadata column to podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column already exists in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} UPGRADE END: ${migrationName}`) +} + +/** + * This migration script removes the fetchEpisodeMetadata column from the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function down({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} DOWNGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Removing fetchEpisodeMetadata column from podcasts table`) + await queryInterface.removeColumn('podcasts', 'fetchEpisodeMetadata') + logger.info(`${loggerPrefix} Removed fetchEpisodeMetadata column from podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column does not exist in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} DOWNGRADE END: ${migrationName}`) +} + +module.exports = { up, down } diff --git a/server/models/LibraryItem.js b/server/models/LibraryItem.js index b33fa585c..2adeaf0b8 100644 --- a/server/models/LibraryItem.js +++ b/server/models/LibraryItem.js @@ -672,6 +672,20 @@ class LibraryItem extends Model { explicit: !!mediaExpanded.explicit, podcastType: mediaExpanded.podcastType } + + if (mediaExpanded.fetchEpisodeMetadata && mediaExpanded.podcastEpisodes?.length) { + jsonObject.episodes = mediaExpanded.podcastEpisodes.map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } } return fsExtra diff --git a/server/models/Podcast.js b/server/models/Podcast.js index 6dbe1cd19..3f5fcbf15 100644 --- a/server/models/Podcast.js +++ b/server/models/Podcast.js @@ -44,6 +44,8 @@ class Podcast extends Model { /** @type {boolean} */ this.explicit /** @type {boolean} */ + this.fetchEpisodeMetadata + /** @type {boolean} */ this.autoDownloadEpisodes /** @type {string} */ this.autoDownloadSchedule @@ -108,6 +110,7 @@ class Podcast extends Model { language: typeof payload.metadata.language === 'string' ? payload.metadata.language : null, podcastType: typeof payload.metadata.type === 'string' ? payload.metadata.type : null, explicit: !!payload.metadata.explicit, + fetchEpisodeMetadata: !!payload.fetchEpisodeMetadata, autoDownloadEpisodes: !!payload.autoDownloadEpisodes, autoDownloadSchedule: autoDownloadSchedule || global.ServerSettings.podcastEpisodeSchedule, lastEpisodeCheck: new Date(), @@ -146,6 +149,7 @@ class Podcast extends Model { podcastType: DataTypes.STRING, explicit: DataTypes.BOOLEAN, + fetchEpisodeMetadata: DataTypes.BOOLEAN, autoDownloadEpisodes: DataTypes.BOOLEAN, autoDownloadSchedule: DataTypes.STRING, lastEpisodeCheck: DataTypes.DATE, @@ -269,6 +273,10 @@ class Podcast extends Model { hasUpdates = true } + if (payload.fetchEpisodeMetadata !== undefined && payload.fetchEpisodeMetadata !== this.fetchEpisodeMetadata) { + this.fetchEpisodeMetadata = !!payload.fetchEpisodeMetadata + hasUpdates = true + } if (payload.autoDownloadEpisodes !== undefined && payload.autoDownloadEpisodes !== this.autoDownloadEpisodes) { this.autoDownloadEpisodes = !!payload.autoDownloadEpisodes hasUpdates = true @@ -443,6 +451,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((episode) => episode.toOldJSON(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -459,6 +468,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], numEpisodes: this.podcastEpisodes?.length || 0, + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -483,6 +493,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((e) => e.toOldJSONExpanded(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, diff --git a/server/scanner/PodcastScanner.js b/server/scanner/PodcastScanner.js index f3241d536..a56a42600 100644 --- a/server/scanner/PodcastScanner.js +++ b/server/scanner/PodcastScanner.js @@ -12,6 +12,71 @@ const fsExtra = require('../libs/fsExtra') const PodcastEpisode = require('../models/PodcastEpisode') const AbsMetadataFileScanner = require('./AbsMetadataFileScanner') const htmlSanitizer = require('../utils/htmlSanitizer') +const Logger = require('../Logger') + +/** + * Match a podcast episode to an entry in the metadata episodes array + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object[]} metadataEpisodes - episodes array from metadata.json + * @returns {Object|null} + */ +function matchEpisodeMetadata(episode, metadataEpisodes) { + // Prefer GUID match + const guid = episode.extraData?.guid + if (guid) { + const match = metadataEpisodes.find((me) => me.guid === guid) + if (match) return match + } + // Fall back to title match (case-insensitive, trimmed) + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + const match = metadataEpisodes.find((me) => (me.title || '').trim().toLowerCase() === episodeTitle) + if (match) return match + } + return null +} + +/** + * Backfill null episode fields from matched metadata + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object} matched - matched metadata entry + * @returns {boolean} whether any fields were updated + */ +function applyEpisodeMetadata(episode, matched) { + let updated = false + if (!episode.description && matched.description) { + episode.description = matched.description + updated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + updated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + updated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + updated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + updated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + updated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + if (typeof episode.changed === 'function') { + episode.changed('extraData', true) + } + updated = true + } + return updated +} /** * Metadata for podcasts pulled from files @@ -232,6 +297,17 @@ class PodcastScanner { } } + // Backfill episode metadata from metadata.json if fetchEpisodeMetadata is enabled + if (media.fetchEpisodeMetadata && podcastMetadata.episodes?.length) { + for (const episode of existingPodcastEpisodes) { + const matched = matchEpisodeMetadata(episode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(episode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${episode.title}" from metadata.json`) + await episode.save() + } + } + } + existingLibraryItem.media = media let libraryItemUpdated = false @@ -312,6 +388,16 @@ class PodcastScanner { podcastMetadata.podcastType = 'episodic' } + // Backfill episode metadata from metadata.json if episodes data exists + if (podcastMetadata.episodes?.length) { + for (const newEpisode of newPodcastEpisodes) { + const matched = matchEpisodeMetadata(newEpisode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(newEpisode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${newEpisode.title}" from metadata.json`) + } + } + } + const podcastObject = { ...podcastMetadata, autoDownloadEpisodes: false, @@ -445,6 +531,21 @@ class PodcastScanner { explicit: !!libraryItem.media.explicit, podcastType: libraryItem.media.podcastType } + + if (libraryItem.media.fetchEpisodeMetadata && libraryItem.media.podcastEpisodes?.length) { + jsonObject.episodes = libraryItem.media.podcastEpisodes.map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } + return fsExtra .writeFile(metadataFilePath, JSON.stringify(jsonObject, null, 2)) .then(async () => { diff --git a/server/utils/generators/abmetadataGenerator.js b/server/utils/generators/abmetadataGenerator.js index d0d278752..7bb30e265 100644 --- a/server/utils/generators/abmetadataGenerator.js +++ b/server/utils/generators/abmetadataGenerator.js @@ -84,6 +84,16 @@ function parseJsonMetadataText(text, mediaType) { validated.series = validated.series.map((series) => parseSeriesString.parse(series)).filter(Boolean) } + if (mediaType === 'podcast' && 'episodes' in abmetadataData) { + if (abmetadataData.episodes === null) { + validated.episodes = [] + } else if (Array.isArray(abmetadataData.episodes)) { + validated.episodes = cleanEpisodesArray(abmetadataData.episodes) + } else { + Logger.warn(`[abmetadataGenerator] Invalid metadata key "episodes" expected array, got ${typeof abmetadataData.episodes}`) + } + } + if (mediaType === 'book' && 'chapters' in abmetadataData) { if (abmetadataData.chapters === null) { validated.chapters = [] @@ -148,6 +158,29 @@ function validateMetadataValue(key, value, expectedType) { return undefined } +/** + * @param {Object[]} episodesArray + * @returns {Object[]} + */ +function cleanEpisodesArray(episodesArray) { + const episodes = [] + for (const ep of episodesArray) { + if (!ep.title || typeof ep.title !== 'string') continue + episodes.push({ + title: ep.title, + description: typeof ep.description === 'string' ? ep.description : null, + season: typeof ep.season === 'string' ? ep.season : null, + episode: typeof ep.episode === 'string' ? ep.episode : null, + episodeType: typeof ep.episodeType === 'string' ? ep.episodeType : null, + pubDate: typeof ep.pubDate === 'string' ? ep.pubDate : null, + guid: typeof ep.guid === 'string' ? ep.guid : null, + subtitle: typeof ep.subtitle === 'string' ? ep.subtitle : null, + duration: typeof ep.duration === 'string' ? ep.duration : null + }) + } + return episodes +} + /** * @param {Object[]} chaptersArray * @param {string} mediaTitle From 54f733558490e36b2954e15e6bea46108a5b58a6 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sat, 6 Jun 2026 20:03:44 -0700 Subject: [PATCH 4/9] update --- .github/workflows/docker-build.yml | 16 +-- .../components/modals/item/tabs/Schedule.vue | 4 +- client/components/modals/podcast/NewModal.vue | 7 +- .../components/widgets/PodcastDetailsEdit.vue | 13 ++- client/strings/en-us.json | 2 + server/controllers/LibraryItemController.js | 14 +++ server/managers/PodcastManager.js | 90 +++++++++++++++ ...36.0-podcast-add-fetch-episode-metadata.js | 68 +++++++++++ server/models/LibraryItem.js | 22 ++++ server/models/Podcast.js | 11 ++ server/scanner/PodcastScanner.js | 109 ++++++++++++++++++ .../utils/generators/abmetadataGenerator.js | 33 ++++++ 12 files changed, 374 insertions(+), 15 deletions(-) create mode 100644 server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fdb57fbc5..dea55c1f9 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: tags: - description: 'Docker Tag' + description: 'Docker Tag (e.g. latest)' required: true default: 'latest' push: @@ -22,7 +22,7 @@ on: jobs: build: - if: ${{ !contains(github.event.head_commit.message, 'skip ci') && github.repository == 'advplyr/audiobookshelf' }} + if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} runs-on: ubuntu-24.04 steps: @@ -33,8 +33,9 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: advplyr/audiobookshelf,ghcr.io/${{ github.repository_owner }}/audiobookshelf + images: entree3000/audiobookshelf tags: | + type=edge,branch=main type=edge,branch=master type=semver,pattern={{version}} @@ -58,17 +59,10 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Login to ghcr - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PASSWORD }} - - name: Build image uses: docker/build-push-action@v6 with: - tags: ${{ github.event.inputs.tags || steps.meta.outputs.tags }} + tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: . platforms: linux/amd64,linux/arm64 diff --git a/client/components/modals/item/tabs/Schedule.vue b/client/components/modals/item/tabs/Schedule.vue index 0faa29630..4b7d5d966 100644 --- a/client/components/modals/item/tabs/Schedule.vue +++ b/client/components/modals/item/tabs/Schedule.vue @@ -31,6 +31,7 @@ +
@@ -104,8 +105,7 @@ export default { return this.media.maxNewEpisodesToDownload }, isUpdated() { - return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) - } + return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) } }, methods: { updatedMaxEpisodesToKeep() { diff --git a/client/components/modals/podcast/NewModal.vue b/client/components/modals/podcast/NewModal.vue index 33e6dbc4b..02b783985 100644 --- a/client/components/modals/podcast/NewModal.vue +++ b/client/components/modals/podcast/NewModal.vue @@ -56,6 +56,9 @@
+
+ +
{{ $strings.ButtonSubmit }}
@@ -94,6 +97,7 @@ export default { itunesId: '', itunesArtistId: '', autoDownloadEpisodes: false, + fetchEpisodeMetadata: false, language: '', explicit: false, type: '' @@ -196,7 +200,8 @@ export default { explicit: this.podcast.explicit, type: this.podcast.type }, - autoDownloadEpisodes: this.podcast.autoDownloadEpisodes + autoDownloadEpisodes: this.podcast.autoDownloadEpisodes, + fetchEpisodeMetadata: this.podcast.fetchEpisodeMetadata } } console.log('Podcast payload', podcastPayload) diff --git a/client/components/widgets/PodcastDetailsEdit.vue b/client/components/widgets/PodcastDetailsEdit.vue index 0be67df32..f92fad1f1 100644 --- a/client/components/widgets/PodcastDetailsEdit.vue +++ b/client/components/widgets/PodcastDetailsEdit.vue @@ -43,6 +43,11 @@
+
+
+ +
+
@@ -73,7 +78,8 @@ export default { language: null, type: null }, - newTags: [] + newTags: [], + enableFetchEpisodeMetadata: false } }, watch: { @@ -223,6 +229,10 @@ export default { updatePayload.tags = [...this.newTags] } + if (this.enableFetchEpisodeMetadata !== !!this.media.fetchEpisodeMetadata) { + updatePayload.fetchEpisodeMetadata = this.enableFetchEpisodeMetadata + } + return { updatePayload, hasChanges: !!Object.keys(updatePayload).length @@ -244,6 +254,7 @@ export default { this.details.type = this.mediaMetadata.type || 'episodic' this.newTags = [...(this.media.tags || [])] + this.enableFetchEpisodeMetadata = !!this.media.fetchEpisodeMetadata }, submitForm() { this.$emit('submit') diff --git a/client/strings/en-us.json b/client/strings/en-us.json index fb2bcb281..aa0d91926 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -191,6 +191,7 @@ "HeaderRemoveEpisodes": "Remove {0} Episodes", "HeaderSavedMediaProgress": "Saved Media Progress", "HeaderSchedule": "Schedule", + "HeaderEpisodeMetadata": "Episode Metadata", "HeaderScheduleEpisodeDownloads": "Schedule Automatic Episode Downloads", "HeaderScheduleLibraryScans": "Schedule Automatic Library Scans", "HeaderSession": "Session", @@ -256,6 +257,7 @@ "LabelAuthorLastFirst": "Author (Last, First)", "LabelAuthors": "Authors", "LabelAutoDownloadEpisodes": "Auto Download Episodes", + "LabelFetchEpisodeMetadata": "Store Episode Metadata", "LabelAutoFetchMetadata": "Auto Fetch Metadata", "LabelAutoFetchMetadataHelp": "Fetches metadata for title, author, and series to streamline uploading. Additional metadata may have to be matched after upload.", "LabelAutoLaunch": "Auto Launch", diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 07b4ee67f..7fcf57911 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -215,6 +215,7 @@ class LibraryItemController { // Podcast specific let isPodcastAutoDownloadUpdated = false + let isFetchEpisodeMetadataEnabled = false if (req.libraryItem.isPodcast) { if (mediaPayload.autoDownloadEpisodes !== undefined && req.libraryItem.media.autoDownloadEpisodes !== mediaPayload.autoDownloadEpisodes) { isPodcastAutoDownloadUpdated = true @@ -226,6 +227,11 @@ class LibraryItemController { Logger.error(`[LibraryItemController] Invalid auto download schedule cron expression "${mediaPayload.autoDownloadSchedule}" for library item "${req.libraryItem.media.title}"`) return res.status(400).send('Invalid auto download schedule cron expression') } + + // Check if fetchEpisodeMetadata is being toggled on + if (mediaPayload.fetchEpisodeMetadata && !req.libraryItem.media.fetchEpisodeMetadata) { + isFetchEpisodeMetadataEnabled = true + } } let hasUpdates = (await req.libraryItem.media.updateFromRequest(mediaPayload)) || mediaPayload.url @@ -276,6 +282,14 @@ class LibraryItemController { this.cronManager.checkUpdatePodcastCron(req.libraryItem) } + // Fetch and populate episode metadata from RSS when toggle is turned on + if (isFetchEpisodeMetadataEnabled) { + const episodesUpdated = await this.podcastManager.populateEpisodeMetadataFromFeed(req.libraryItem) + if (episodesUpdated) { + await req.libraryItem.saveMetadataFile() + } + } + Logger.debug(`[LibraryItemController] Updated library item media ${req.libraryItem.media.title}`) SocketAuthority.libraryItemEmitter('item_updated', req.libraryItem) } diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index bdf6fc764..c9d8026c1 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -250,6 +250,11 @@ class PodcastManager { await libraryItem.media.save() } + // Save episode metadata to metadata.json if fetchEpisodeMetadata is enabled + if (libraryItem.media.fetchEpisodeMetadata) { + await libraryItem.saveMetadataFile() + } + SocketAuthority.libraryItemEmitter('item_updated', libraryItem) const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id) podcastEpisodeExpanded.libraryItem = libraryItem.toOldJSONExpanded() @@ -739,5 +744,90 @@ class PodcastManager { TaskManager.taskFinished(task) Logger.info(`[PodcastManager] createPodcastsFromFeedUrls: Finished OPML import. Created ${numPodcastsAdded} podcasts out of ${rssFeedUrls.length} RSS feed URLs`) } + + /** + * Fetch episode metadata from RSS feed and backfill missing fields on existing episodes + * + * @param {import('../models/LibraryItem')} libraryItem - must have media.podcastEpisodes loaded + * @returns {Promise} - true if any episodes were updated + */ + async populateEpisodeMetadataFromFeed(libraryItem) { + const podcast = libraryItem.media + if (!podcast.feedURL) { + Logger.warn(`[PodcastManager] Cannot fetch episode metadata - no feed URL for "${podcast.title}"`) + return false + } + + const feed = await getPodcastFeed(podcast.feedURL).catch((error) => { + Logger.error(`[PodcastManager] Failed to fetch feed for episode metadata population`, error) + return null + }) + if (!feed?.episodes?.length) { + Logger.warn(`[PodcastManager] No episodes found in feed for "${podcast.title}"`) + return false + } + + const episodes = podcast.podcastEpisodes || [] + let hasUpdates = false + + for (const episode of episodes) { + // Match by GUID first, then by title + const guid = episode.extraData?.guid + let matched = null + if (guid) { + matched = feed.episodes.find((fe) => fe.guid === guid) + } + if (!matched) { + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + matched = feed.episodes.find((fe) => (fe.title || '').trim().toLowerCase() === episodeTitle) + } + } + + if (!matched) continue + + let episodeUpdated = false + if (!episode.description && matched.description) { + episode.description = matched.description + episodeUpdated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + episodeUpdated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + episodeUpdated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + episodeUpdated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + episodeUpdated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + episodeUpdated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + episode.changed('extraData', true) + episodeUpdated = true + } + + if (episodeUpdated) { + await episode.save() + hasUpdates = true + } + } + + if (hasUpdates) { + Logger.info(`[PodcastManager] Populated episode metadata from feed for "${podcast.title}"`) + } + + return hasUpdates + } } module.exports = PodcastManager diff --git a/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js new file mode 100644 index 000000000..4bd69df4d --- /dev/null +++ b/server/migrations/v2.36.0-podcast-add-fetch-episode-metadata.js @@ -0,0 +1,68 @@ +/** + * @typedef MigrationContext + * @property {import('sequelize').QueryInterface} queryInterface - a Sequelize QueryInterface object. + * @property {import('../Logger')} logger - a Logger object. + * + * @typedef MigrationOptions + * @property {MigrationContext} context - an object containing the migration context. + */ + +const migrationVersion = '2.36.0' +const migrationName = `${migrationVersion}-podcast-add-fetch-episode-metadata` +const loggerPrefix = `[${migrationVersion} migration]` + +/** + * This migration script adds the fetchEpisodeMetadata column to the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function up({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} UPGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (!tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Adding fetchEpisodeMetadata column to podcasts table`) + await queryInterface.addColumn('podcasts', 'fetchEpisodeMetadata', { + type: queryInterface.sequelize.Sequelize.DataTypes.BOOLEAN, + defaultValue: false, + allowNull: false + }) + logger.info(`${loggerPrefix} Added fetchEpisodeMetadata column to podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column already exists in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} UPGRADE END: ${migrationName}`) +} + +/** + * This migration script removes the fetchEpisodeMetadata column from the podcasts table. + * + * @param {MigrationOptions} options - an object containing the migration context. + * @returns {Promise} - A promise that resolves when the migration is complete. + */ +async function down({ context: { queryInterface, logger } }) { + logger.info(`${loggerPrefix} DOWNGRADE BEGIN: ${migrationName}`) + + if (await queryInterface.tableExists('podcasts')) { + const tableDescription = await queryInterface.describeTable('podcasts') + if (tableDescription.fetchEpisodeMetadata) { + logger.info(`${loggerPrefix} Removing fetchEpisodeMetadata column from podcasts table`) + await queryInterface.removeColumn('podcasts', 'fetchEpisodeMetadata') + logger.info(`${loggerPrefix} Removed fetchEpisodeMetadata column from podcasts table`) + } else { + logger.info(`${loggerPrefix} fetchEpisodeMetadata column does not exist in podcasts table`) + } + } else { + logger.info(`${loggerPrefix} podcasts table does not exist`) + } + + logger.info(`${loggerPrefix} DOWNGRADE END: ${migrationName}`) +} + +module.exports = { up, down } diff --git a/server/models/LibraryItem.js b/server/models/LibraryItem.js index b33fa585c..e50ee1526 100644 --- a/server/models/LibraryItem.js +++ b/server/models/LibraryItem.js @@ -672,6 +672,28 @@ class LibraryItem extends Model { explicit: !!mediaExpanded.explicit, podcastType: mediaExpanded.podcastType } + + if (mediaExpanded.fetchEpisodeMetadata && mediaExpanded.podcastEpisodes?.length) { + jsonObject.episodes = [...mediaExpanded.podcastEpisodes].sort((a, b) => { + const seasonA = Number(a.season) || 0 + const seasonB = Number(b.season) || 0 + if (seasonA !== seasonB) return seasonA - seasonB + const epA = Number(a.episode) || 0 + const epB = Number(b.episode) || 0 + if (epA !== epB) return epA - epB + return new Date(a.pubDate || 0) - new Date(b.pubDate || 0) + }).map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } } return fsExtra diff --git a/server/models/Podcast.js b/server/models/Podcast.js index 6dbe1cd19..3f5fcbf15 100644 --- a/server/models/Podcast.js +++ b/server/models/Podcast.js @@ -44,6 +44,8 @@ class Podcast extends Model { /** @type {boolean} */ this.explicit /** @type {boolean} */ + this.fetchEpisodeMetadata + /** @type {boolean} */ this.autoDownloadEpisodes /** @type {string} */ this.autoDownloadSchedule @@ -108,6 +110,7 @@ class Podcast extends Model { language: typeof payload.metadata.language === 'string' ? payload.metadata.language : null, podcastType: typeof payload.metadata.type === 'string' ? payload.metadata.type : null, explicit: !!payload.metadata.explicit, + fetchEpisodeMetadata: !!payload.fetchEpisodeMetadata, autoDownloadEpisodes: !!payload.autoDownloadEpisodes, autoDownloadSchedule: autoDownloadSchedule || global.ServerSettings.podcastEpisodeSchedule, lastEpisodeCheck: new Date(), @@ -146,6 +149,7 @@ class Podcast extends Model { podcastType: DataTypes.STRING, explicit: DataTypes.BOOLEAN, + fetchEpisodeMetadata: DataTypes.BOOLEAN, autoDownloadEpisodes: DataTypes.BOOLEAN, autoDownloadSchedule: DataTypes.STRING, lastEpisodeCheck: DataTypes.DATE, @@ -269,6 +273,10 @@ class Podcast extends Model { hasUpdates = true } + if (payload.fetchEpisodeMetadata !== undefined && payload.fetchEpisodeMetadata !== this.fetchEpisodeMetadata) { + this.fetchEpisodeMetadata = !!payload.fetchEpisodeMetadata + hasUpdates = true + } if (payload.autoDownloadEpisodes !== undefined && payload.autoDownloadEpisodes !== this.autoDownloadEpisodes) { this.autoDownloadEpisodes = !!payload.autoDownloadEpisodes hasUpdates = true @@ -443,6 +451,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((episode) => episode.toOldJSON(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -459,6 +468,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], numEpisodes: this.podcastEpisodes?.length || 0, + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, @@ -483,6 +493,7 @@ class Podcast extends Model { coverPath: this.coverPath, tags: [...(this.tags || [])], episodes: this.podcastEpisodes.map((e) => e.toOldJSONExpanded(libraryItemId)), + fetchEpisodeMetadata: this.fetchEpisodeMetadata, autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck?.valueOf() || null, diff --git a/server/scanner/PodcastScanner.js b/server/scanner/PodcastScanner.js index f3241d536..0359e3022 100644 --- a/server/scanner/PodcastScanner.js +++ b/server/scanner/PodcastScanner.js @@ -12,6 +12,71 @@ const fsExtra = require('../libs/fsExtra') const PodcastEpisode = require('../models/PodcastEpisode') const AbsMetadataFileScanner = require('./AbsMetadataFileScanner') const htmlSanitizer = require('../utils/htmlSanitizer') +const Logger = require('../Logger') + +/** + * Match a podcast episode to an entry in the metadata episodes array + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object[]} metadataEpisodes - episodes array from metadata.json + * @returns {Object|null} + */ +function matchEpisodeMetadata(episode, metadataEpisodes) { + // Prefer GUID match + const guid = episode.extraData?.guid + if (guid) { + const match = metadataEpisodes.find((me) => me.guid === guid) + if (match) return match + } + // Fall back to title match (case-insensitive, trimmed) + const episodeTitle = (episode.title || '').trim().toLowerCase() + if (episodeTitle) { + const match = metadataEpisodes.find((me) => (me.title || '').trim().toLowerCase() === episodeTitle) + if (match) return match + } + return null +} + +/** + * Backfill null episode fields from matched metadata + * @param {Object} episode - PodcastEpisode model or plain object + * @param {Object} matched - matched metadata entry + * @returns {boolean} whether any fields were updated + */ +function applyEpisodeMetadata(episode, matched) { + let updated = false + if (!episode.description && matched.description) { + episode.description = matched.description + updated = true + } + if (!episode.season && matched.season) { + episode.season = matched.season + updated = true + } + if (!episode.episode && matched.episode) { + episode.episode = matched.episode + updated = true + } + if (!episode.episodeType && matched.episodeType) { + episode.episodeType = matched.episodeType + updated = true + } + if (!episode.pubDate && matched.pubDate) { + episode.pubDate = matched.pubDate + updated = true + } + if (!episode.subtitle && matched.subtitle) { + episode.subtitle = matched.subtitle + updated = true + } + if (matched.guid && !episode.extraData?.guid) { + episode.extraData = { ...(episode.extraData || {}), guid: matched.guid } + if (typeof episode.changed === 'function') { + episode.changed('extraData', true) + } + updated = true + } + return updated +} /** * Metadata for podcasts pulled from files @@ -232,6 +297,17 @@ class PodcastScanner { } } + // Backfill episode metadata from metadata.json if fetchEpisodeMetadata is enabled + if (media.fetchEpisodeMetadata && podcastMetadata.episodes?.length) { + for (const episode of existingPodcastEpisodes) { + const matched = matchEpisodeMetadata(episode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(episode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${episode.title}" from metadata.json`) + await episode.save() + } + } + } + existingLibraryItem.media = media let libraryItemUpdated = false @@ -312,6 +388,16 @@ class PodcastScanner { podcastMetadata.podcastType = 'episodic' } + // Backfill episode metadata from metadata.json if episodes data exists + if (podcastMetadata.episodes?.length) { + for (const newEpisode of newPodcastEpisodes) { + const matched = matchEpisodeMetadata(newEpisode, podcastMetadata.episodes) + if (matched && applyEpisodeMetadata(newEpisode, matched)) { + libraryScan.addLog(LogLevel.INFO, `Backfilled metadata for episode "${newEpisode.title}" from metadata.json`) + } + } + } + const podcastObject = { ...podcastMetadata, autoDownloadEpisodes: false, @@ -445,6 +531,29 @@ class PodcastScanner { explicit: !!libraryItem.media.explicit, podcastType: libraryItem.media.podcastType } + + if (libraryItem.media.fetchEpisodeMetadata && libraryItem.media.podcastEpisodes?.length) { + jsonObject.episodes = [...libraryItem.media.podcastEpisodes].sort((a, b) => { + const seasonA = Number(a.season) || 0 + const seasonB = Number(b.season) || 0 + if (seasonA !== seasonB) return seasonA - seasonB + const epA = Number(a.episode) || 0 + const epB = Number(b.episode) || 0 + if (epA !== epB) return epA - epB + return new Date(a.pubDate || 0) - new Date(b.pubDate || 0) + }).map((ep) => ({ + title: ep.title, + description: ep.description || null, + season: ep.season || null, + episode: ep.episode || null, + episodeType: ep.episodeType || null, + pubDate: ep.pubDate || null, + guid: ep.extraData?.guid || null, + subtitle: ep.subtitle || null, + duration: ep.audioFile?.duration ? String(Math.round(ep.audioFile.duration)) : null + })) + } + return fsExtra .writeFile(metadataFilePath, JSON.stringify(jsonObject, null, 2)) .then(async () => { diff --git a/server/utils/generators/abmetadataGenerator.js b/server/utils/generators/abmetadataGenerator.js index d0d278752..7bb30e265 100644 --- a/server/utils/generators/abmetadataGenerator.js +++ b/server/utils/generators/abmetadataGenerator.js @@ -84,6 +84,16 @@ function parseJsonMetadataText(text, mediaType) { validated.series = validated.series.map((series) => parseSeriesString.parse(series)).filter(Boolean) } + if (mediaType === 'podcast' && 'episodes' in abmetadataData) { + if (abmetadataData.episodes === null) { + validated.episodes = [] + } else if (Array.isArray(abmetadataData.episodes)) { + validated.episodes = cleanEpisodesArray(abmetadataData.episodes) + } else { + Logger.warn(`[abmetadataGenerator] Invalid metadata key "episodes" expected array, got ${typeof abmetadataData.episodes}`) + } + } + if (mediaType === 'book' && 'chapters' in abmetadataData) { if (abmetadataData.chapters === null) { validated.chapters = [] @@ -148,6 +158,29 @@ function validateMetadataValue(key, value, expectedType) { return undefined } +/** + * @param {Object[]} episodesArray + * @returns {Object[]} + */ +function cleanEpisodesArray(episodesArray) { + const episodes = [] + for (const ep of episodesArray) { + if (!ep.title || typeof ep.title !== 'string') continue + episodes.push({ + title: ep.title, + description: typeof ep.description === 'string' ? ep.description : null, + season: typeof ep.season === 'string' ? ep.season : null, + episode: typeof ep.episode === 'string' ? ep.episode : null, + episodeType: typeof ep.episodeType === 'string' ? ep.episodeType : null, + pubDate: typeof ep.pubDate === 'string' ? ep.pubDate : null, + guid: typeof ep.guid === 'string' ? ep.guid : null, + subtitle: typeof ep.subtitle === 'string' ? ep.subtitle : null, + duration: typeof ep.duration === 'string' ? ep.duration : null + }) + } + return episodes +} + /** * @param {Object[]} chaptersArray * @param {string} mediaTitle From 5fd87584046de6b15bf37848549a97da0cd7ca17 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sun, 7 Jun 2026 21:13:13 -0700 Subject: [PATCH 5/9] Update PodcastManager.js --- server/managers/PodcastManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index c9d8026c1..045dc0330 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -250,8 +250,8 @@ class PodcastManager { await libraryItem.media.save() } - // Save episode metadata to metadata.json if fetchEpisodeMetadata is enabled - if (libraryItem.media.fetchEpisodeMetadata) { + // Update metadata.json after episode download + if (global.ServerSettings.storeMetadataWithItem || libraryItem.media.fetchEpisodeMetadata) { await libraryItem.saveMetadataFile() } From 78deaa17a720ebbbfb3deba7f16f4fa76d7e32d6 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sun, 7 Jun 2026 21:27:38 -0700 Subject: [PATCH 6/9] Update PodcastManager.js --- server/managers/PodcastManager.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index 045dc0330..3abbca7e8 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -251,9 +251,7 @@ class PodcastManager { } // Update metadata.json after episode download - if (global.ServerSettings.storeMetadataWithItem || libraryItem.media.fetchEpisodeMetadata) { - await libraryItem.saveMetadataFile() - } + await libraryItem.saveMetadataFile() SocketAuthority.libraryItemEmitter('item_updated', libraryItem) const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id) From 5312bb63bd84f42e4ad8f4303b62fc6e79c099a3 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sun, 7 Jun 2026 21:49:43 -0700 Subject: [PATCH 7/9] update --- .github/ISSUE_TEMPLATE/bug.yaml | 98 ------------------- .github/ISSUE_TEMPLATE/config.yml | 5 - .github/ISSUE_TEMPLATE/feature.yml | 63 ------------ .github/pull_request_template.md | 33 ------- .github/workflows/apply_comments.yaml | 55 ----------- .github/workflows/close-issues-on-release.yml | 20 ---- .github/workflows/close_blank_issues.yaml | 42 -------- .github/workflows/codeql.yml | 78 --------------- .github/workflows/component-tests.yml | 48 --------- .github/workflows/docker-build.yml | 76 -------------- .github/workflows/i18n-integration.yml | 31 ------ .github/workflows/integration-test.yml | 52 ---------- .github/workflows/lint-openapi.yml | 39 -------- .github/workflows/notify-abs-windows.yml | 17 ---- .github/workflows/unit-tests.yml | 38 ------- .vscode/extensions.json | 7 -- .vscode/launch.json | 44 --------- .vscode/settings.json | 27 ----- .vscode/tasks.json | 40 -------- 19 files changed, 813 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug.yaml delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature.yml delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/apply_comments.yaml delete mode 100644 .github/workflows/close-issues-on-release.yml delete mode 100644 .github/workflows/close_blank_issues.yaml delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/component-tests.yml delete mode 100644 .github/workflows/docker-build.yml delete mode 100644 .github/workflows/i18n-integration.yml delete mode 100644 .github/workflows/integration-test.yml delete mode 100644 .github/workflows/lint-openapi.yml delete mode 100644 .github/workflows/notify-abs-windows.yml delete mode 100644 .github/workflows/unit-tests.yml delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json delete mode 100644 .vscode/tasks.json diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml deleted file mode 100644 index 89aec401c..000000000 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ /dev/null @@ -1,98 +0,0 @@ -name: 🐞 Bug Report -description: File a bug/issue and help us improve Audiobookshelf -title: '[Bug]: ' -labels: ['bug', 'triage'] -body: - - type: markdown - attributes: - value: 'Thank you for filing a bug report! 🐛' - - type: markdown - attributes: - value: 'Please first search for your issue and check the [docs](https://audiobookshelf.org/docs).' - - type: markdown - attributes: - value: 'Report issues with the mobile app [here](https://github.com/advplyr/audiobookshelf-app/issues/new/choose).' - - type: markdown - attributes: - value: 'Join the [discord server](https://discord.gg/HQgCbd6E75) for questions or if you are not sure about a bug.' - - type: textarea - id: what-happened - attributes: - label: What happened? - placeholder: Tell us what you see! - validations: - required: true - - type: textarea - id: what-was-expected - attributes: - label: What did you expect to happen? - placeholder: Tell us what you expected to see! Be as descriptive as you can and include screenshots if applicable. - validations: - required: true - - type: textarea - id: steps-to-reproduce - attributes: - label: Steps to reproduce the issue - value: '1. ' - validations: - required: true - - type: markdown - attributes: - value: '## Install Environment' - - type: input - id: version - attributes: - label: Audiobookshelf version - description: Do not put 'Latest version', please put the actual version here - placeholder: 'e.g. v1.6.60' - validations: - required: true - - type: dropdown - id: install - attributes: - label: How are you running audiobookshelf? - options: - - Docker - - Debian/PPA - - Windows Tray App - - Built from source - - Other (list in "Additional Notes" box) - validations: - required: true - - type: dropdown - id: server-os - attributes: - label: What OS is your Audiobookshelf server hosted from? - options: - - Windows - - macOS - - Linux - - Other (list in "Additional Notes" box) - validations: - required: true - - type: dropdown - id: desktop-browsers - attributes: - label: If the issue is being seen in the UI, what browsers are you seeing the problem on? - options: - - Chrome - - Firefox - - Safari - - Edge - - Firefox for Android - - Chrome for Android - - Safari on iOS - - Other (list in "Additional Notes" box) - - type: textarea - id: logs - attributes: - label: Logs - description: Please include any relevant logs here. This field is automatically formatted into code, so you do not need to include any backticks. - placeholder: Paste logs here - render: shell - - type: textarea - id: additional-notes - attributes: - label: Additional Notes - description: Anything else you want to add? - placeholder: 'e.g. I have tried X, Y, and Z.' diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index d04ad818f..000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Discord - url: https://discord.gg/HQgCbd6E75 - about: Ask questions, get help troubleshooting, and join the Abs community here. diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml deleted file mode 100644 index 768880916..000000000 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: 🚀 Feature Request -description: Request a feature/enhancement -title: '[Enhancement]: ' -labels: ['enhancement'] -body: - - type: markdown - attributes: - value: '#### *Mobile app features should be [requested here](https://github.com/advplyr/audiobookshelf-app/issues/new/choose)*.' - - type: markdown - attributes: - value: '## Web/Server Feature Request Description' - - type: markdown - attributes: - value: 'Please first search in both issues & discussions for your enhancement.' - - type: dropdown - id: enhancment-type - attributes: - label: Type of Enhancement - options: - - Server Backend - - Web Interface/Frontend - - Documentation - - type: textarea - id: describe - attributes: - label: Describe the Feature/Enhancement - description: Please help us understand what you want. - placeholder: What is your vision? - validations: - required: true - - type: textarea - id: the-why - attributes: - label: Why would this be helpful? - description: Please help us understand why this would enhance your experience. - placeholder: Explain the "why" or "use case". - validations: - required: true - - type: textarea - id: image - attributes: - label: Future Implementation (Screenshot) - description: Please help us visualize by including a doodle or screenshot. - placeholder: How could this look? - validations: - required: true - - type: markdown - attributes: - value: '## Web/Server Current Implementation' - - type: input - id: version - attributes: - label: Audiobookshelf Server Version - description: Do not put 'Latest version', please put your current version number here - placeholder: 'e.g. v1.6.60' - validations: - required: true - - type: textarea - id: current-image - attributes: - label: Current Implementation (Screenshot) - description: What page were you looking at when you thought of this enhancement? - placeholder: If an image is not applicable, please explain why. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 0cd521a5b..000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,33 +0,0 @@ - - -## Brief summary - - - -## Which issue is fixed? - - - -## In-depth Description - - - -## How have you tested this? - - - -## Screenshots - - diff --git a/.github/workflows/apply_comments.yaml b/.github/workflows/apply_comments.yaml deleted file mode 100644 index 69a7ce280..000000000 --- a/.github/workflows/apply_comments.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Add issue comments by label -on: - issues: - types: - - labeled -jobs: - help-wanted: - if: github.event.label.name == 'help wanted' - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - name: Help wanted comment - run: gh issue comment "$NUMBER" --body "$BODY" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - NUMBER: ${{ github.event.issue.number }} - BODY: > - This issue is not able to be completed due to limited bandwidth or access to the required test hardware. - - This issue is available for anyone to work on. - - - config-issue: - if: github.event.label.name == 'config-issue' - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - name: Config issue comment - run: gh issue close "$NUMBER" --reason "not planned" --comment "$BODY" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - NUMBER: ${{ github.event.issue.number }} - BODY: > - After reviewing this issue, this appears to be a problem with your setup and not Audiobookshelf. This issue is being closed to keep the issue tracker focused on Audiobookshelf itself. Please reach out on the Audiobookshelf Discord for community support. - - Some common search terms to help you find the solution to your problem: - - Reverse proxy - - Enabling websockets - - SSL (https vs http) - - Configuring a static IP - - `localhost` versus IP address - - hairpin NAT - - VPN - - firewall ports - - public versus private network - - bridge versus host mode - - Docker networking - - DNS (such as EAI_AGAIN errors) - - After you have followed these steps, please post the solution or steps you followed to fix the problem to help others in the future, or show that it is a problem with Audiobookshelf so we can reopen the issue. - diff --git a/.github/workflows/close-issues-on-release.yml b/.github/workflows/close-issues-on-release.yml deleted file mode 100644 index 9c5907589..000000000 --- a/.github/workflows/close-issues-on-release.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Close fixed issues on release. -on: - release: - types: [published] - -permissions: - contents: read - issues: write - -jobs: - comment: - runs-on: ubuntu-latest - steps: - - name: Close issues marked as fixed upon a release. - uses: gcampbell-msft/fixed-pending-release@7fa1b75a0c04bcd4b375110522878e5f6100cff5 - with: - label: 'awaiting release' - removeLabel: true - applyToAll: true - message: Fixed in [${releaseTag}](${releaseUrl}). diff --git a/.github/workflows/close_blank_issues.yaml b/.github/workflows/close_blank_issues.yaml deleted file mode 100644 index 7190546a0..000000000 --- a/.github/workflows/close_blank_issues.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Close Issues not using a template - -on: - issues: - types: - - opened - -permissions: - issues: write - -jobs: - close_issue: - runs-on: ubuntu-latest - - steps: - - name: Check issue headings - uses: actions/github-script@v7 - with: - script: | - const issueBody = context.payload.issue.body || ""; - - // Match Markdown headings (e.g., # Heading, ## Heading) - const headingRegex = /^(#{1,6})\s.+/gm; - const headings = [...issueBody.matchAll(headingRegex)]; - - if (headings.length < 3) { - // Post a comment - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.issue.number, - body: "Thank you for opening an issue! To help us review your request efficiently, please use one of the provided issue templates. If you're seeking information or have a general question, consider opening a Discussion or joining the conversation on our Discord. Thanks!" - }); - - // Close the issue - await github.rest.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.issue.number, - state: "closed" - }); - } diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 809563018..000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: 'CodeQL' - -on: - push: - branches: ['master'] - # Only build when files in these directories have been changed - paths: - - client/** - - server/** - - test/** - - index.js - - package.json - pull_request: - # The branches below must be a subset of the branches above - branches: ['master'] - # Only build when files in these directories have been changed - paths: - - client/** - - server/** - - test/** - - index.js - - package.json - schedule: - - cron: '16 5 * * 4' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ['javascript'] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: '/language:${{matrix.language}}' diff --git a/.github/workflows/component-tests.yml b/.github/workflows/component-tests.yml deleted file mode 100644 index fcc2c2138..000000000 --- a/.github/workflows/component-tests.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Run Component Tests - -on: - workflow_dispatch: - inputs: - ref: - description: 'Branch/Tag/SHA to test' - required: true - pull_request: - paths: - - 'client/**' - - '.github/workflows/component-tests.yml' - push: - paths: - - 'client/**' - - '.github/workflows/component-tests.yml' - -jobs: - run-component-tests: - name: Run Component Tests - runs-on: ubuntu-latest - - steps: - - name: Checkout (push/pull request) - uses: actions/checkout@v4 - if: github.event_name != 'workflow_dispatch' - - - name: Checkout (workflow_dispatch) - uses: actions/checkout@v4 - with: - ref: ${{ inputs.ref }} - if: github.event_name == 'workflow_dispatch' - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - - name: Install dependencies - run: | - cd client - npm ci - - - name: Run tests - run: | - cd client - npm test diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index dea55c1f9..000000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- -name: Build and Push Docker Image - -on: - # Allows you to run workflow manually from Actions tab - workflow_dispatch: - inputs: - tags: - description: 'Docker Tag (e.g. latest)' - required: true - default: 'latest' - push: - branches: [main, master] - tags: - - 'v*.*.*' - # Only build when files in these directories have been changed - paths: - - client/** - - server/** - - index.js - - package.json - -jobs: - build: - if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} - runs-on: ubuntu-24.04 - - steps: - - name: Check out - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: entree3000/audiobookshelf - tags: | - type=edge,branch=main - type=edge,branch=master - type=semver,pattern={{version}} - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Login to Dockerhub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build image - uses: docker/build-push-action@v6 - with: - tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - context: . - platforms: linux/amd64,linux/arm64 - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/i18n-integration.yml b/.github/workflows/i18n-integration.yml deleted file mode 100644 index 8b3a4678f..000000000 --- a/.github/workflows/i18n-integration.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Verify all i18n files are alphabetized - -on: - pull_request: - paths: - - client/strings/** # Should only check if any strings changed - push: - paths: - - client/strings/** # Should only check if any strings changed - -jobs: - update_translations: - runs-on: ubuntu-latest - steps: - # Check out the repository - - name: Checkout repository - uses: actions/checkout@v4 - - # Set up node to run the javascript - - name: Set up node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - # The only argument is the `directory`, which is where the i18n files are - # stored. - - name: Run Update JSON Files action - uses: audiobookshelf/audiobookshelf-i18n-updater@v1.3.0 - with: - directory: 'client/strings/' # Adjust the directory path as needed diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml deleted file mode 100644 index 18c1d2dae..000000000 --- a/.github/workflows/integration-test.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Integration Test - -on: - pull_request: - push: - branches-ignore: - - 'dependabot/**' # Don't run dependabot branches, as they are already covered by pull requests - # Only build when files in these directories have been changed - paths: - - client/** - - server/** - - test/** - - index.js - - package.json - -jobs: - build: - name: build and test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: setup node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - - name: install pkg (using yao-pkg fork for targeting node20) - run: npm install -g @yao-pkg/pkg - - - name: get client dependencies - working-directory: client - run: npm ci - - - name: build client - working-directory: client - run: npm run generate - - - name: get server dependencies - run: npm ci --only=production - - - name: build binary - run: pkg -t node20-linux-x64 -o audiobookshelf . - - - name: run audiobookshelf - run: | - ./audiobookshelf & - sleep 5 - - - name: test if server is available - run: curl -sf http://127.0.0.1:3333 | grep Audiobookshelf diff --git a/.github/workflows/lint-openapi.yml b/.github/workflows/lint-openapi.yml deleted file mode 100644 index ec08ecb36..000000000 --- a/.github/workflows/lint-openapi.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: API linting - -# Run on pull requests or pushes when there is a change to any OpenAPI files in docs/ -on: - pull_request: - push: - paths: - - 'docs/**' - -# This action only needs read permissions -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - # Check out the repository - - name: Checkout - uses: actions/checkout@v4 - - # Set up node to run the javascript - - name: Set up node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - # Install Redocly CLI - - name: Install Redocly CLI - run: npm install -g @redocly/cli@latest - - # Perform linting for exploded spec - - name: Run linting for exploded spec - run: redocly lint docs/root.yaml --format=github-actions - - # Perform linting for bundled spec - - name: Run linting for bundled spec - run: redocly lint docs/openapi.json --format=github-actions diff --git a/.github/workflows/notify-abs-windows.yml b/.github/workflows/notify-abs-windows.yml deleted file mode 100644 index 9ede33b81..000000000 --- a/.github/workflows/notify-abs-windows.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Dispatch an abs-windows event - -on: - release: - types: [published] - workflow_dispatch: - -jobs: - abs-windows-dispatch: - runs-on: ubuntu-latest - steps: - - name: Send a remote repository dispatch event - uses: peter-evans/repository-dispatch@v3 - with: - token: ${{ secrets.ABS_WINDOWS_PAT }} - repository: mikiher/audiobookshelf-windows - event-type: build-windows diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 91a22c716..000000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Run Unit Tests - -on: - workflow_dispatch: - inputs: - ref: - description: 'Branch/Tag/SHA to test' - required: true - pull_request: - push: - -jobs: - run-unit-tests: - name: Run Unit Tests - runs-on: ubuntu-latest - - steps: - - name: Checkout (push/pull request) - uses: actions/checkout@v4 - if: github.event_name != 'workflow_dispatch' - - - name: Checkout (workflow_dispatch) - uses: actions/checkout@v4 - with: - ref: ${{ inputs.ref }} - if: github.event_name == 'workflow_dispatch' - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Run tests - run: npm test diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index d2a045982..000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": [ - "EditorConfig.EditorConfig", - "esbenp.prettier-vscode", - "octref.vetur" - ] -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 20706b262..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Debug server", - "runtimeExecutable": "npm", - "args": [ - "run", - "dev" - ], - "skipFiles": [ - "/**" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug client (nuxt)", - "runtimeExecutable": "npm", - "args": [ - "run", - "dev" - ], - "cwd": "${workspaceFolder}/client", - "skipFiles": [ - "${workspaceFolder}//**" - ] - } - ], - "compounds": [ - { - "name": "Debug server and client (nuxt)", - "configurations": [ - "Debug server", - "Debug client (nuxt)" - ] - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 75503e6a4..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "vetur.format.defaultFormatterOptions": { - "prettier": { - "semi": false, - "singleQuote": true, - "printWidth": 400, - "proseWrap": "never", - "trailingComma": "none" - }, - "prettyhtml": { - "printWidth": 400, - "singleQuote": false, - "wrapAttributes": false, - "sortAttributes": false - } - }, - "editor.formatOnSave": true, - "editor.detectIndentation": true, - "editor.tabSize": 2, - "javascript.format.semicolons": "remove", - "[javascript][json][jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[vue]": { - "editor.defaultFormatter": "octref.vetur" - } -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index e041741fb..000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "path": "client", - "type": "npm", - "script": "generate", - "detail": "nuxt generate", - "label": "Build client", - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "dependsOn": [ - "Build client" - ], - "type": "npm", - "script": "dev", - "detail": "nodemon --watch server index.js", - "label": "Run server", - "group": { - "kind": "test", - "isDefault": true - } - }, - { - "path": "client", - "type": "npm", - "script": "dev", - "detail": "nuxt", - "label": "Run Live-reload client", - "group": { - "kind": "test", - "isDefault": false - } - } - ] -} \ No newline at end of file From 7b1a7ce04e204ac870ebca1bb6a8e65e6b0f77e3 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sun, 7 Jun 2026 21:50:29 -0700 Subject: [PATCH 8/9] reverted --- .github/ISSUE_TEMPLATE/bug.yaml | 98 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 + .github/ISSUE_TEMPLATE/feature.yml | 63 ++++++++++++ .github/pull_request_template.md | 33 +++++++ .github/workflows/apply_comments.yaml | 55 +++++++++++ .github/workflows/close-issues-on-release.yml | 20 ++++ .github/workflows/close_blank_issues.yaml | 42 ++++++++ .github/workflows/codeql.yml | 78 +++++++++++++++ .github/workflows/component-tests.yml | 48 +++++++++ .github/workflows/docker-build.yml | 76 ++++++++++++++ .github/workflows/i18n-integration.yml | 31 ++++++ .github/workflows/integration-test.yml | 52 ++++++++++ .github/workflows/lint-openapi.yml | 39 ++++++++ .github/workflows/notify-abs-windows.yml | 17 ++++ .github/workflows/unit-tests.yml | 38 +++++++ .vscode/extensions.json | 7 ++ .vscode/launch.json | 44 +++++++++ .vscode/settings.json | 27 +++++ .vscode/tasks.json | 40 ++++++++ 19 files changed, 813 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.yaml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/apply_comments.yaml create mode 100644 .github/workflows/close-issues-on-release.yml create mode 100644 .github/workflows/close_blank_issues.yaml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/component-tests.yml create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/i18n-integration.yml create mode 100644 .github/workflows/integration-test.yml create mode 100644 .github/workflows/lint-openapi.yml create mode 100644 .github/workflows/notify-abs-windows.yml create mode 100644 .github/workflows/unit-tests.yml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 000000000..89aec401c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,98 @@ +name: 🐞 Bug Report +description: File a bug/issue and help us improve Audiobookshelf +title: '[Bug]: ' +labels: ['bug', 'triage'] +body: + - type: markdown + attributes: + value: 'Thank you for filing a bug report! 🐛' + - type: markdown + attributes: + value: 'Please first search for your issue and check the [docs](https://audiobookshelf.org/docs).' + - type: markdown + attributes: + value: 'Report issues with the mobile app [here](https://github.com/advplyr/audiobookshelf-app/issues/new/choose).' + - type: markdown + attributes: + value: 'Join the [discord server](https://discord.gg/HQgCbd6E75) for questions or if you are not sure about a bug.' + - type: textarea + id: what-happened + attributes: + label: What happened? + placeholder: Tell us what you see! + validations: + required: true + - type: textarea + id: what-was-expected + attributes: + label: What did you expect to happen? + placeholder: Tell us what you expected to see! Be as descriptive as you can and include screenshots if applicable. + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to reproduce the issue + value: '1. ' + validations: + required: true + - type: markdown + attributes: + value: '## Install Environment' + - type: input + id: version + attributes: + label: Audiobookshelf version + description: Do not put 'Latest version', please put the actual version here + placeholder: 'e.g. v1.6.60' + validations: + required: true + - type: dropdown + id: install + attributes: + label: How are you running audiobookshelf? + options: + - Docker + - Debian/PPA + - Windows Tray App + - Built from source + - Other (list in "Additional Notes" box) + validations: + required: true + - type: dropdown + id: server-os + attributes: + label: What OS is your Audiobookshelf server hosted from? + options: + - Windows + - macOS + - Linux + - Other (list in "Additional Notes" box) + validations: + required: true + - type: dropdown + id: desktop-browsers + attributes: + label: If the issue is being seen in the UI, what browsers are you seeing the problem on? + options: + - Chrome + - Firefox + - Safari + - Edge + - Firefox for Android + - Chrome for Android + - Safari on iOS + - Other (list in "Additional Notes" box) + - type: textarea + id: logs + attributes: + label: Logs + description: Please include any relevant logs here. This field is automatically formatted into code, so you do not need to include any backticks. + placeholder: Paste logs here + render: shell + - type: textarea + id: additional-notes + attributes: + label: Additional Notes + description: Anything else you want to add? + placeholder: 'e.g. I have tried X, Y, and Z.' diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..d04ad818f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Discord + url: https://discord.gg/HQgCbd6E75 + about: Ask questions, get help troubleshooting, and join the Abs community here. diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 000000000..768880916 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,63 @@ +name: 🚀 Feature Request +description: Request a feature/enhancement +title: '[Enhancement]: ' +labels: ['enhancement'] +body: + - type: markdown + attributes: + value: '#### *Mobile app features should be [requested here](https://github.com/advplyr/audiobookshelf-app/issues/new/choose)*.' + - type: markdown + attributes: + value: '## Web/Server Feature Request Description' + - type: markdown + attributes: + value: 'Please first search in both issues & discussions for your enhancement.' + - type: dropdown + id: enhancment-type + attributes: + label: Type of Enhancement + options: + - Server Backend + - Web Interface/Frontend + - Documentation + - type: textarea + id: describe + attributes: + label: Describe the Feature/Enhancement + description: Please help us understand what you want. + placeholder: What is your vision? + validations: + required: true + - type: textarea + id: the-why + attributes: + label: Why would this be helpful? + description: Please help us understand why this would enhance your experience. + placeholder: Explain the "why" or "use case". + validations: + required: true + - type: textarea + id: image + attributes: + label: Future Implementation (Screenshot) + description: Please help us visualize by including a doodle or screenshot. + placeholder: How could this look? + validations: + required: true + - type: markdown + attributes: + value: '## Web/Server Current Implementation' + - type: input + id: version + attributes: + label: Audiobookshelf Server Version + description: Do not put 'Latest version', please put your current version number here + placeholder: 'e.g. v1.6.60' + validations: + required: true + - type: textarea + id: current-image + attributes: + label: Current Implementation (Screenshot) + description: What page were you looking at when you thought of this enhancement? + placeholder: If an image is not applicable, please explain why. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..0cd521a5b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,33 @@ + + +## Brief summary + + + +## Which issue is fixed? + + + +## In-depth Description + + + +## How have you tested this? + + + +## Screenshots + + diff --git a/.github/workflows/apply_comments.yaml b/.github/workflows/apply_comments.yaml new file mode 100644 index 000000000..69a7ce280 --- /dev/null +++ b/.github/workflows/apply_comments.yaml @@ -0,0 +1,55 @@ +name: Add issue comments by label +on: + issues: + types: + - labeled +jobs: + help-wanted: + if: github.event.label.name == 'help wanted' + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Help wanted comment + run: gh issue comment "$NUMBER" --body "$BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} + BODY: > + This issue is not able to be completed due to limited bandwidth or access to the required test hardware. + + This issue is available for anyone to work on. + + + config-issue: + if: github.event.label.name == 'config-issue' + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Config issue comment + run: gh issue close "$NUMBER" --reason "not planned" --comment "$BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} + BODY: > + After reviewing this issue, this appears to be a problem with your setup and not Audiobookshelf. This issue is being closed to keep the issue tracker focused on Audiobookshelf itself. Please reach out on the Audiobookshelf Discord for community support. + + Some common search terms to help you find the solution to your problem: + - Reverse proxy + - Enabling websockets + - SSL (https vs http) + - Configuring a static IP + - `localhost` versus IP address + - hairpin NAT + - VPN + - firewall ports + - public versus private network + - bridge versus host mode + - Docker networking + - DNS (such as EAI_AGAIN errors) + + After you have followed these steps, please post the solution or steps you followed to fix the problem to help others in the future, or show that it is a problem with Audiobookshelf so we can reopen the issue. + diff --git a/.github/workflows/close-issues-on-release.yml b/.github/workflows/close-issues-on-release.yml new file mode 100644 index 000000000..9c5907589 --- /dev/null +++ b/.github/workflows/close-issues-on-release.yml @@ -0,0 +1,20 @@ +name: Close fixed issues on release. +on: + release: + types: [published] + +permissions: + contents: read + issues: write + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - name: Close issues marked as fixed upon a release. + uses: gcampbell-msft/fixed-pending-release@7fa1b75a0c04bcd4b375110522878e5f6100cff5 + with: + label: 'awaiting release' + removeLabel: true + applyToAll: true + message: Fixed in [${releaseTag}](${releaseUrl}). diff --git a/.github/workflows/close_blank_issues.yaml b/.github/workflows/close_blank_issues.yaml new file mode 100644 index 000000000..7190546a0 --- /dev/null +++ b/.github/workflows/close_blank_issues.yaml @@ -0,0 +1,42 @@ +name: Close Issues not using a template + +on: + issues: + types: + - opened + +permissions: + issues: write + +jobs: + close_issue: + runs-on: ubuntu-latest + + steps: + - name: Check issue headings + uses: actions/github-script@v7 + with: + script: | + const issueBody = context.payload.issue.body || ""; + + // Match Markdown headings (e.g., # Heading, ## Heading) + const headingRegex = /^(#{1,6})\s.+/gm; + const headings = [...issueBody.matchAll(headingRegex)]; + + if (headings.length < 3) { + // Post a comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + body: "Thank you for opening an issue! To help us review your request efficiently, please use one of the provided issue templates. If you're seeking information or have a general question, consider opening a Discussion or joining the conversation on our Discord. Thanks!" + }); + + // Close the issue + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + state: "closed" + }); + } diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..809563018 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,78 @@ +name: 'CodeQL' + +on: + push: + branches: ['master'] + # Only build when files in these directories have been changed + paths: + - client/** + - server/** + - test/** + - index.js + - package.json + pull_request: + # The branches below must be a subset of the branches above + branches: ['master'] + # Only build when files in these directories have been changed + paths: + - client/** + - server/** + - test/** + - index.js + - package.json + schedule: + - cron: '16 5 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ['javascript'] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: '/language:${{matrix.language}}' diff --git a/.github/workflows/component-tests.yml b/.github/workflows/component-tests.yml new file mode 100644 index 000000000..fcc2c2138 --- /dev/null +++ b/.github/workflows/component-tests.yml @@ -0,0 +1,48 @@ +name: Run Component Tests + +on: + workflow_dispatch: + inputs: + ref: + description: 'Branch/Tag/SHA to test' + required: true + pull_request: + paths: + - 'client/**' + - '.github/workflows/component-tests.yml' + push: + paths: + - 'client/**' + - '.github/workflows/component-tests.yml' + +jobs: + run-component-tests: + name: Run Component Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout (push/pull request) + uses: actions/checkout@v4 + if: github.event_name != 'workflow_dispatch' + + - name: Checkout (workflow_dispatch) + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + if: github.event_name == 'workflow_dispatch' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: | + cd client + npm ci + + - name: Run tests + run: | + cd client + npm test diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..dea55c1f9 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,76 @@ +--- +name: Build and Push Docker Image + +on: + # Allows you to run workflow manually from Actions tab + workflow_dispatch: + inputs: + tags: + description: 'Docker Tag (e.g. latest)' + required: true + default: 'latest' + push: + branches: [main, master] + tags: + - 'v*.*.*' + # Only build when files in these directories have been changed + paths: + - client/** + - server/** + - index.js + - package.json + +jobs: + build: + if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} + runs-on: ubuntu-24.04 + + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: entree3000/audiobookshelf + tags: | + type=edge,branch=main + type=edge,branch=master + type=semver,pattern={{version}} + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build image + uses: docker/build-push-action@v6 + with: + tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + context: . + platforms: linux/amd64,linux/arm64 + push: true + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/i18n-integration.yml b/.github/workflows/i18n-integration.yml new file mode 100644 index 000000000..8b3a4678f --- /dev/null +++ b/.github/workflows/i18n-integration.yml @@ -0,0 +1,31 @@ +name: Verify all i18n files are alphabetized + +on: + pull_request: + paths: + - client/strings/** # Should only check if any strings changed + push: + paths: + - client/strings/** # Should only check if any strings changed + +jobs: + update_translations: + runs-on: ubuntu-latest + steps: + # Check out the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Set up node to run the javascript + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + # The only argument is the `directory`, which is where the i18n files are + # stored. + - name: Run Update JSON Files action + uses: audiobookshelf/audiobookshelf-i18n-updater@v1.3.0 + with: + directory: 'client/strings/' # Adjust the directory path as needed diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 000000000..18c1d2dae --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,52 @@ +name: Integration Test + +on: + pull_request: + push: + branches-ignore: + - 'dependabot/**' # Don't run dependabot branches, as they are already covered by pull requests + # Only build when files in these directories have been changed + paths: + - client/** + - server/** + - test/** + - index.js + - package.json + +jobs: + build: + name: build and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: install pkg (using yao-pkg fork for targeting node20) + run: npm install -g @yao-pkg/pkg + + - name: get client dependencies + working-directory: client + run: npm ci + + - name: build client + working-directory: client + run: npm run generate + + - name: get server dependencies + run: npm ci --only=production + + - name: build binary + run: pkg -t node20-linux-x64 -o audiobookshelf . + + - name: run audiobookshelf + run: | + ./audiobookshelf & + sleep 5 + + - name: test if server is available + run: curl -sf http://127.0.0.1:3333 | grep Audiobookshelf diff --git a/.github/workflows/lint-openapi.yml b/.github/workflows/lint-openapi.yml new file mode 100644 index 000000000..ec08ecb36 --- /dev/null +++ b/.github/workflows/lint-openapi.yml @@ -0,0 +1,39 @@ +name: API linting + +# Run on pull requests or pushes when there is a change to any OpenAPI files in docs/ +on: + pull_request: + push: + paths: + - 'docs/**' + +# This action only needs read permissions +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Check out the repository + - name: Checkout + uses: actions/checkout@v4 + + # Set up node to run the javascript + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + # Install Redocly CLI + - name: Install Redocly CLI + run: npm install -g @redocly/cli@latest + + # Perform linting for exploded spec + - name: Run linting for exploded spec + run: redocly lint docs/root.yaml --format=github-actions + + # Perform linting for bundled spec + - name: Run linting for bundled spec + run: redocly lint docs/openapi.json --format=github-actions diff --git a/.github/workflows/notify-abs-windows.yml b/.github/workflows/notify-abs-windows.yml new file mode 100644 index 000000000..9ede33b81 --- /dev/null +++ b/.github/workflows/notify-abs-windows.yml @@ -0,0 +1,17 @@ +name: Dispatch an abs-windows event + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + abs-windows-dispatch: + runs-on: ubuntu-latest + steps: + - name: Send a remote repository dispatch event + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.ABS_WINDOWS_PAT }} + repository: mikiher/audiobookshelf-windows + event-type: build-windows diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..91a22c716 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,38 @@ +name: Run Unit Tests + +on: + workflow_dispatch: + inputs: + ref: + description: 'Branch/Tag/SHA to test' + required: true + pull_request: + push: + +jobs: + run-unit-tests: + name: Run Unit Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout (push/pull request) + uses: actions/checkout@v4 + if: github.event_name != 'workflow_dispatch' + + - name: Checkout (workflow_dispatch) + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + if: github.event_name == 'workflow_dispatch' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..d2a045982 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "octref.vetur" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..20706b262 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,44 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Debug server", + "runtimeExecutable": "npm", + "args": [ + "run", + "dev" + ], + "skipFiles": [ + "/**" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug client (nuxt)", + "runtimeExecutable": "npm", + "args": [ + "run", + "dev" + ], + "cwd": "${workspaceFolder}/client", + "skipFiles": [ + "${workspaceFolder}//**" + ] + } + ], + "compounds": [ + { + "name": "Debug server and client (nuxt)", + "configurations": [ + "Debug server", + "Debug client (nuxt)" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..75503e6a4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,27 @@ +{ + "vetur.format.defaultFormatterOptions": { + "prettier": { + "semi": false, + "singleQuote": true, + "printWidth": 400, + "proseWrap": "never", + "trailingComma": "none" + }, + "prettyhtml": { + "printWidth": 400, + "singleQuote": false, + "wrapAttributes": false, + "sortAttributes": false + } + }, + "editor.formatOnSave": true, + "editor.detectIndentation": true, + "editor.tabSize": 2, + "javascript.format.semicolons": "remove", + "[javascript][json][jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[vue]": { + "editor.defaultFormatter": "octref.vetur" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..e041741fb --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,40 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "path": "client", + "type": "npm", + "script": "generate", + "detail": "nuxt generate", + "label": "Build client", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "dependsOn": [ + "Build client" + ], + "type": "npm", + "script": "dev", + "detail": "nodemon --watch server index.js", + "label": "Run server", + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "path": "client", + "type": "npm", + "script": "dev", + "detail": "nuxt", + "label": "Run Live-reload client", + "group": { + "kind": "test", + "isDefault": false + } + } + ] +} \ No newline at end of file From 32f0cc95fbabb6319d1e8183def6b9870e0d67e8 Mon Sep 17 00:00:00 2001 From: kyle-in-the-cloud Date: Sun, 7 Jun 2026 21:52:56 -0700 Subject: [PATCH 9/9] Update docker-build.yml --- .github/workflows/docker-build.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index dea55c1f9..fdb57fbc5 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: inputs: tags: - description: 'Docker Tag (e.g. latest)' + description: 'Docker Tag' required: true default: 'latest' push: @@ -22,7 +22,7 @@ on: jobs: build: - if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} + if: ${{ !contains(github.event.head_commit.message, 'skip ci') && github.repository == 'advplyr/audiobookshelf' }} runs-on: ubuntu-24.04 steps: @@ -33,9 +33,8 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: entree3000/audiobookshelf + images: advplyr/audiobookshelf,ghcr.io/${{ github.repository_owner }}/audiobookshelf tags: | - type=edge,branch=main type=edge,branch=master type=semver,pattern={{version}} @@ -59,10 +58,17 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Login to ghcr + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_PASSWORD }} + - name: Build image uses: docker/build-push-action@v6 with: - tags: ${{ github.event.inputs.tags && format('entree3000/audiobookshelf:{0}', github.event.inputs.tags) || steps.meta.outputs.tags }} + tags: ${{ github.event.inputs.tags || steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: . platforms: linux/amd64,linux/arm64