Skip to content

Commit ce100c4

Browse files
authored
Merge pull request #62 from jellyfin/graves
Expose hidden setting and add option to replace grave characters
2 parents b06233b + 7babf44 commit ce100c4

File tree

9 files changed

+81
-62
lines changed

9 files changed

+81
-62
lines changed

Jellyfin.Plugin.Anime/Configuration/PluginConfiguration.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,26 @@ public class PluginConfiguration : BasePluginConfiguration
2525
public PluginConfiguration()
2626
{
2727
TitlePreference = TitlePreferenceType.Localized;
28-
TidyGenreList = true;
2928
MaxGenres = 5;
29+
TidyGenreList = true;
3030
AddAnimeGenre = true;
31-
UseAnidbOrderingWithSeasons = false;
32-
AniDB_wait_time = 2000;
31+
AniDbRateLimit = 2000;
32+
AniDbOrderWithSeasons = false;
33+
AniDbReplaceGraves = true;
3334
}
3435

3536
public TitlePreferenceType TitlePreference { get; set; }
36-
public bool TidyGenreList { get; set; }
37+
3738
public int MaxGenres { get; set; }
39+
40+
public bool TidyGenreList { get; set; }
41+
3842
public bool AddAnimeGenre { get; set; }
39-
public bool UseAnidbOrderingWithSeasons { get; set; }
40-
public int AniDB_wait_time { get; set; }
43+
44+
public int AniDbRateLimit { get; set; }
45+
46+
public bool AniDbOrderWithSeasons { get; set; }
47+
48+
public bool AniDbReplaceGraves { get; set; }
4149
}
4250
}

Jellyfin.Plugin.Anime/Configuration/configPage.html

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,53 @@
33
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
44
<head>
55
<meta charset="utf-8" />
6-
<title>Anime Configuration</title>
6+
<title>Anime</title>
77
</head>
88
<body>
99
<div id="animeConfigurationPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox">
1010
<div data-role="content">
1111
<div class="content-primary">
12-
1312
<form id="animeConfigurationForm">
1413
<div class="selectContainer">
15-
<label class="selectLabel" for="titleLanguage">Title Language:</label>
14+
<label class="selectLabel" for="titleLanguage">Title Language</label>
1615
<select is="emby-select" id="titleLanguage" name="titleLanguage" class="emby-select-withcolor emby-select">
1716
<option id="optLanguageLocalized" value="Localized">Localized</option>
18-
<option id="optLanguageRomaji" value="JapaneseRomaji">Romaji</option>
1917
<option id="optLanguageJapanese" value="Japanese">Japanese</option>
18+
<option id="optLanguageJapaneseRomaji" value="JapaneseRomaji">Romaji</option>
2019
</select>
2120
</div>
2221
<div class="inputContainer">
23-
<label class="inputeLabel inputLabelUnfocused" for="chkMaxGenres">Max Genres:</label>
22+
<label class="inputeLabel inputLabelUnfocused" for="chkMaxGenres">Max Genres</label>
2423
<input id="chkMaxGenres" name="chkMaxGenres" type="number" is="emby-input" min="0"/>
25-
<div class="fieldDescription">[0: unlimited]</div>
24+
<div class="fieldDescription">Set this to zero to remove any limit.</div>
25+
</div>
26+
<div class="checkboxContainer checkboxContainer-withDescripton">
27+
<label class="emby-checkbox-label">
28+
<input id="chkTidyGenres" name="chkTidyGenres" type="checkbox" is="emby-checkbox"/>
29+
<span>Tidy Genre List</span>
30+
</label>
31+
</div>
32+
<div class="checkboxContainer checkboxContainer-withDescripton">
33+
<label class="emby-checkbox-label">
34+
<input id="chkAddAnimeGenre" name="chkAddAnimeGenre" type="checkbox" is="emby-checkbox"/>
35+
<span>Add Anime Genre</span>
36+
</label>
2637
</div>
2738
<div class="inputContainer">
28-
<label class="inputeLabel inputLabelUnfocused" for="chkAniDB_wait_time">AniDB wait time:</label>
29-
<input id="chkAniDB_wait_time" name="chkAniDB_wait_time" type="number" is="emby-input"/>
30-
<div class="fieldDescription">AniDB sleep time to prevent IP ban (ms)</div>
39+
<label class="inputeLabel inputLabelUnfocused" for="chkAniDbWaitTime">AniDB Rate Limit</label>
40+
<input id="chkAniDbWaitTime" name="chkAniDbWaitTime" type="number" is="emby-input"/>
41+
<div class="fieldDescription">This will prevent IP bans for requesting data too quickly.</div>
3142
</div>
3243
<div class="checkboxContainer checkboxContainer-withDescripton">
3344
<label class="emby-checkbox-label">
34-
<input id="chkAnidbSeasonOne" name="chkAnidbSeasonOne" type="checkbox" is="emby-checkbox"/>
35-
<span>Use AniDB Ordering with Seasons</span>
45+
<input id="chkAniDbOrderWithSeasons" name="chkAniDbOrderWithSeasons" type="checkbox" is="emby-checkbox"/>
46+
<span>AniDB Order with Seasons</span>
3647
</label>
3748
</div>
3849
<div class="checkboxContainer checkboxContainer-withDescripton">
3950
<label class="emby-checkbox-label">
40-
<input id="chkTidyGenres" name="chkTidyGenres" type="checkbox" is="emby-checkbox"/>
41-
<span>Tidy Genre List</span>
51+
<input id="chkAniDbReplaceGraves" name="chkAniDbReplaceGraves" type="checkbox" is="emby-checkbox"/>
52+
<span>AniDB Replace Grave Characters</span>
4253
</label>
4354
</div>
4455
<div>
@@ -51,24 +62,22 @@
5162
</div>
5263

5364
<script type="text/javascript">
54-
var AnimeConfigurationPage =
55-
{
65+
var AnimeConfigurationPage = {
5666
pluginUniqueId: "a4df60c5-6ab4-412a-8f79-2cab93fb2bc5",
5767

58-
virtualFolders: [],
59-
physicalFolders: [],
60-
6168
loadConfiguration: function() {
6269
Dashboard.showLoadingMsg();
6370

6471
ApiClient.getPluginConfiguration(AnimeConfigurationPage.pluginUniqueId).then(function (config) {
6572
var page = $.mobile.activePage;
6673

6774
$('#titleLanguage', page).val(config.TitlePreference).change();
68-
$('#chkTidyGenres', page).checked(config.TidyGenreList).checkboxradio("refresh");
6975
$('#chkMaxGenres', page).val(config.MaxGenres).change();
70-
$('#chkAnidbSeasonOne', page).checked(config.UseAnidbOrderingWithSeasons).checkboxradio("refresh");
71-
$('#chkAniDB_wait_time', page).val(config.AniDB_wait_time).change();
76+
$('#chkTidyGenres', page).checked(config.TidyGenreList).checkboxradio("refresh");
77+
$('#chkAddAnimeGenre', page).checked(config.AddAnimeGenre).checkboxradio("refresh");
78+
$('#chkAniDbWaitTime', page).val(config.AniDbWaitTime).change();
79+
$('#chkAniDbOrderWithSeasons', page).checked(config.AniDbOrderWithSeasons).checkboxradio("refresh");
80+
$('#chkAniDbReplaceGraves', page).checked(config.AniDbReplaceGraves).checkboxradio("refresh");
7281

7382
Dashboard.hideLoadingMsg();
7483
});
@@ -77,15 +86,17 @@
7786
saveConfiguration: function() {
7887
Dashboard.showLoadingMsg();
7988

80-
var page = $.mobile.activePage;
81-
8289
ApiClient.getPluginConfiguration(AnimeConfigurationPage.pluginUniqueId).then(function(config) {
90+
var page = $.mobile.activePage;
8391

8492
config.TitlePreference = $('#titleLanguage', page).val();
85-
config.TidyGenreList = $('#chkTidyGenres').prop('checked');
8693
config.MaxGenres = $('#chkMaxGenres').val();
87-
config.UseAnidbOrderingWithSeasons = $('#chkAnidbSeasonOne').prop('checked');
88-
config.AniDB_wait_time = $('#chkAniDB_wait_time').val();
94+
config.TidyGenreList = $('#chkTidyGenres').prop('checked');
95+
config.AddAnimeGenre = $('#chkAddAnimeGenre').prop('checked');
96+
config.AniDbWaitTime = $('#chkAniDbWaitTime').val();
97+
config.AniDbOrderWithSeasons = $('#chkAniDbOrderWithSeasons').prop('checked');
98+
config.AniDbReplaceGraves = $('#chkAniDbReplaceGraves').prop('checked');
99+
89100
ApiClient.updatePluginConfiguration(AnimeConfigurationPage.pluginUniqueId, config).then(function (result) {
90101
Dashboard.processPluginConfigurationUpdateResult(result);
91102
});

Jellyfin.Plugin.Anime/Jellyfin.Plugin.Anime.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.1</TargetFramework>
55
<RootNamespace>Jellyfin.Plugin.Anime</RootNamespace>
6-
<AssemblyVersion>7.0.0</AssemblyVersion>
7-
<FileVersion>7.0.0</FileVersion>
6+
<AssemblyVersion>8.0.0</AssemblyVersion>
7+
<FileVersion>8.0.0</FileVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>

Jellyfin.Plugin.Anime/Providers/AniDB/Identity/AniDbTitleDownloader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static async Task DownloadTitles_static(string titlesFile)
9494
client.Headers.Add("User-Agent", Constants.UserAgent);
9595

9696
await AniDbSeriesProvider.RequestLimiter.Tick().ConfigureAwait(false);
97-
await Task.Delay(Plugin.Instance.Configuration.AniDB_wait_time).ConfigureAwait(false);
97+
await Task.Delay(Plugin.Instance.Configuration.AniDbRateLimit).ConfigureAwait(false);
9898
using (var stream = await client.OpenReadTaskAsync(TitlesUrl))
9999
using (var unzipped = new GZipStream(stream, CompressionMode.Decompress))
100100
using (var writer = File.Open(titlesFile, FileMode.Create, FileAccess.Write))

Jellyfin.Plugin.Anime/Providers/AniDB/Metadata/AniDbEpisodeProvider.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@ public AniDbEpisodeProvider(IServerConfigurationManager configurationManager, IH
3535

3636
public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo info, CancellationToken cancellationToken)
3737
{
38-
var result = new MetadataResult<Episode>();
39-
4038
cancellationToken.ThrowIfCancellationRequested();
39+
var result = new MetadataResult<Episode>();
4140

42-
var anidbId = info.ProviderIds.GetOrDefault(ProviderNames.AniDb);
43-
if (string.IsNullOrEmpty(anidbId))
41+
var aniDbId = info.ProviderIds.GetOrDefault(ProviderNames.AniDb);
42+
if (string.IsNullOrEmpty(aniDbId))
4443
{
4544
return result;
4645
}
4746

48-
var id = AniDbEpisodeIdentity.Parse(anidbId);
47+
var id = AniDbEpisodeIdentity.Parse(aniDbId);
4948
if (id == null)
5049
{
5150
return result;
@@ -97,17 +96,6 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(EpisodeInfo
9796
var list = new List<RemoteSearchResult>();
9897

9998
var id = AniDbEpisodeIdentity.Parse(searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb));
100-
if (id == null)
101-
{
102-
//var episodeIdentifier = new AnidbEpisodeIdentityProvider();
103-
//await episodeIdentifier.Identify(searchInfo);
104-
105-
//var converter = new AnidbTvdbEpisodeConverter();
106-
//await converter.Convert(searchInfo);
107-
108-
//id = AnidbEpisodeIdentity.Parse(searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb));
109-
}
110-
11199
if (id == null)
112100
{
113101
return list;
@@ -213,7 +201,10 @@ private async Task ParseAdditionalEpisodeXml(FileInfo xml, Episode episode, stri
213201
var title = titles.Localize(Plugin.Instance.Configuration.TitlePreference, metadataLanguage).Name;
214202
if (!string.IsNullOrEmpty(title))
215203
{
216-
episode.Name += ", " + title;
204+
title = ", " + title;
205+
episode.Name += Plugin.Instance.Configuration.AniDbReplaceGraves
206+
? title.Replace('`', '\'')
207+
: title;
217208
}
218209
}
219210
}
@@ -303,7 +294,9 @@ private async Task ParseEpisodeXml(FileInfo xml, Episode episode, string preferr
303294
var title = titles.Localize(Plugin.Instance.Configuration.TitlePreference, preferredMetadataLanguage).Name;
304295
if (!string.IsNullOrEmpty(title))
305296
{
306-
episode.Name = title;
297+
episode.Name = Plugin.Instance.Configuration.AniDbReplaceGraves
298+
? title.Replace('`', '\'')
299+
: title;
307300
}
308301
}
309302
}

Jellyfin.Plugin.Anime/Providers/AniDB/Metadata/AniDbMovieProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo se
7474
{
7575
var seriesInfo = new SeriesInfo();
7676
var seriesId = searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb);
77+
7778
if (seriesId != null)
7879
{
7980
seriesInfo.ProviderIds.Add(ProviderNames.AniDb, seriesId);
8081
}
82+
8183
seriesInfo.Name = searchInfo.Name;
8284

8385
return await _seriesProvider.GetSearchResults(seriesInfo, cancellationToken);

Jellyfin.Plugin.Anime/Providers/AniDB/Metadata/AniDbPersonInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
public class AniDbPersonInfo
44
{
55
public string Name { get; set; }
6+
67
public string Id { get; set; }
8+
79
public string Image { get; set; }
810
}
911
}

Jellyfin.Plugin.Anime/Providers/AniDB/Metadata/AniDbSeriesProvider.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AniDbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>,
3636
private readonly IApplicationPaths _appPaths;
3737
private readonly IHttpClient _httpClient;
3838

39-
private readonly Dictionary<string, string> _typeMappings = new Dictionary<string, string>()
39+
private readonly Dictionary<string, string> _typeMappings = new Dictionary<string, string>
4040
{
4141
{"Direction", PersonType.Director},
4242
{"Music", PersonType.Composer},
@@ -130,7 +130,7 @@ public static async Task<string> GetSeriesData(IApplicationPaths appPaths, IHttp
130130
var seriesDataPath = Path.Combine(dataPath, SeriesDataFile);
131131
var fileInfo = new FileInfo(seriesDataPath);
132132

133-
// download series data if not present, or out of date
133+
// download series data if not present or out of date
134134
if (!fileInfo.Exists || DateTime.UtcNow - fileInfo.LastWriteTimeUtc > TimeSpan.FromDays(7))
135135
{
136136
await DownloadSeriesData(seriesId, seriesDataPath, appPaths.CachePath, httpClient, cancellationToken).ConfigureAwait(false);
@@ -201,7 +201,9 @@ private async Task FetchSeriesInfo(MetadataResult<Series> result, string seriesD
201201
var title = await ParseTitle(subtree, preferredMetadataLangauge).ConfigureAwait(false);
202202
if (!string.IsNullOrEmpty(title))
203203
{
204-
series.Name = title;
204+
series.Name = Plugin.Instance.Configuration.AniDbReplaceGraves
205+
? title.Replace('`', '\'')
206+
: title;
205207
}
206208
}
207209

@@ -529,7 +531,8 @@ private static async Task DownloadSeriesData(string aid, string seriesDataPath,
529531
};
530532

531533
await RequestLimiter.Tick().ConfigureAwait(false);
532-
await Task.Delay(Plugin.Instance.Configuration.AniDB_wait_time).ConfigureAwait(false);
534+
await Task.Delay(Plugin.Instance.Configuration.AniDbRateLimit).ConfigureAwait(false);
535+
533536
using (var stream = await httpClient.Get(requestOptions).ConfigureAwait(false))
534537
using (var unzipped = new GZipStream(stream, CompressionMode.Decompress))
535538
using (var reader = new StreamReader(unzipped, Encoding.UTF8, true))
@@ -828,7 +831,7 @@ private static async Task<string> ParseEpisodeNumber(string xml)
828831
}
829832

830833
/// <summary>
831-
/// Gets the series data path.
834+
/// Gets the series data path.
832835
/// </summary>
833836
/// <param name="appPaths">The app paths.</param>
834837
/// <param name="seriesId">The series id.</param>
@@ -841,7 +844,7 @@ internal static string GetSeriesDataPath(IApplicationPaths appPaths, string seri
841844
}
842845

843846
/// <summary>
844-
/// Gets the series data path.
847+
/// Gets the series data path.
845848
/// </summary>
846849
/// <param name="appPaths">The app paths.</param>
847850
/// <returns>System.String.</returns>
@@ -905,7 +908,7 @@ public static Title Localize(this IEnumerable<Title> titles, TitlePreferenceType
905908
}
906909

907910
/// <summary>
908-
/// Gets the series data path.
911+
/// Gets the series data path.
909912
/// </summary>
910913
/// <param name="appPaths">The app paths.</param>
911914
/// <param name="seriesId">The series id.</param>
@@ -918,7 +921,7 @@ internal static string GetSeriesDataPath(IApplicationPaths appPaths, string seri
918921
}
919922

920923
/// <summary>
921-
/// Gets the series data path.
924+
/// Gets the series data path.
922925
/// </summary>
923926
/// <param name="appPaths">The app paths.</param>
924927
/// <returns>System.String.</returns>

build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: "jellyfin-plugin-anime"
33
guid: "a4df60c5-6ab4-412a-8f79-2cab93fb2bc5"
4-
version: "7"
4+
version: "8"
55
jellyfin_version: "10.5.0"
66
owner: "jellyfin"
77
nicename: "Anime"

0 commit comments

Comments
 (0)