From 31d7a73d9a4b781d42e98dcfca9cfbede4361e40 Mon Sep 17 00:00:00 2001 From: GARNIER Joris Date: Sat, 9 Mar 2019 19:57:32 +0100 Subject: [PATCH] Adapted to mal-scraper 2.5.0 and fixed malform and malPage (can't really use malForm tho since API still dead) --- app/api/mal/official.js | 2 ++ app/web/assets/App.vue | 4 +++- app/web/components/global/malForm.vue | 16 +++++++-------- app/web/pages/malPage.vue | 21 ++++++++++---------- app/web/store/modules/mal/getters.js | 27 ++++++++++---------------- app/web/store/modules/mal/mutations.js | 2 +- package.json | 12 +++++++----- 7 files changed, 41 insertions(+), 43 deletions(-) diff --git a/app/api/mal/official.js b/app/api/mal/official.js index f0df38f..aa51318 100644 --- a/app/api/mal/official.js +++ b/app/api/mal/official.js @@ -54,6 +54,8 @@ const actOnList = (req, res) => { api.actOnList(type, id, opts) .then((data) => { + if (data.includes('404 Not Found')) throw new Error(404) + logger.info('(Act on List):' + data) res.status(typeof data === 'string' ? 200 : 204).send() }) diff --git a/app/web/assets/App.vue b/app/web/assets/App.vue index d5af535..ec777fd 100644 --- a/app/web/assets/App.vue +++ b/app/web/assets/App.vue @@ -14,7 +14,7 @@ overlay(v-show='overlay') video-modal(v-show='$store.state.streaming.player.show') magnets-modal - //- mal-form + mal-form //- Used for displaying any info v-snackbar( @@ -38,6 +38,7 @@ import MagnetsModal from 'components/magnets/modal.vue' import VideoModal from 'components/video/modal.vue' import Overlay from 'components/global/overlay.vue' import Env from 'components/global/env.vue' +import MalForm from 'components/global/malForm.vue' // Mixins import Meta from 'mixins/global/meta' @@ -55,6 +56,7 @@ export default { // Global TorrentDialog, + MalForm, MagnetsModal, VideoModal, Overlay, diff --git a/app/web/components/global/malForm.vue b/app/web/components/global/malForm.vue index 0dfebbe..2410736 100644 --- a/app/web/components/global/malForm.vue +++ b/app/web/components/global/malForm.vue @@ -214,13 +214,13 @@ export default { return this.$store.state.mal.entry }, entryTitle () { - return ': ' + (this.entry.title || this.entry.name) + return ': ' + (this.entry.animeTitle || this.entry.name) }, nbEpisodes () { - return this.entry.nbEpisodes || this.entry.episodes + return this.entry.animeNumEpisodes || this.entry.episodes }, isEdit () { - return this.entry.lastUpdate + return !!this.entry.animeTitle }, addOrEdit () { return this.isEdit ? 'Edit' : 'Add' @@ -232,7 +232,7 @@ export default { this.form = this.initForm }, submit () { - const id = this.entry.id + const id = this.entry.id || this.entry.animeId const opts = this.$_.clone(this.form) opts.tags = opts.tags.join(', ') @@ -284,12 +284,10 @@ export default { if (this.isEdit) { this.form.status = obj.status this.form.score = obj.score || null - this.form.episode = obj.nbWatchedEpisode || null - this.form.date_start = obj.startDate || null - this.form.date_finish = obj.endDate || null + this.form.episode = obj.numWatchedEpisodes || null this.form.tags = obj.tags.length ? obj.tags.split(', ') : [] - this.form.date_start = obj.myStartDate === '0000-00-00' ? null : obj.myStartDate - this.form.date_finish = obj.myEndDate === '0000-00-00' ? null : obj.myEndDate + this.form.date_start = obj.startDateString === '0000-00-00' ? null : obj.startDateString + this.form.date_finish = obj.endDateString === '0000-00-00' ? null : obj.endDateString } const { id } = obj diff --git a/app/web/pages/malPage.vue b/app/web/pages/malPage.vue index 3661c4a..71bff4d 100644 --- a/app/web/pages/malPage.vue +++ b/app/web/pages/malPage.vue @@ -4,14 +4,15 @@ v-flex.centered(xs12, sm2) .headline.pl-4 MyAnimeList v-flex.centered.pr-2(xs10, sm3, md3, offset-sm1) - v-select( + v-autocomplete( v-model='tagsFilter', :items='customTags', label='Tags', persistent-hint, hint='Looking for special tags?', single-line, - clearable, dense, chips, tags + clearable, dense, + multiple, deletable-chips, small-chips ) v-flex.centered.pl-2(xs8, sm3, md3, offset-md1) v-text-field( @@ -38,19 +39,19 @@ :rows-per-page-items='rowsPerPage' ) template(slot='items', slot-scope='props') - td.text-xs-center + td.pa-0.text-xs-center img.entry-image(:src='props.item.image') - td.text-xs-left.entry-title + td.pa-0.text-xs-left.entry-title span.pl-3 {{ props.item.title }} - td.text-xs-center {{ props.item.score }} - td.text-xs-center {{ props.item.type }} - td.text-xs-center {{ props.item.progress }} - td.text-xs-center {{ props.item.status }} - td.text-xs-center.ellipsis.entry-tags + td.pa-0.text-xs-center {{ props.item.score }} + td.pa-0.text-xs-center {{ props.item.type }} + td.pa-0.text-xs-center {{ props.item.progress }} + td.pa-0.text-xs-center {{ props.item.status }} + td.pa-0.text-xs-center.ellipsis.entry-tags v-tooltip(top) span(slot='activator') {{ props.item.tags }} span {{ props.item.tags }} - td + td.pa-0 v-btn.blue--text.darken-1(icon, flat, @click.stop='showForm(props.item.id)') v-icon edit v-btn.blue--text.darken-1(icon, flat, @click.stop='showInfo(props.item.title, props.item.link)') diff --git a/app/web/store/modules/mal/getters.js b/app/web/store/modules/mal/getters.js index 6e197ab..84b4abb 100644 --- a/app/web/store/modules/mal/getters.js +++ b/app/web/store/modules/mal/getters.js @@ -10,30 +10,23 @@ export default { 4: 'Dropped', 6: 'Plan to watch' } - const types = { - 1: 'TV', - 2: 'OVA', - 3: 'Movie', - 4: 'Special', - 5: 'ONA' - } _.each(state.watchLists, (entry) => { - const dec = (+entry.nbWatchedEpisode / +entry.nbEpisodes) || 1 + const dec = (+entry.numWatchedEpisodes / +entry.animeNumEpisodes) || 1 const toAdd = { score: entry.score || 'N/A', - progress: (entry.nbWatchedEpisode || '??') + ' / ' + (entry.nbEpisodes || '??'), - progressDec: (dec === 1 ? entry.nbWatchedEpisode : dec), - title: entry.title, - type: types[entry.type], - image: entry.picture, - id: entry.id, + progress: (entry.numWatchedEpisodes || '??') + ' / ' + (entry.animeNumEpisodes || '??'), + progressDec: (dec === 1 ? entry.numWatchedEpisodes : dec), + title: entry.animeTitle, + type: entry.animeMediaTypeString, + image: entry.animeImagePath, + id: entry.animeId, status: status[entry.status], statusNum: entry.status, - start: entry.myStartDate === '0000-00-00' ? null : entry.myStartDate, - end: entry.myEndDate === '0000-00-00' ? null : entry.myEndDate, - link: 'https://myanimelist.net/anime/' + entry.id + '/' + entry.title, + start: entry.startDateString === '0000-00-00' ? null : entry.startDateString, + end: entry.endDateString === '0000-00-00' ? null : entry.endDateString, + link: 'https://myanimelist.net' + entry.animeUrl, tags: entry.tags || 'No tags', nbCorrespondingTags: 0 } diff --git a/app/web/store/modules/mal/mutations.js b/app/web/store/modules/mal/mutations.js index fa22c7e..bf40250 100644 --- a/app/web/store/modules/mal/mutations.js +++ b/app/web/store/modules/mal/mutations.js @@ -10,7 +10,7 @@ export default { setEntry (state, itemOrID) { const id = itemOrID.id || itemOrID // Need to find the right entry in the lists if it's in there - state.entry = _.find(state.watchLists, (o) => o.id === id) || itemOrID + state.entry = _.find(state.watchLists, (o) => o.animeId === id) || itemOrID }, isAdding (state, bool) { state.isAdding = bool diff --git a/package.json b/package.json index 22e0c82..1c6a439 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "express": "^4.16.4", "lodash": "^4.17.11", "lru-cache": "^4.1.3", - "mal-scraper": "^2.4.5", + "mal-scraper": "^2.5.0", "matroska-subtitles": "^2.0.3", "mime": "^2.4.0", "moment": "^2.23.0", @@ -154,9 +154,11 @@ "oneClick": false, "allowToChangeInstallationDirectory": true }, - "fileAssociations": [{ - "ext": "torrent", - "name": "Torrent files" - }] + "fileAssociations": [ + { + "ext": "torrent", + "name": "Torrent files" + } + ] } }