Skip to content

Commit

Permalink
Simplify imports and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
jwueller committed Jan 5, 2024
1 parent 051f03b commit ae13b7d
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 27 deletions.
10 changes: 8 additions & 2 deletions JWueller.Jellyfin.OnePace.Tests/ProviderIdsExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public void ShouldExtractOnePaceId(string providerId)
{
var itemLookupInfo = new ItemLookupInfo
{
ProviderIds = { [Plugin.ProviderName] = providerId }
ProviderIds =
{
[Plugin.ProviderName] = providerId
}
};

Assert.Equal(providerId, itemLookupInfo.GetOnePaceId());
Expand All @@ -35,7 +38,10 @@ public void ShouldDiscardLegacyOnePaceId(string providerId)
{
var itemLookupInfo = new ItemLookupInfo
{
ProviderIds = { [Plugin.ProviderName] = providerId }
ProviderIds =
{
[Plugin.ProviderName] = providerId
}
};

Assert.Null(itemLookupInfo.GetOnePaceId());
Expand Down
16 changes: 7 additions & 9 deletions JWueller.Jellyfin.OnePace/ArcIdentifier.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
Expand All @@ -11,7 +11,7 @@ namespace JWueller.Jellyfin.OnePace;

internal static class ArcIdentifier
{
public static async Task<Model.IArc?> IdentifyAsync(
public static async Task<IArc?> IdentifyAsync(
IRepository repository,
ItemLookupInfo itemLookupInfo,
CancellationToken cancellationToken)
Expand Down Expand Up @@ -40,7 +40,8 @@ internal static class ArcIdentifier
// match against chapter ranges
foreach (var arc in arcs.OrderByDescending(arc => arc.MangaChapters?.Length ?? 0))
{
if (!string.IsNullOrEmpty(arc.MangaChapters) && IdentifierUtil.BuildTextRegex(arc.MangaChapters).IsMatch(directoryName))
if (!string.IsNullOrEmpty(arc.MangaChapters) &&
IdentifierUtil.BuildTextRegex(arc.MangaChapters).IsMatch(directoryName))
{
return arc;
}
Expand All @@ -49,7 +50,8 @@ internal static class ArcIdentifier
// match against invariant titles
foreach (var arc in arcs.OrderByDescending(arc => arc.InvariantTitle.Length))
{
if (!string.IsNullOrEmpty(arc.InvariantTitle) && IdentifierUtil.BuildTextRegex(arc.InvariantTitle).IsMatch(directoryName))
if (!string.IsNullOrEmpty(arc.InvariantTitle) &&
IdentifierUtil.BuildTextRegex(arc.InvariantTitle).IsMatch(directoryName))
{
return arc;
}
Expand All @@ -58,11 +60,7 @@ internal static class ArcIdentifier
// match against arc ranks
foreach (var arc in arcs)
{
var pattern =
@"\b0*" +
Regex.Escape(arc.Rank.ToString(System.Globalization.CultureInfo.InvariantCulture)) +
@"\b";

var pattern = @"\b0*" + Regex.Escape(arc.Rank.ToString(CultureInfo.InvariantCulture)) + @"\b";
if (Regex.IsMatch(directoryName, pattern, RegexOptions.IgnoreCase))
{
return arc;
Expand Down
5 changes: 3 additions & 2 deletions JWueller.Jellyfin.OnePace/ArcImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
Expand Down Expand Up @@ -81,8 +82,8 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
_log.LogInformation(
"Found {Count} arc image(s) for {Item} --> {Result}",
result.Count,
System.Text.Json.JsonSerializer.Serialize(item),
System.Text.Json.JsonSerializer.Serialize(result));
JsonSerializer.Serialize(item),
JsonSerializer.Serialize(result));

return result;
}
Expand Down
5 changes: 3 additions & 2 deletions JWueller.Jellyfin.OnePace/ArcProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
Expand Down Expand Up @@ -73,8 +74,8 @@ public async Task<MetadataResult<Season>> GetMetadata(SeasonInfo info, Cancellat

_log.LogInformation(
"Identified Arc {Info} --> {Match}",
System.Text.Json.JsonSerializer.Serialize(info),
System.Text.Json.JsonSerializer.Serialize(arcMatch));
JsonSerializer.Serialize(info),
JsonSerializer.Serialize(arcMatch));

return result;
}
Expand Down
6 changes: 4 additions & 2 deletions JWueller.Jellyfin.OnePace/EpisodeIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ internal static class EpisodeIdentifier
// match against chapter ranges
foreach (var episode in episodes.OrderByDescending(episode => episode.MangaChapters?.Length ?? 0))
{
if (!string.IsNullOrEmpty(episode.MangaChapters) && IdentifierUtil.BuildTextRegex(episode.MangaChapters).IsMatch(fileName))
if (!string.IsNullOrEmpty(episode.MangaChapters) &&
IdentifierUtil.BuildTextRegex(episode.MangaChapters).IsMatch(fileName))
{
return episode;
}
Expand All @@ -62,7 +63,8 @@ internal static class EpisodeIdentifier
// match against invariant titles
foreach (var episode in episodes.OrderByDescending(episode => episode.InvariantTitle.Length))
{
if (!string.IsNullOrEmpty(episode.InvariantTitle) && IdentifierUtil.BuildTextRegex(episode.InvariantTitle).IsMatch(fileName))
if (!string.IsNullOrEmpty(episode.InvariantTitle) &&
IdentifierUtil.BuildTextRegex(episode.InvariantTitle).IsMatch(fileName))
{
return episode;
}
Expand Down
5 changes: 3 additions & 2 deletions JWueller.Jellyfin.OnePace/EpisodeImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
Expand Down Expand Up @@ -81,8 +82,8 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
_log.LogInformation(
"Found {Count} episode image(s) for {Item} --> {Result}",
result.Count,
System.Text.Json.JsonSerializer.Serialize(item),
System.Text.Json.JsonSerializer.Serialize(result));
JsonSerializer.Serialize(item),
JsonSerializer.Serialize(result));

return result;
}
Expand Down
3 changes: 2 additions & 1 deletion JWueller.Jellyfin.OnePace/EpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo info, Cancell
{
var result = new MetadataResult<Episode>();

var episodeMatch = await EpisodeIdentifier.IdentifyAsync(_repository, info, cancellationToken).ConfigureAwait(false);
var episodeMatch = await EpisodeIdentifier.IdentifyAsync(_repository, info, cancellationToken)
.ConfigureAwait(false);
if (episodeMatch != null)
{
var arc = await _repository.FindArcByIdAsync(episodeMatch.ArcId, cancellationToken).ConfigureAwait(false);
Expand Down
4 changes: 3 additions & 1 deletion JWueller.Jellyfin.OnePace/Model/IArc.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace JWueller.Jellyfin.OnePace.Model;

/// <summary>
Expand Down Expand Up @@ -28,5 +30,5 @@ public interface IArc
/// <summary>
/// Gets the release date of the arc. Null if release date is unknown or the arc is unreleased.
/// </summary>
System.DateTime? ReleaseDate { get; }
DateTime? ReleaseDate { get; }
}
3 changes: 2 additions & 1 deletion JWueller.Jellyfin.OnePace/SeriesIdentifier.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Threading;
using System.Threading.Tasks;
using JWueller.Jellyfin.OnePace.Model;
using MediaBrowser.Controller.Providers;

namespace JWueller.Jellyfin.OnePace;

internal static class SeriesIdentifier
{
public static async Task<Model.ISeries?> IdentifyAsync(
public static async Task<ISeries?> IdentifyAsync(
IRepository repository,
ItemLookupInfo itemLookupInfo,
CancellationToken cancellationToken)
Expand Down
5 changes: 3 additions & 2 deletions JWueller.Jellyfin.OnePace/SeriesImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
Expand Down Expand Up @@ -87,8 +88,8 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
_log.LogInformation(
"Found {Count} series image(s) for {Item} --> {Result}",
result.Count,
System.Text.Json.JsonSerializer.Serialize(item),
System.Text.Json.JsonSerializer.Serialize(result));
JsonSerializer.Serialize(item),
JsonSerializer.Serialize(result));

return result;
}
Expand Down
8 changes: 5 additions & 3 deletions JWueller.Jellyfin.OnePace/SeriesProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
Expand Down Expand Up @@ -46,7 +47,8 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
{
var result = new MetadataResult<Series>();

var seriesMatch = await SeriesIdentifier.IdentifyAsync(_repository, info, cancellationToken).ConfigureAwait(false);
var seriesMatch = await SeriesIdentifier.IdentifyAsync(_repository, info, cancellationToken)
.ConfigureAwait(false);
if (seriesMatch != null)
{
result.HasMetadata = true;
Expand Down Expand Up @@ -74,8 +76,8 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat

_log.LogInformation(
"Identified Series {Info} --> {Match}",
System.Text.Json.JsonSerializer.Serialize(info),
System.Text.Json.JsonSerializer.Serialize(seriesMatch));
JsonSerializer.Serialize(info),
JsonSerializer.Serialize(seriesMatch));

return result;
}
Expand Down

0 comments on commit ae13b7d

Please sign in to comment.