Merge pull request #65 from mmshivesh/feature-add-language-filter

This commit is contained in:
Cody Robibero 2024-05-13 07:10:47 -06:00 committed by GitHub
commit b04ed7ddb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 15 deletions

View File

@ -25,12 +25,19 @@ namespace Jellyfin.Plugin.AniList.Configuration
None, Anime, Animation
}
public enum LanguageFilterType {
Localized,
Japanese,
All
}
public class PluginConfiguration : BasePluginConfiguration
{
public PluginConfiguration()
{
TitlePreference = TitlePreferenceType.Localized;
OriginalTitlePreference = TitlePreferenceType.JapaneseRomaji;
PersonLanguageFilterPreference = LanguageFilterType.All;
MaxGenres = 5;
AnimeDefaultGenre = AnimeDefaultGenreType.Anime;
AniDbRateLimit = 2000;
@ -43,6 +50,8 @@ namespace Jellyfin.Plugin.AniList.Configuration
public TitlePreferenceType OriginalTitlePreference { get; set; }
public LanguageFilterType PersonLanguageFilterPreference { get; set; }
public int MaxGenres { get; set; }
public AnimeDefaultGenreType AnimeDefaultGenre { get; set; }
@ -53,8 +62,6 @@ namespace Jellyfin.Plugin.AniList.Configuration
public bool AniListShowSpoilerTags { get; set; }
public bool FilterPeopleByTitlePreference { get; set; }
public bool UseAnitomyLibrary { get; set; }
}

View File

@ -26,14 +26,17 @@
<option id="optLanguageJapaneseRomaji" value="JapaneseRomaji">Romaji</option>
</select>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="chkFilterPeopleByTitlePreference" name="chkFilterPeopleByTitlePreference" type="checkbox" is="emby-checkbox" />
<span>Filter people by title preference</span>
</label>
<div class="selectContainer">
<label class="selectLabel" for="filterPeopleByLanguage">Filter People by Language Preference</label>
<select is="emby-select" id="filterPeopleByLanguage" name="filterPeopleByLanguage" class="emby-select-withcolor emby-select">
<option id="optLanguageLocalized" value="Localized">Localized</option>
<option id="optLanguageJapanese" value="Japanese">Japanese</option>
<option id="optLanguageAll" value="All">Do not filter</option>
</select>
<div class="fieldDescription">This setting will only keep people with chosen language. Choosing Localized will retain everybody except Japanese VAs.</div>
</div>
<div class="inputContainer">
<label class="inputeLabel inputLabelUnfocused" for="chkMaxGenres">Max Genres</label>
<label class="inputLabel inputLabelUnfocused" for="chkMaxGenres">Max Genres</label>
<input id="chkMaxGenres" name="chkMaxGenres" type="number" is="emby-input" min="0" />
<div class="fieldDescription">Set this to zero to remove any limit.</div>
</div>
@ -46,7 +49,7 @@
</select>
</div>
<div class="inputContainer">
<label class="inputeLabel inputLabelUnfocused" for="chkAniDbRateLimit">AniDB Rate Limit</label>
<label class="inputLabel inputLabelUnfocused" for="chkAniDbRateLimit">AniDB Rate Limit</label>
<input id="chkAniDbRateLimit" name="chkAniDbRateLimit" type="number" is="emby-input" min="0" />
<div class="fieldDescription">This will prevent IP bans for requesting data too quickly.</div>
</div>
@ -87,7 +90,7 @@
ApiClient.getPluginConfiguration(AniListConfigurationPage.pluginUniqueId).then(function (config) {
document.getElementById('titleLanguage').value = config.TitlePreference;
document.getElementById('originalTitleLanguage').value = config.OriginalTitlePreference;
document.getElementById('chkFilterPeopleByTitlePreference').checked = config.FilterPeopleByTitlePreference;
document.getElementById('filterPeopleByLanguage').value = config.PersonLanguageFilterPreference;
document.getElementById('chkMaxGenres').value = config.MaxGenres;
document.getElementById('animeDefaultGenre').value = config.AnimeDefaultGenre;
document.getElementById('chkAniDbRateLimit').value = config.AniDbRateLimit;
@ -105,7 +108,7 @@
ApiClient.getPluginConfiguration(AniListConfigurationPage.pluginUniqueId).then(function (config) {
config.TitlePreference = document.getElementById('titleLanguage').value;
config.OriginalTitlePreference = document.getElementById('originalTitleLanguage').value;
config.FilterPeopleByTitlePreference = document.getElementById('chkFilterPeopleByTitlePreference').checked;
config.PersonLanguageFilterPreference = document.getElementById('filterPeopleByLanguage').value;
config.MaxGenres = document.getElementById('chkMaxGenres').value;
config.AnimeDefaultGenre = document.getElementById('animeDefaultGenre').value;
config.AniDbRateLimit = document.getElementById('chkAniDbRateLimit').value;

View File

@ -129,7 +129,7 @@ query($id: Int!, $type: MediaType) {
medium
large
}
language
language: languageV2
}
}
}

View File

@ -199,11 +199,11 @@ namespace Jellyfin.Plugin.AniList.Providers.AniList
{
foreach (VoiceActor va in edge.voiceActors)
{
if (config.FilterPeopleByTitlePreference) {
if (config.TitlePreference != TitlePreferenceType.Localized && va.language != "JAPANESE") {
if (config.PersonLanguageFilterPreference != LanguageFilterType.All) {
if (config.PersonLanguageFilterPreference == LanguageFilterType.Japanese && va.language != "Japanese") {
continue;
}
if (config.TitlePreference == TitlePreferenceType.Localized && va.language == "JAPANESE") {
if (config.PersonLanguageFilterPreference == LanguageFilterType.Localized && va.language == "Japanese") {
continue;
}
}