-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert back to custom MusicBrainz client (#89)
- Loading branch information
Showing
22 changed files
with
270 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Jellyfin.Plugin.ListenBrainz.Common/Exceptions/NoDataException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Jellyfin.Plugin.ListenBrainz.Common.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when there's no data available. | ||
/// </summary> | ||
public class NoDataException : Exception | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NoDataException"/> class. | ||
/// </summary> | ||
public NoDataException() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NoDataException"/> class. | ||
/// </summary> | ||
/// <param name="msg">Exception message.</param> | ||
public NoDataException(string msg) : base(msg) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NoDataException"/> class. | ||
/// </summary> | ||
/// <param name="msg">Exception message.</param> | ||
/// <param name="inner">Inner exception.</param> | ||
public NoDataException(string msg, Exception inner) : base(msg, inner) | ||
{ | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Jellyfin.Plugin.ListenBrainz.Common/Exceptions/RateLimitException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Jellyfin.Plugin.ListenBrainz.Common.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when a service is rate limited. | ||
/// </summary> | ||
public class RateLimitException : Exception | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RateLimitException"/> class. | ||
/// </summary> | ||
public RateLimitException() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RateLimitException"/> class. | ||
/// </summary> | ||
/// <param name="msg">Exception message.</param> | ||
public RateLimitException(string msg) : base(msg) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RateLimitException"/> class. | ||
/// </summary> | ||
/// <param name="msg">Exception message.</param> | ||
/// <param name="inner">Inner exception.</param> | ||
public RateLimitException(string msg, Exception inner) : base(msg, inner) | ||
{ | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Jellyfin.Plugin.ListenBrainz.Common/Jellyfin.Plugin.ListenBrainz.Common.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> | ||
<AnalysisMode>AllEnabledByDefault</AnalysisMode> | ||
<CodeAnalysisRuleSet>../../code.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" /> | ||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" /> | ||
<PackageReference Include="SmartAnalyzers.ExceptionAnalyzer" Version="1.0.10" /> | ||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
23 changes: 23 additions & 0 deletions
23
src/Jellyfin.Plugin.ListenBrainz.Common/LoggerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Jellyfin.Plugin.ListenBrainz.Common; | ||
|
||
/// <summary> | ||
/// Extensions for <see cref="ILogger"/>. | ||
/// </summary> | ||
public static class LoggerExtensions | ||
{ | ||
/// <summary> | ||
/// Add a new scope for specified event ID. | ||
/// </summary> | ||
/// <param name="logger">Logger instance.</param> | ||
/// <param name="eventKey">Event key. Defaults to "EventId" if null.</param> | ||
/// <param name="eventVal">Event value. Defaults to a value from <see cref="Utils.GetNewId"/> if null.</param> | ||
/// <returns>Disposable logger scope.</returns> | ||
public static IDisposable AddNewScope(this ILogger logger, string? eventKey = null, string? eventVal = null) | ||
{ | ||
var key = eventKey ?? "EventId"; | ||
var val = eventVal ?? Utils.GetNewId(); | ||
return logger.BeginScope(new Dictionary<string, object> { { key, val } }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Jellyfin.Plugin.ListenBrainz.Common; | ||
|
||
/// <summary> | ||
/// Various functions which can be used across the project. | ||
/// </summary> | ||
public static class Utils | ||
{ | ||
/// <summary> | ||
/// Get a new ID. The ID is 7 characters long. | ||
/// </summary> | ||
/// <returns>New ID.</returns> | ||
public static string GetNewId() | ||
{ | ||
return Guid.NewGuid().ToString("N")[..7]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.