Skip to content

Commit

Permalink
Update AniDB component (#6880)
Browse files Browse the repository at this point in the history
* Update shows store module

* Update anidb-release-group-ui.vue

Use `showName` prop with `apiRoute('home/fetch_releasegroups')`

* Remove fetching of AniDB data in `Series`

* Update add-show-options template

* [bundle]

* show -> series

* emit group names on change (not objects)
  • Loading branch information
sharkykh authored and p0psicles committed Jun 27, 2019
1 parent afb6a4d commit 317bcb3
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 160 deletions.
7 changes: 0 additions & 7 deletions dredd/api-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ paths:
description: Filter series based on paused status
type: boolean
- $ref: '#/parameters/detailed'
- $ref: '#/parameters/fetch'
- $ref: '#/parameters/page'
- $ref: '#/parameters/limit'
- $ref: '#/parameters/sort'
Expand Down Expand Up @@ -2475,12 +2474,6 @@ parameters:
required: false
description: Whether response should contain detailed information
type: boolean
fetch:
name: fetch
in: query
required: false
description: Whether response should fetch external information
type: boolean
page:
name: page
in: query
Expand Down
6 changes: 2 additions & 4 deletions medusa/server/api/v2/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ def filter_series(current):

if not series_slug:
detailed = self._parse_boolean(self.get_argument('detailed', default=False))
fetch = self._parse_boolean(self.get_argument('fetch', default=False))
data = [
s.to_json(detailed=detailed, fetch=fetch)
s.to_json(detailed=detailed)
for s in Series.find_series(predicate=filter_series)
]
return self._paginate(data, sort='title')
Expand All @@ -65,8 +64,7 @@ def filter_series(current):
return self._not_found('Series not found')

detailed = self._parse_boolean(self.get_argument('detailed', default=True))
fetch = self._parse_boolean(self.get_argument('fetch', default=False))
data = series.to_json(detailed=detailed, fetch=fetch)
data = series.to_json(detailed=detailed)
if path_param:
if path_param not in data:
return self._bad_request("Invalid path parameter '{0}'".format(path_param))
Expand Down
23 changes: 3 additions & 20 deletions medusa/tv/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
try_int,
)
from medusa.helper.exceptions import (
AnidbAdbaConnectionException,
CantRefreshShowException,
CantRemoveShowException,
EpisodeDeletedException,
Expand All @@ -64,7 +63,7 @@
ShowNotFoundException,
ex,
)
from medusa.helpers.anidb import get_release_groups_for_anime, short_group_names
from medusa.helpers.anidb import short_group_names
from medusa.helpers.externals import get_externals, load_externals_from_db
from medusa.helpers.utils import safe_get, to_camel_case
from medusa.imdb import Imdb
Expand Down Expand Up @@ -2061,15 +2060,12 @@ def __unicode__(self):
to_return += u'anime: {0}\n'.format(self.is_anime)
return to_return

def to_json(self, detailed=True, fetch=False):
def to_json(self, detailed=True):
"""
Return JSON representation.
:param detailed: Append seasons & episodes data as well
:param fetch: Fetch and append external data (for example AniDB release groups)
"""
bw_list = self.release_groups or BlackAndWhiteList(self)

data = {}
data['id'] = {}
data['id'][self.indexer_name] = self.series_id
Expand Down Expand Up @@ -2130,23 +2126,10 @@ def to_json(self, detailed=True, fetch=False):

# These are for now considered anime-only options
if self.is_anime:
bw_list = self.release_groups or BlackAndWhiteList(self)
data['config']['release']['blacklist'] = bw_list.blacklist
data['config']['release']['whitelist'] = bw_list.whitelist

# Fetch data from external sources
if fetch:
# These are for now considered anime-only options, as they query anidb for available release groups.
if self.is_anime:
try:
data['config']['release']['allgroups'] = get_release_groups_for_anime(self.name)
except AnidbAdbaConnectionException as error:
data['config']['release']['allgroups'] = []
log.warning(
'An anidb adba exception occurred when attempting to get the release groups for the show {show}'
'\nError: {error}',
{'show': self.name, 'error': error}
)

if detailed:
episodes = self.get_all_episodes()
data['size'] = self.size
Expand Down
97 changes: 41 additions & 56 deletions themes-default/slim/src/components/add-show-options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
</div>

<div v-if="subtitlesEnabled" id="use-subtitles">
<config-toggle-slider label="Subtitles" id="subtitles" :value="selectedSubtitleEnabled" @input="selectedSubtitleEnabled = $event"
:explanations="['Download subtitles for this show?']">
</config-toggle-slider>
<config-toggle-slider
label="Subtitles"
id="subtitles"
:value="selectedSubtitleEnabled"
:explanations="['Download subtitles for this show?']"
@input="selectedSubtitleEnabled = $event"
/>
</div>

<div class="form-group">
Expand Down Expand Up @@ -48,30 +52,46 @@
</div>
</div>

<config-toggle-slider label="Season Folders" id="season_folders" :value="selectedSeasonFoldersEnabled" :disabled="namingForceFolders"
:explanations="['Group episodes by season folders?']" @input="selectedSeasonFoldersEnabled = $event">
</config-toggle-slider>
<config-toggle-slider
label="Season Folders"
id="season_folders"
:value="selectedSeasonFoldersEnabled"
:disabled="namingForceFolders"
:explanations="['Group episodes by season folders?']"
@input="selectedSeasonFoldersEnabled = $event"
/>

<config-toggle-slider v-if="enableAnimeOptions" label="Anime" id="anime"
:explanations="['Is this show an Anime?']" :value="selectedAnimeEnabled" @input="selectedAnimeEnabled = $event">
</config-toggle-slider>
<config-toggle-slider
v-if="enableAnimeOptions"
label="Anime"
id="anime"
:value="selectedAnimeEnabled"
:explanations="['Is this show an Anime?']"
@input="selectedAnimeEnabled = $event"
/>

<div v-if="enableAnimeOptions && selectedAnimeEnabled" class="form-group">
<div class="row">
<label for="anidbReleaseGroup" class="col-sm-2 control-label">
<span>Release Groups</span>
</label>
<div class="col-sm-10 content">
<anidb-release-group-ui class="max-width" :blacklist="release.blacklist" :whitelist="release.whitelist"
:all-groups="release.allgroups" @change="onChangeReleaseGroupsAnime">
</anidb-release-group-ui>
<anidb-release-group-ui
class="max-width"
:show-name="showName"
@change="onChangeReleaseGroupsAnime"
/>
</div>
</div>
</div>

<config-toggle-slider label="Scene Numbering" id="scene" :value="selectedSceneEnabled"
:explanations="['Is this show scene numbered?']" @input="selectedSceneEnabled = $event">
</config-toggle-slider>
<config-toggle-slider
label="Scene Numbering"
id="scene"
:value="selectedSceneEnabled"
:explanations="['Is this show scene numbered?']"
@input="selectedSceneEnabled = $event"
/>

<div class="form-group">
<div class="row">
Expand All @@ -86,9 +106,9 @@
</fieldset>
</div>
</template>

<script>
import { mapState, mapGetters } from 'vuex';
import { apiRoute } from '../api';
import { combineQualities } from '../utils/core';
import {
ConfigToggleSlider,
Expand Down Expand Up @@ -129,8 +149,7 @@ export default {
selectedSceneEnabled: false,
release: {
blacklist: [],
whitelist: [],
allgroups: []
whitelist: []
}
};
},
Expand All @@ -152,23 +171,6 @@ export default {
});
},
methods: {
getReleaseGroups(showName) {
const params = {
series_name: showName // eslint-disable-line camelcase
};
return apiRoute
.get('home/fetch_releasegroups', { params, timeout: 30000 })
.then(response => response.data)
.catch(error => {
this.$snotify.warning(
`Error while trying to fetch release groups for show "${showName}": ${error || 'Unknown'}`,
'Error'
);
console.warn(error);
return null;
});
},
update() {
const {
selectedSubtitleEnabled,
Expand All @@ -193,9 +195,9 @@ export default {
});
});
},
onChangeReleaseGroupsAnime(items) {
this.release.whitelist = items.filter(item => item.memberOf === 'whitelist').map(item => item.name);
this.release.blacklist = items.filter(item => item.memberOf === 'blacklist').map(item => item.name);
onChangeReleaseGroupsAnime(groupNames) {
this.release.whitelist = groupNames.whitelist;
this.release.blacklist = groupNames.blacklist;
this.update();
},
saveDefaults() {
Expand Down Expand Up @@ -294,24 +296,7 @@ export default {
].every(Boolean);
}
},
asyncComputed: {
releaseGroups() {
const { selectedAnimeEnabled, showName } = this;
if (!selectedAnimeEnabled || !showName) {
return Promise.resolve([]);
}
return this.getReleaseGroups(showName).then(result => {
if (result.groups) {
return result.groups;
}
});
}
},
watch: {
releaseGroups(groups) {
this.release.allgroups = groups;
},
release: {
handler() {
this.$emit('refresh');
Expand Down Expand Up @@ -348,6 +333,6 @@ export default {
}
};
</script>
<style>

<style>
</style>

0 comments on commit 317bcb3

Please sign in to comment.