Skip to content

Commit

Permalink
Add option to mass-update the info language. (#10516)
Browse files Browse the repository at this point in the history
* Add option to mass-update the info language.

* Add id
  • Loading branch information
p0psicles authored Apr 20, 2022
1 parent 661a2b4 commit b036338
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
12 changes: 8 additions & 4 deletions medusa/server/api/v2/series_mass_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def post(self):
"""Perform a mass update action."""
required_options = (
'paused', 'defaultEpisodeStatus', 'anime', 'sports', 'scene',
'airByDate', 'seasonFolders', 'subtitles', 'qualities'
'airByDate', 'seasonFolders', 'subtitles', 'qualities', 'language', 'languageKeep'
)
data = json_decode(self.request.body)
shows = data.get('shows', [])
Expand Down Expand Up @@ -66,6 +66,8 @@ def post(self):
season_folders = options.get('seasonFolders')
subtitles = options.get('subtitles')
qualities = options.get('qualities')
language = options.get('language')
language_keep = options.get('languageKeep')

for show_slug in shows:
identifier = SeriesIdentifier.from_slug(show_slug)
Expand Down Expand Up @@ -96,6 +98,7 @@ def post(self):
new_dvd_order = show_obj.dvd_order if dvd_order is None else dvd_order
new_season_folders = show_obj.season_folders if season_folders is None else season_folders
new_subtitles = show_obj.subtitles if subtitles is None else subtitles
new_language = show_obj.lang if language_keep else language

# If both are false (two empty arrays), use the shows current value.
if not qualities['allowed'] and not qualities['preferred']:
Expand All @@ -112,17 +115,17 @@ def post(self):
allowed_qualities=new_quality_allowed, preferred_qualities=new_quality_preferred,
season_folders=new_season_folders, paused=new_paused, air_by_date=new_air_by_date, sports=new_sports,
dvd_order=new_dvd_order, subtitles=new_subtitles, anime=new_anime, scene=new_scene,
default_ep_status=new_default_ep_status,
default_ep_status=new_default_ep_status, language=new_language
)

return self._created(data={'errors': errors})

def mass_edit_show(
self, show_obj, location=None, allowed_qualities=None, preferred_qualities=None,
season_folders=None, paused=None, air_by_date=None, sports=None, dvd_order=None, subtitles=None,
anime=None, scene=None, default_ep_status=None
anime=None, scene=None, default_ep_status=None, language=None
):
"""A variation of the original `editShow`, where `directCall` is always true."""
"""Variation of the original `editShow`, where `directCall` is always true."""
allowed_qualities = allowed_qualities or []
preferred_qualities = preferred_qualities or []

Expand Down Expand Up @@ -169,6 +172,7 @@ def mass_edit_show(
show_obj.air_by_date = air_by_date
show_obj.default_ep_status = int(default_ep_status)
show_obj.dvd_order = dvd_order
show_obj.lang = language

# if we change location clear the db of episodes, change it, write to db, and rescan
old_location = path.normpath(show_obj._location)
Expand Down
37 changes: 35 additions & 2 deletions themes-default/slim/src/components/manage-mass-edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@
</select>
<p>Search for subtitles.</p>
</config-template>

<config-toggle-slider v-model="config.languageKeep" id="keep_language" label="Keep language" />
<config-template v-if="!config.languageKeep" label-for="indexerLangSelect" label="Info Language">
<language-select
id="indexerLangSelect"
@update-language="config.language = $event"
:language="config.language"
:available="availableLanguages"
name="indexer_lang"
class="form-control form-control-inline input-sm"
/>
<div class="clear-left"><p>This only applies to episode filenames and the contents of metadata files.</p></div>
</config-template>
</fieldset>
<button class="btn-medusa config_submitter pull-left"
:disabled="saving"
Expand All @@ -130,7 +143,13 @@

<script>
import { mapActions, mapState } from 'vuex';
import { AppLink, StateSwitch, QualityChooser } from './helpers';
import {
AppLink,
LanguageSelect,
ConfigToggleSlider,
StateSwitch,
QualityChooser
} from './helpers';
import ConfigTemplate from './helpers/config-template.vue';
import EditRootDirs from './helpers/edit-root-dirs.vue';
import { combineQualities } from '../utils/core';
Expand All @@ -140,7 +159,9 @@ export default {
components: {
AppLink,
ConfigTemplate,
ConfigToggleSlider,
EditRootDirs,
LanguageSelect,
QualityChooser,
StateSwitch
},
Expand All @@ -164,6 +185,8 @@ export default {
airByDate: null,
dvdOrder: null,
subtitles: null,
language: null,
languageKeep: null,
rootDirs: []
}
};
Expand All @@ -185,12 +208,15 @@ export default {
this.config.dvdOrder = allEqual(shows.map(show => show.config.dvdOrder)) ? shows[0].config.dvdOrder : null;
this.config.subtitles = allEqual(shows.map(show => show.config.subtitlesEnabled)) ? shows[0].config.subtitlesEnabled : null;
this.config.rootDirs = this.setRootDirs.map(rd => ({ old: rd, new: rd }));
this.config.language = shows[0].language;
this.config.languageKeep = !allEqual(shows.map(show => show.language));
},
computed: {
...mapState({
general: state => state.config.general,
layout: state => state.config.layout,
client: state => state.auth.client
client: state => state.auth.client,
indexers: state => state.config.indexers
}),
setRootDirs() {
return [...new Set(this.shows.map(show => show.config.rootDir))];
Expand All @@ -202,6 +228,13 @@ export default {
return 0;
}
return combineQualities(qualities.allowed, qualities.preferred);
},
availableLanguages() {
if (this.indexers.main.validLanguages) {
return this.indexers.main.validLanguages.join(',');
}
return '';
}
},
methods: {
Expand Down
4 changes: 2 additions & 2 deletions themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

0 comments on commit b036338

Please sign in to comment.