mirror of
https://github.com/jellyfin/jellyfin-plugin-anidb.git
synced 2024-11-23 13:59:43 +00:00
Added title case genres, default anime genre name and fixes
This commit is contained in:
parent
8045f093cc
commit
8045bd6846
@ -20,6 +20,11 @@ namespace Jellyfin.Plugin.Anime.Configuration
|
||||
JapaneseRomaji
|
||||
}
|
||||
|
||||
public enum AnimeDefaultGenreType
|
||||
{
|
||||
None, Anime, Animation
|
||||
}
|
||||
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
public PluginConfiguration()
|
||||
@ -27,7 +32,8 @@ namespace Jellyfin.Plugin.Anime.Configuration
|
||||
TitlePreference = TitlePreferenceType.Localized;
|
||||
MaxGenres = 5;
|
||||
TidyGenreList = true;
|
||||
AddAnimeGenre = true;
|
||||
TitleCaseGenres = false;
|
||||
AnimeDefaultGenre = AnimeDefaultGenreType.Anime;
|
||||
AniDbRateLimit = 2000;
|
||||
AniDbReplaceGraves = true;
|
||||
}
|
||||
@ -38,7 +44,9 @@ namespace Jellyfin.Plugin.Anime.Configuration
|
||||
|
||||
public bool TidyGenreList { get; set; }
|
||||
|
||||
public bool AddAnimeGenre { get; set; }
|
||||
public bool TitleCaseGenres { get; set; }
|
||||
|
||||
public AnimeDefaultGenreType AnimeDefaultGenre { get; set; }
|
||||
|
||||
public int AniDbRateLimit { get; set; }
|
||||
|
||||
|
@ -20,29 +20,37 @@
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputeLabel inputLabelUnfocused" for="chkMaxGenres">Max Genres</label>
|
||||
<input id="chkMaxGenres" name="chkMaxGenres" type="number" is="emby-input" min="0"/>
|
||||
<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>
|
||||
<div class="checkboxContainer checkboxContainer-withDescripton">
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="chkTidyGenres" name="chkTidyGenres" type="checkbox" is="emby-checkbox"/>
|
||||
<input id="chkTitleCaseGenres" name="chkTitleCaseGenres" type="checkbox" is="emby-checkbox" />
|
||||
<span>Title Case Genres</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="chkTidyGenres" name="chkTidyGenres" type="checkbox" is="emby-checkbox" />
|
||||
<span>Tidy Genre List</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescripton">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="chkAddAnimeGenre" name="chkAddAnimeGenre" type="checkbox" is="emby-checkbox"/>
|
||||
<span>Add Anime Genre</span>
|
||||
</label>
|
||||
<div class="selectContainer">
|
||||
<label class="selectLabel" for="animeDefaultGenre">Anime Default Genre Name</label>
|
||||
<select is="emby-select" id="animeDefaultGenre" name="animeDefaultGenre" class="emby-select-withcolor emby-select">
|
||||
<option id="optDefaultGenreNone" value="None">None</option>
|
||||
<option id="optDefaultGenreAnime" value="Anime">Anime</option>
|
||||
<option id="optDefaultGenreAnimation" value="Animation">Animation</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputeLabel inputLabelUnfocused" for="chkAniDbWaitTime">AniDB Rate Limit</label>
|
||||
<input id="chkAniDbWaitTime" name="chkAniDbWaitTime" type="number" is="emby-input"/>
|
||||
<label class="inputeLabel 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>
|
||||
<div class="checkboxContainer checkboxContainer-withDescripton">
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="chkAniDbReplaceGraves" name="chkAniDbReplaceGraves" type="checkbox" is="emby-checkbox"/>
|
||||
<input id="chkAniDbReplaceGraves" name="chkAniDbReplaceGraves" type="checkbox" is="emby-checkbox" />
|
||||
<span>AniDB Replace Grave Characters</span>
|
||||
</label>
|
||||
</div>
|
||||
@ -59,34 +67,32 @@
|
||||
var AnimeConfigurationPage = {
|
||||
pluginUniqueId: "a4df60c5-6ab4-412a-8f79-2cab93fb2bc5",
|
||||
|
||||
loadConfiguration: function() {
|
||||
loadConfiguration: function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.getPluginConfiguration(AnimeConfigurationPage.pluginUniqueId).then(function (config) {
|
||||
var page = $.mobile.activePage;
|
||||
|
||||
$('#titleLanguage', page).val(config.TitlePreference).change();
|
||||
$('#chkMaxGenres', page).val(config.MaxGenres).change();
|
||||
document.getElementById('titleLanguage').value = config.TitlePreference;
|
||||
document.getElementById('chkMaxGenres').value = config.MaxGenres;
|
||||
document.getElementById('chkTitleCaseGenres').checked = config.TitleCaseGenres;
|
||||
document.getElementById('chkTidyGenres').checked = config.TidyGenreList;
|
||||
document.getElementById('chkAddAnimeGenre').checked = config.AddAnimeGenre;
|
||||
$('#chkAniDbWaitTime', page).val(config.AniDbWaitTime).change();
|
||||
document.getElementById('animeDefaultGenre').value = config.AnimeDefaultGenre;
|
||||
document.getElementById('chkAniDbRateLimit').value = config.AniDbRateLimit;
|
||||
document.getElementById('chkAniDbReplaceGraves').checked = config.AniDbReplaceGraves;
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
},
|
||||
|
||||
saveConfiguration: function() {
|
||||
saveConfiguration: function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.getPluginConfiguration(AnimeConfigurationPage.pluginUniqueId).then(function(config) {
|
||||
var page = $.mobile.activePage;
|
||||
|
||||
config.TitlePreference = $('#titleLanguage', page).val();
|
||||
config.MaxGenres = $('#chkMaxGenres').val();
|
||||
ApiClient.getPluginConfiguration(AnimeConfigurationPage.pluginUniqueId).then(function (config) {
|
||||
config.TitlePreference = document.getElementById('titleLanguage').value;
|
||||
config.MaxGenres = document.getElementById('chkMaxGenres').value;
|
||||
config.TitleCaseGenres = document.getElementById('chkTitleCaseGenres').checked;
|
||||
config.TidyGenreList = document.getElementById('chkTidyGenres').checked;
|
||||
config.AddAnimeGenre = document.getElementById('chkAddAnimeGenre').checked;
|
||||
config.AniDbWaitTime = $('#chkAniDbWaitTime').val();
|
||||
config.AnimeDefaultGenre = document.getElementById('animeDefaultGenre').value;
|
||||
config.AniDbRateLimit = document.getElementById('chkAniDbRateLimit').value;
|
||||
config.AniDbReplaceGraves = document.getElementById('chkAniDbReplaceGraves').checked;
|
||||
|
||||
ApiClient.updatePluginConfiguration(AnimeConfigurationPage.pluginUniqueId, config).then(function (result) {
|
||||
@ -96,13 +102,13 @@
|
||||
},
|
||||
};
|
||||
|
||||
$('#animeConfigurationPage').on('pageshow', function () {
|
||||
document.getElementById('animeConfigurationPage').addEventListener('pageshow', function () {
|
||||
AnimeConfigurationPage.loadConfiguration();
|
||||
});
|
||||
|
||||
$('#animeConfigurationForm').on('submit', function () {
|
||||
document.getElementById('animeConfigurationForm').addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
AnimeConfigurationPage.saveConfiguration();
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Jellyfin.Plugin.Anime.Configuration;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
@ -192,6 +193,11 @@ namespace Jellyfin.Plugin.Anime.Providers
|
||||
{
|
||||
PluginConfiguration config = Plugin.Instance.Configuration;
|
||||
|
||||
if (config.TitleCaseGenres)
|
||||
{
|
||||
series.Genres = series.Genres.Select(g => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(g)).ToArray();
|
||||
}
|
||||
|
||||
if (config.TidyGenreList)
|
||||
{
|
||||
series.Genres = RemoveRedundantGenres(series.Genres)
|
||||
@ -201,24 +207,17 @@ namespace Jellyfin.Plugin.Anime.Providers
|
||||
TidyGenres(series);
|
||||
}
|
||||
|
||||
var max = config.MaxGenres;
|
||||
if (config.AddAnimeGenre)
|
||||
if (config.AnimeDefaultGenre != AnimeDefaultGenreType.None)
|
||||
{
|
||||
series.Genres = series.Genres.Except(new[] { "Animation", "Anime" }).ToArray();
|
||||
|
||||
max = Math.Max(max - 1, 0);
|
||||
series.Genres = series.Genres
|
||||
.Except(new[] { "Animation", "Anime" })
|
||||
.Prepend(config.AnimeDefaultGenre.ToString())
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
if (config.MaxGenres > 0)
|
||||
{
|
||||
series.Genres = series.Genres.Take(max).ToArray();
|
||||
}
|
||||
|
||||
if (!series.Genres.Contains("Anime") && config.AddAnimeGenre)
|
||||
{
|
||||
series.Genres = series.Genres.Except(new[] { "Animation" }).ToArray();
|
||||
|
||||
series.AddGenre("Anime");
|
||||
series.Genres = series.Genres.Take(config.MaxGenres).ToArray();
|
||||
}
|
||||
|
||||
series.Genres = series.Genres.OrderBy(i => i).ToArray();
|
||||
@ -226,8 +225,6 @@ namespace Jellyfin.Plugin.Anime.Providers
|
||||
|
||||
public static void TidyGenres(Series series)
|
||||
{
|
||||
var config = Plugin.Instance.Configuration;
|
||||
|
||||
var genres = new HashSet<string>();
|
||||
var tags = new HashSet<string>(series.Tags);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user