From b1ee54522a88ccf3ce1adf5e8d6a7865a7ab714f Mon Sep 17 00:00:00 2001 From: mfcar Date: Wed, 22 Feb 2023 18:22:52 +0000 Subject: [PATCH] Add support to podcast type --- .../components/widgets/PodcastDetailsEdit.vue | 16 +++++++++++++--- client/store/globals.js | 11 ++++++++++- client/strings/de.json | 1 + client/strings/en-us.json | 1 + client/strings/es.json | 3 ++- client/strings/fr.json | 3 ++- client/strings/hr.json | 3 ++- client/strings/it.json | 3 ++- client/strings/pl.json | 3 ++- client/strings/ru.json | 3 ++- client/strings/zh-cn.json | 3 ++- server/objects/Feed.js | 4 +++- server/objects/FeedEpisode.js | 19 +++++++++++++++++-- server/objects/FeedMeta.js | 8 ++++++-- server/objects/metadata/PodcastMetadata.js | 11 ++++++++--- server/utils/podcastUtils.js | 7 ++++--- 16 files changed, 77 insertions(+), 22 deletions(-) diff --git a/client/components/widgets/PodcastDetailsEdit.vue b/client/components/widgets/PodcastDetailsEdit.vue index 8030028d..4442f9c6 100644 --- a/client/components/widgets/PodcastDetailsEdit.vue +++ b/client/components/widgets/PodcastDetailsEdit.vue @@ -39,6 +39,11 @@ +
+
+ +
+
@@ -65,7 +70,8 @@ export default { itunesId: null, itunesArtistId: null, explicit: false, - language: null + language: null, + type: null }, newTags: [] } @@ -93,7 +99,10 @@ export default { }, filterData() { return this.$store.state.libraries.filterData || {} - } + }, + podcastTypes() { + return this.$store.state.globals.podcastTypes || [] + }, }, methods: { getDetails() { @@ -219,6 +228,7 @@ export default { this.details.itunesArtistId = this.mediaMetadata.itunesArtistId || '' this.details.language = this.mediaMetadata.language || '' this.details.explicit = !!this.mediaMetadata.explicit + this.details.type = this.mediaMetadata.type || 'episodic' this.newTags = [...(this.media.tags || [])] }, @@ -228,4 +238,4 @@ export default { }, mounted() {} } - \ No newline at end of file + diff --git a/client/store/globals.js b/client/store/globals.js index 13c6bb05..953398c1 100644 --- a/client/store/globals.js +++ b/client/store/globals.js @@ -37,6 +37,15 @@ export const state = () => ({ value: 'yyyy-MM-dd' } ], + podcastTypes: [ + { text: 'Episodic', value: 'episodic' }, + { text: 'Serial', value: 'serial' } + ], + episodeTypes: [ + { text: 'Full', value: 'full' }, + { text: 'Trailer', value: 'trailer' }, + { text: 'Bonus', value: 'bonus' } + ], libraryIcons: ['database', 'audiobookshelf', 'books-1', 'books-2', 'book-1', 'microphone-1', 'microphone-3', 'radio', 'podcast', 'rss', 'headphones', 'music', 'file-picture', 'rocket', 'power', 'star', 'heart'] }) @@ -169,4 +178,4 @@ export const mutations = { state.selectedMediaItems.push(item) } } -} \ No newline at end of file +} diff --git a/client/strings/de.json b/client/strings/de.json index 6f14ee47..3d99c992 100644 --- a/client/strings/de.json +++ b/client/strings/de.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Abspielmethode", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasts", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Zu ignorierende(s) Vorwort(e) (Groß- und Kleinschreibung wird nicht berücksichtigt)", "LabelProgress": "Fortschritt", "LabelProvider": "Anbieter", diff --git a/client/strings/en-us.json b/client/strings/en-us.json index aba99d1c..f2e5e565 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Play Method", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasts", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Prefixes to Ignore (case insensitive)", "LabelProgress": "Progress", "LabelProvider": "Provider", diff --git a/client/strings/es.json b/client/strings/es.json index ba435f0b..f2e5e565 100644 --- a/client/strings/es.json +++ b/client/strings/es.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Play Method", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasts", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Prefixes to Ignore (case insensitive)", "LabelProgress": "Progress", "LabelProvider": "Provider", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "Socket failed to connect", "ToastUserDeleteFailed": "Failed to delete user", "ToastUserDeleteSuccess": "User deleted" -} \ No newline at end of file +} diff --git a/client/strings/fr.json b/client/strings/fr.json index d2e24df9..7d45f8f1 100644 --- a/client/strings/fr.json +++ b/client/strings/fr.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Méthode d'écoute", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasts", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Préfixes à Ignorer (Insensible à la Casse)", "LabelProgress": "Progression", "LabelProvider": "Fournisseur", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "Échec de la connexion WebSocket", "ToastUserDeleteFailed": "Échec de la suppression de l'utilisateur", "ToastUserDeleteSuccess": "Utilisateur supprimé" -} \ No newline at end of file +} diff --git a/client/strings/hr.json b/client/strings/hr.json index 467412f2..19cf4f8b 100644 --- a/client/strings/hr.json +++ b/client/strings/hr.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Vrsta reprodukcije", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasts", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Prefiksi za ignorirati (mala i velika slova nisu bitna)", "LabelProgress": "Napredak", "LabelProvider": "Dobavljač", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "Socket failed to connect", "ToastUserDeleteFailed": "Neuspješno brisanje korisnika", "ToastUserDeleteSuccess": "Korisnik obrisan" -} \ No newline at end of file +} diff --git a/client/strings/it.json b/client/strings/it.json index 90e95b33..a4e88e4c 100644 --- a/client/strings/it.json +++ b/client/strings/it.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Metodo di riproduzione", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasts", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Suffissi da ignorare (specificando maiuscole e minuscole)", "LabelProgress": "Cominciati", "LabelProvider": "Provider", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "Socket non riesce a connettersi", "ToastUserDeleteFailed": "Errore eliminazione utente", "ToastUserDeleteSuccess": "Utente eliminato" -} \ No newline at end of file +} diff --git a/client/strings/pl.json b/client/strings/pl.json index 497d9ca2..e6215d3f 100644 --- a/client/strings/pl.json +++ b/client/strings/pl.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Metoda odtwarzania", "LabelPodcast": "Podcast", "LabelPodcasts": "Podcasty", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Ignorowane prefiksy (wielkość liter nie ma znaczenia)", "LabelProgress": "Postęp", "LabelProvider": "Dostawca", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "Poączenie z serwerem nie powiodło się", "ToastUserDeleteFailed": "Nie udało się usunąć użytkownika", "ToastUserDeleteSuccess": "Użytkownik usunięty" -} \ No newline at end of file +} diff --git a/client/strings/ru.json b/client/strings/ru.json index 07a47627..9441f453 100644 --- a/client/strings/ru.json +++ b/client/strings/ru.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "Метод Воспроизведения", "LabelPodcast": "Подкаст", "LabelPodcasts": "Подкасты", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "Игнорируемые Префиксы (без учета регистра)", "LabelProgress": "Прогресс", "LabelProvider": "Провайдер", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "Не удалось подключить сокет", "ToastUserDeleteFailed": "Не удалось удалить пользователя", "ToastUserDeleteSuccess": "Пользователь удален" -} \ No newline at end of file +} diff --git a/client/strings/zh-cn.json b/client/strings/zh-cn.json index 2033feab..3d3f48fb 100644 --- a/client/strings/zh-cn.json +++ b/client/strings/zh-cn.json @@ -301,6 +301,7 @@ "LabelPlayMethod": "播放方法", "LabelPodcast": "播客", "LabelPodcasts": "播客", + "LabelPodcastType": "Podcast Type", "LabelPrefixesToIgnore": "忽略的前缀 (不区分大小写)", "LabelProgress": "进度", "LabelProvider": "供应商", @@ -616,4 +617,4 @@ "ToastSocketFailedToConnect": "网络连接失败", "ToastUserDeleteFailed": "删除用户失败", "ToastUserDeleteSuccess": "用户已删除" -} \ No newline at end of file +} diff --git a/server/objects/Feed.js b/server/objects/Feed.js index cc5e804f..c4aa3b87 100644 --- a/server/objects/Feed.js +++ b/server/objects/Feed.js @@ -106,6 +106,7 @@ class Feed { this.meta.feedUrl = feedUrl this.meta.link = `${serverAddress}/item/${libraryItem.id}` this.meta.explicit = !!mediaMetadata.explicit + this.meta.type = mediaMetadata.type this.episodes = [] if (isPodcast) { // PODCAST EPISODES @@ -142,6 +143,7 @@ class Feed { this.meta.author = author this.meta.imageUrl = media.coverPath ? `${this.serverAddress}/feed/${this.slug}/cover` : `${this.serverAddress}/Logo.png` this.meta.explicit = !!mediaMetadata.explicit + this.meta.type = mediaMetadata.type this.episodes = [] if (isPodcast) { // PODCAST EPISODES @@ -333,4 +335,4 @@ class Feed { return author } } -module.exports = Feed \ No newline at end of file +module.exports = Feed diff --git a/server/objects/FeedEpisode.js b/server/objects/FeedEpisode.js index 8891aa07..65395f04 100644 --- a/server/objects/FeedEpisode.js +++ b/server/objects/FeedEpisode.js @@ -14,6 +14,9 @@ class FeedEpisode { this.author = null this.explicit = null this.duration = null + this.season = null + this.episode = null + this.episodeType = null this.libraryItemId = null this.episodeId = null @@ -35,6 +38,9 @@ class FeedEpisode { this.author = episode.author this.explicit = episode.explicit this.duration = episode.duration + this.season = episode.season + this.episode = episode.episode + this.episodeType = episode.episodeType this.libraryItemId = episode.libraryItemId this.episodeId = episode.episodeId || null this.trackIndex = episode.trackIndex || 0 @@ -52,6 +58,9 @@ class FeedEpisode { author: this.author, explicit: this.explicit, duration: this.duration, + season: this.season, + episode: this.episode, + episodeType: this.episodeType, libraryItemId: this.libraryItemId, episodeId: this.episodeId, trackIndex: this.trackIndex, @@ -77,6 +86,9 @@ class FeedEpisode { this.author = meta.author this.explicit = mediaMetadata.explicit this.duration = episode.duration + this.season = episode.season + this.episode = episode.episode + this.episodeType = episode.episodeType this.libraryItemId = libraryItem.id this.episodeId = episode.id this.trackIndex = 0 @@ -144,9 +156,12 @@ class FeedEpisode { { 'itunes:summary': this.description || '' }, { "itunes:explicit": !!this.explicit - } + }, + {"itunes:episodeType": this.episodeType}, + {"itunes:season": this.season}, + {"itunes:episode": this.episode} ] } } } -module.exports = FeedEpisode \ No newline at end of file +module.exports = FeedEpisode diff --git a/server/objects/FeedMeta.js b/server/objects/FeedMeta.js index 6c029095..94ce73e5 100644 --- a/server/objects/FeedMeta.js +++ b/server/objects/FeedMeta.js @@ -7,6 +7,7 @@ class FeedMeta { this.feedUrl = null this.link = null this.explicit = null + this.type = null if (meta) { this.construct(meta) @@ -21,6 +22,7 @@ class FeedMeta { this.feedUrl = meta.feedUrl this.link = meta.link this.explicit = meta.explicit + this.type = meta.type } toJSON() { @@ -31,7 +33,8 @@ class FeedMeta { imageUrl: this.imageUrl, feedUrl: this.feedUrl, link: this.link, - explicit: this.explicit + explicit: this.explicit, + type: this.type } } @@ -53,6 +56,7 @@ class FeedMeta { { 'author': this.author || 'advplyr' }, { 'itunes:author': this.author || 'advplyr' }, { 'itunes:summary': this.description || '' }, + { 'itunes:type': this.type }, { 'itunes:image': { _attr: { @@ -73,4 +77,4 @@ class FeedMeta { } } } -module.exports = FeedMeta \ No newline at end of file +module.exports = FeedMeta diff --git a/server/objects/metadata/PodcastMetadata.js b/server/objects/metadata/PodcastMetadata.js index 85e2c52d..59b5fa6f 100644 --- a/server/objects/metadata/PodcastMetadata.js +++ b/server/objects/metadata/PodcastMetadata.js @@ -15,6 +15,7 @@ class PodcastMetadata { this.itunesArtistId = null this.explicit = false this.language = null + this.type = null if (metadata) { this.construct(metadata) @@ -34,6 +35,7 @@ class PodcastMetadata { this.itunesArtistId = metadata.itunesArtistId this.explicit = metadata.explicit this.language = metadata.language || null + this.type = metadata.type || 'episodic' } toJSON() { @@ -49,7 +51,8 @@ class PodcastMetadata { itunesId: this.itunesId, itunesArtistId: this.itunesArtistId, explicit: this.explicit, - language: this.language + language: this.language, + type: this.type } } @@ -67,7 +70,8 @@ class PodcastMetadata { itunesId: this.itunesId, itunesArtistId: this.itunesArtistId, explicit: this.explicit, - language: this.language + language: this.language, + type: this.type } } @@ -112,6 +116,7 @@ class PodcastMetadata { this.itunesArtistId = mediaMetadata.itunesArtistId || null this.explicit = !!mediaMetadata.explicit this.language = mediaMetadata.language || null + this.type = mediaMetadata.type || null if (mediaMetadata.genres && mediaMetadata.genres.length) { this.genres = [...mediaMetadata.genres] } @@ -132,4 +137,4 @@ class PodcastMetadata { return hasUpdates } } -module.exports = PodcastMetadata \ No newline at end of file +module.exports = PodcastMetadata diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index ef7d54d1..bf7c4d4a 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -46,7 +46,8 @@ function extractPodcastMetadata(channel) { categories: extractCategories(channel), feedUrl: null, description: null, - descriptionPlain: null + descriptionPlain: null, + type: null } if (channel['itunes:new-feed-url']) { @@ -61,7 +62,7 @@ function extractPodcastMetadata(channel) { metadata.descriptionPlain = htmlSanitizer.stripAllTags(rawDescription) } - var arrayFields = ['title', 'language', 'itunes:explicit', 'itunes:author', 'pubDate', 'link'] + var arrayFields = ['title', 'language', 'itunes:explicit', 'itunes:author', 'pubDate', 'link', 'itunes:type'] arrayFields.forEach((key) => { var cleanKey = key.split(':').pop() metadata[cleanKey] = extractFirstArrayItem(channel, key) @@ -258,4 +259,4 @@ module.exports.findMatchingEpisodesInFeed = (feed, searchTitle) => { } }) return matches.sort((a, b) => a.levenshtein - b.levenshtein) -} \ No newline at end of file +}