From 034d858f1804c8a5456693a646b5bed0915c365c Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 23 Apr 2022 19:41:06 -0500 Subject: [PATCH] Change new podcast modal to remove episode download list #494, Fix error when importing many episodes (set max size to 5MB) #493, show podcast episodes downloading and in queue on podcast landing page --- client/components/app/LazyBookshelf.vue | 7 +- client/components/cards/LazyBookCard.vue | 23 ++-- client/components/controls/FilterSelect.vue | 21 +-- .../components/modals/podcast/EpisodeFeed.vue | 11 +- client/components/modals/podcast/NewModal.vue | 122 +++++------------- client/pages/item/_id/index.vue | 64 ++++++++- server/Server.js | 4 +- server/controllers/LibraryItemController.js | 3 + server/controllers/PodcastController.js | 28 +++- server/managers/CoverManager.js | 5 +- server/managers/PodcastManager.js | 26 ++++ server/objects/PodcastEpisodeDownload.js | 30 ++++- server/routers/ApiRouter.js | 2 + server/utils/libraryHelpers.js | 2 +- 14 files changed, 222 insertions(+), 126 deletions(-) diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index 797d08e6..7f78d560 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -89,9 +89,12 @@ export default { return this.$store.getters['libraries/getCurrentLibraryMediaType'] == 'podcast' }, emptyMessage() { - if (this.page === 'series') return `You have no series` + if (this.page === 'series') return 'You have no series' if (this.page === 'collections') return "You haven't made any collections yet" - if (this.hasFilter) return `No Results for filter "${this.filterName}: ${this.filterValue}"` + if (this.hasFilter) { + if (this.filterName === 'Issues') return 'No Issues' + return `No Results for filter "${this.filterName}: ${this.filterValue}"` + } return 'No results' }, entityName() { diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index a51d720e..9d93301f 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -272,7 +272,7 @@ export default { return this.userProgress ? !!this.userProgress.isFinished : false }, showError() { - return this.hasMissingParts || this.hasInvalidParts || this.isMissing || this.isInvalid + return this.numMissingParts || this.isMissing || this.isInvalid }, isStreaming() { return this.store.getters['getlibraryItemIdStreaming'] === this.libraryItemId @@ -292,22 +292,19 @@ export default { isInvalid() { return this._libraryItem.isInvalid }, - hasMissingParts() { - return this._libraryItem.hasMissingParts - }, - hasInvalidParts() { - return this._libraryItem.hasInvalidParts + numMissingParts() { + if (this.isPodcast) return 0 + return this.media.numMissingParts }, errorText() { if (this.isMissing) return 'Item directory is missing!' - else if (this.isInvalid) return 'Item has no audio tracks & ebook' - var txt = '' - if (this.hasMissingParts) { - txt = `${this.hasMissingParts} missing parts.` + else if (this.isInvalid) { + if (this.isPodcast) return 'Podcast has no episodes' + return 'Item has no audio tracks & ebook' } - if (this.hasInvalidParts) { - if (this.hasMissingParts) txt += ' ' - txt += `${this.hasInvalidParts} invalid parts.` + var txt = '' + if (this.numMissingParts) { + txt = `${this.numMissingParts} missing parts.` } return txt || 'Unknown Error' }, diff --git a/client/components/controls/FilterSelect.vue b/client/components/controls/FilterSelect.vue index 58b0d700..dc5ed98c 100644 --- a/client/components/controls/FilterSelect.vue +++ b/client/components/controls/FilterSelect.vue @@ -132,6 +132,11 @@ export default { text: 'Tag', value: 'tags', sublist: true + }, + { + text: 'Issues', + value: 'issues', + sublist: false } ] } @@ -166,26 +171,26 @@ export default { selectedText() { if (!this.selected) return '' var parts = this.selected.split('.') - var filterName = this.selectItems.find((i) => i.value === parts[0]); - var filterValue = null; + var filterName = this.selectItems.find((i) => i.value === parts[0]) + var filterValue = null if (parts.length > 1) { var decoded = this.$decode(parts[1]) if (decoded.startsWith('aut_')) { var author = this.authors.find((au) => au.id == decoded) - if (author) filterValue = author.name; + if (author) filterValue = author.name } else if (decoded.startsWith('ser_')) { var series = this.series.find((se) => se.id == decoded) if (series) filterValue = series.name } else { - filterValue = decoded; + filterValue = decoded } } if (filterName && filterValue) { - return `${filterName.text}: ${filterValue}`; + return `${filterName.text}: ${filterValue}` } else if (filterName) { - return filterName.text; + return filterName.text } else if (filterValue) { - return filterValue; + return filterValue } else { return '' } @@ -212,7 +217,7 @@ export default { return ['Finished', 'In Progress', 'Not Started'] }, missing() { - return ['ASIN', 'ISBN', 'Subtitle', 'Author', 'Publish Year', 'Series', 'Volume Number', 'Description', 'Genres', 'Tags', 'Narrator', 'Publisher', 'Language', ] + return ['ASIN', 'ISBN', 'Subtitle', 'Author', 'Publish Year', 'Series', 'Volume Number', 'Description', 'Genres', 'Tags', 'Narrator', 'Publisher', 'Language'] }, sublistItems() { return (this[this.sublist] || []).map((item) => { diff --git a/client/components/modals/podcast/EpisodeFeed.vue b/client/components/modals/podcast/EpisodeFeed.vue index eb1c0fe3..b5f94a61 100644 --- a/client/components/modals/podcast/EpisodeFeed.vue +++ b/client/components/modals/podcast/EpisodeFeed.vue @@ -124,7 +124,13 @@ export default { episodesToDownload = this.episodesSelected.map((episodeIndex) => this.episodes[Number(episodeIndex)]) } - console.log('Podcast payload', episodesToDownload) + var payloadSize = JSON.stringify(episodesToDownload).length + var sizeInMb = payloadSize / 1024 / 1024 + var sizeInMbPretty = sizeInMb.toFixed(2) + 'MB' + console.log('Request size', sizeInMb) + if (sizeInMb > 4.99) { + return this.$toast.error(`Request is too large (${sizeInMbPretty}) should be < 5Mb`) + } this.processing = true this.$axios @@ -144,7 +150,8 @@ export default { init() { for (let i = 0; i < this.episodes.length; i++) { var episode = this.episodes[i] - if (episode.enclosure && !this.itemEpisodeMap[episode.enclosure.url]) { // Do not include episodes already downloaded + if (episode.enclosure && !this.itemEpisodeMap[episode.enclosure.url]) { + // Do not include episodes already downloaded this.$set(this.selectedEpisodes, String(i), false) } } diff --git a/client/components/modals/podcast/NewModal.vue b/client/components/modals/podcast/NewModal.vue index 35e247a5..5d55783a 100644 --- a/client/components/modals/podcast/NewModal.vue +++ b/client/components/modals/podcast/NewModal.vue @@ -1,63 +1,42 @@