mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 13:44:33 -04:00
Stylcop: Adding a stylecop analyser and trying to configure it
This commit is contained in:
parent
38472a7431
commit
8ff2fe3965
17
Directory.Build.props
Normal file
17
Directory.Build.props
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
|
||||||
|
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
|
||||||
|
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" />
|
||||||
|
<None Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" Visible="false" />
|
||||||
|
<None Include="$(MSBuildThisFileDirectory).editorconfig" Link="stylecop.json" Visible="false" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Kyoo.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -16,9 +16,9 @@
|
|||||||
void Restart();
|
void Restart();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the data directory
|
/// Get the data directory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Retrieve the data directory where runtime data should be stored</returns>
|
/// <returns>Retrieve the data directory where runtime data should be stored.</returns>
|
||||||
string GetDataDirectory();
|
string GetDataDirectory();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -28,4 +28,4 @@
|
|||||||
/// <returns>The configuration file name.</returns>
|
/// <returns>The configuration file name.</returns>
|
||||||
string GetConfigFile();
|
string GetConfigFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,12 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
public interface IConfigurationManager
|
public interface IConfigurationManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an editable configuration to the editable configuration list
|
/// Add an editable configuration to the editable configuration list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The root path of the editable configuration. It should not be a nested type.</param>
|
/// <param name="path">The root path of the editable configuration. It should not be a nested type.</param>
|
||||||
/// <typeparam name="T">The type of the configuration</typeparam>
|
/// <typeparam name="T">The type of the configuration.</typeparam>
|
||||||
void AddTyped<T>(string path);
|
void AddTyped<T>(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an editable configuration to the editable configuration list.
|
/// Add an editable configuration to the editable configuration list.
|
||||||
/// WARNING: this method allow you to add an unmanaged type. This type won't be editable. This can be used
|
/// WARNING: this method allow you to add an unmanaged type. This type won't be editable. This can be used
|
||||||
@ -36,32 +36,33 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <param name="path">The root path of the editable configuration. It should not be a nested type.</param>
|
/// <param name="path">The root path of the editable configuration. It should not be a nested type.</param>
|
||||||
/// <param name="type">The type of the configuration or null.</param>
|
/// <param name="type">The type of the configuration or null.</param>
|
||||||
void Register(string path, [CanBeNull] Type type);
|
void Register(string path, [CanBeNull] Type type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the value of a setting using it's path.
|
/// Get the value of a setting using it's path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path of the resource (can be separated by ':' or '__')</param>
|
/// <param name="path">The path of the resource (can be separated by ':' or '__').</param>
|
||||||
/// <exception cref="ItemNotFoundException">No setting found at the given path.</exception>
|
/// <exception cref="ItemNotFoundException">No setting found at the given path.</exception>
|
||||||
/// <returns>The value of the settings (if it's a strongly typed one, the given type is instantiated</returns>
|
/// <returns>The value of the settings (if it's a strongly typed one, the given type is instantiated.</returns>
|
||||||
object GetValue(string path);
|
object GetValue(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the value of a setting using it's path.
|
/// Get the value of a setting using it's path.
|
||||||
/// If your don't need a strongly typed value, see <see cref="GetValue"/>.
|
/// If your don't need a strongly typed value, see <see cref="GetValue"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path of the resource (can be separated by ':' or '__')</param>
|
/// <param name="path">The path of the resource (can be separated by ':' or '__').</param>
|
||||||
/// <typeparam name="T">A type to strongly type your option.</typeparam>
|
/// <typeparam name="T">A type to strongly type your option.</typeparam>
|
||||||
/// <exception cref="InvalidCastException">If your type is not the same as the registered type</exception>
|
/// <exception cref="InvalidCastException">If your type is not the same as the registered type.</exception>
|
||||||
/// <exception cref="ItemNotFoundException">No setting found at the given path.</exception>
|
/// <exception cref="ItemNotFoundException">No setting found at the given path.</exception>
|
||||||
/// <returns>The value of the settings (if it's a strongly typed one, the given type is instantiated</returns>
|
/// <returns>The value of the settings (if it's a strongly typed one, the given type is instantiated.</returns>
|
||||||
T GetValue<T>(string path);
|
T GetValue<T>(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Edit the value of a setting using it's path. Save it to the json file.
|
/// Edit the value of a setting using it's path. Save it to the json file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path of the resource (can be separated by ':' or '__')</param>
|
/// <param name="path">The path of the resource (can be separated by ':' or '__').</param>
|
||||||
/// <param name="value">The new value of the resource</param>
|
/// <param name="value">The new value of the resource.</param>
|
||||||
/// <exception cref="ItemNotFoundException">No setting found at the given path.</exception>
|
/// <exception cref="ItemNotFoundException">No setting found at the given path.</exception>
|
||||||
|
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||||
Task EditValue(string path, object value);
|
Task EditValue(string path, object value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
namespace Kyoo.Abstractions.Controllers
|
namespace Kyoo.Abstractions.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A service to abstract the file system to allow custom file systems (like distant file systems or external providers)
|
/// A service to abstract the file system to allow custom file systems
|
||||||
|
/// (like distant file systems or external providers).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IFileSystem
|
public interface IFileSystem
|
||||||
{
|
{
|
||||||
@ -16,10 +17,10 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for http queries returning a file. This should be used to return local files
|
/// Used for http queries returning a file. This should be used to return local files
|
||||||
/// or proxy them from a distant server
|
/// or proxy them from a distant server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If no file exists at the given path or if the path is null, a NotFoundResult is returned
|
/// If no file exists at the given path or if the path is null, a NotFoundResult is returned
|
||||||
/// to handle it gracefully.
|
/// to handle it gracefully.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="path">The path of the file.</param>
|
/// <param name="path">The path of the file.</param>
|
||||||
@ -42,7 +43,7 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <exception cref="FileNotFoundException">If the file could not be found.</exception>
|
/// <exception cref="FileNotFoundException">If the file could not be found.</exception>
|
||||||
/// <returns>A reader to read the file.</returns>
|
/// <returns>A reader to read the file.</returns>
|
||||||
public Task<Stream> GetReader([NotNull] string path);
|
public Task<Stream> GetReader([NotNull] string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a file present at <paramref name="path"/>. The reader can be used in an arbitrary context.
|
/// Read a file present at <paramref name="path"/>. The reader can be used in an arbitrary context.
|
||||||
/// To return files from an http endpoint, use <see cref="FileResult"/>.
|
/// To return files from an http endpoint, use <see cref="FileResult"/>.
|
||||||
@ -80,7 +81,7 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <param name="path">The path of the directory</param>
|
/// <param name="path">The path of the directory</param>
|
||||||
/// <param name="options">Should the search be recursive or not.</param>
|
/// <param name="options">Should the search be recursive or not.</param>
|
||||||
/// <returns>A list of files's path.</returns>
|
/// <returns>A list of files's path.</returns>
|
||||||
public Task<ICollection<string>> ListFiles([NotNull] string path,
|
public Task<ICollection<string>> ListFiles([NotNull] string path,
|
||||||
SearchOption options = SearchOption.TopDirectoryOnly);
|
SearchOption options = SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,4 +101,4 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// <returns>The extra directory of the resource.</returns>
|
/// <returns>The extra directory of the resource.</returns>
|
||||||
public Task<string> GetExtraDirectory<T>([NotNull] T resource);
|
public Task<string> GetExtraDirectory<T>([NotNull] T resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// If no metadata could be parsed for a type, null can be returned.
|
/// If no metadata could be parsed for a type, null can be returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<(Collection, Show, Season, Episode)> Identify(string path);
|
Task<(Collection, Show, Season, Episode)> Identify(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identify an external subtitle or track file from it's path and return the parsed metadata.
|
/// Identify an external subtitle or track file from it's path and return the parsed metadata.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -34,4 +34,4 @@ namespace Kyoo.Abstractions.Controllers
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
Task<Track> IdentifyTrack(string path);
|
Task<Track> IdentifyTrack(string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using Kyoo.Abstractions.Models;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Kyoo.Abstractions.Models;
|
||||||
|
|
||||||
namespace Kyoo.Abstractions.Controllers
|
namespace Kyoo.Abstractions.Controllers
|
||||||
{
|
{
|
||||||
|
@ -15,18 +15,18 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IdentificationFailedException()
|
public IdentificationFailedException()
|
||||||
: base("An identification failed.")
|
: base("An identification failed.")
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="IdentificationFailedException"/> with a custom message.
|
/// Create a new <see cref="IdentificationFailedException"/> with a custom message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">The message to use.</param>
|
/// <param name="message">The message to use.</param>
|
||||||
public IdentificationFailedException(string message)
|
public IdentificationFailedException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{}
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The serialization constructor
|
/// The serialization constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">Serialization infos</param>
|
/// <param name="info">Serialization infos</param>
|
||||||
/// <param name="context">The serialization context</param>
|
/// <param name="context">The serialization context</param>
|
||||||
@ -34,4 +34,4 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
: base(info, context)
|
: base(info, context)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a default <see cref="ItemNotFoundException"/> with no message.
|
/// Create a default <see cref="ItemNotFoundException"/> with no message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ItemNotFoundException() {}
|
public ItemNotFoundException() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="ItemNotFoundException"/> with a message
|
/// Create a new <see cref="ItemNotFoundException"/> with a message
|
||||||
@ -21,9 +21,9 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
public ItemNotFoundException(string message)
|
public ItemNotFoundException(string message)
|
||||||
: base(message)
|
: base(message)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The serialization constructor
|
/// The serialization constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">Serialization infos</param>
|
/// <param name="info">Serialization infos</param>
|
||||||
/// <param name="context">The serialization context</param>
|
/// <param name="context">The serialization context</param>
|
||||||
@ -31,4 +31,4 @@ namespace Kyoo.Abstractions.Models.Exceptions
|
|||||||
: base(info, context)
|
: base(info, context)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,6 @@
|
|||||||
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
|
||||||
<LangVersion>default</LangVersion>
|
<LangVersion>default</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
|
|
||||||
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
|
|
||||||
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TranscoderBinary Condition="$(IsWindows) == true">transcoder.dll</TranscoderBinary>
|
<TranscoderBinary Condition="$(IsWindows) == true">transcoder.dll</TranscoderBinary>
|
||||||
@ -58,14 +52,14 @@
|
|||||||
</Exec>
|
</Exec>
|
||||||
<Error Condition="'$(ErrorCode)' != '0'" Text="An environement capable of building the transcoder was not found. Appropriate tools are not installed, not available in the $PATH or not correctly configured. To fix this you can ether:
 - Fix your tools
 - Skip the transcoder via the '-p:SkipTranscoder=true'
 - Download an already built transcoder and put it in ./Kyoo.Transcoder/build" />
|
<Error Condition="'$(ErrorCode)' != '0'" Text="An environement capable of building the transcoder was not found. Appropriate tools are not installed, not available in the $PATH or not correctly configured. To fix this you can ether:
 - Fix your tools
 - Skip the transcoder via the '-p:SkipTranscoder=true'
 - Download an already built transcoder and put it in ./Kyoo.Transcoder/build" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(SkipTranscoder)' != 'true'">
|
<ItemGroup Condition="'$(SkipTranscoder)' != 'true'">
|
||||||
<None Include="$(TranscoderRoot)/build/$(TranscoderBinary)">
|
<None Include="$(TranscoderRoot)/build/$(TranscoderBinary)">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
<Visible>false</Visible>
|
<Visible>false</Visible>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="../LICENSE" CopyToOutputDirectory="Always" Visible="false" />
|
<Content Include="../LICENSE" CopyToOutputDirectory="Always" Visible="false" />
|
||||||
<Content Include="settings.json" CopyToOutputDirectory="PreserveNewest" />
|
<Content Include="settings.json" CopyToOutputDirectory="PreserveNewest" />
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
using Kyoo.Abstractions.Models.Permissions;
|
using Kyoo.Abstractions.Models.Permissions;
|
||||||
using Kyoo.Core.Models.Options;
|
using Kyoo.Core.Models.Options;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Kyoo.Core.Api
|
namespace Kyoo.Core.Api
|
||||||
@ -33,11 +33,11 @@ namespace Kyoo.Core.Api
|
|||||||
ActionResult<Library> result = await base.Create(resource);
|
ActionResult<Library> result = await base.Create(resource);
|
||||||
if (result.Value != null)
|
if (result.Value != null)
|
||||||
_taskManager.StartTask("scan",
|
_taskManager.StartTask("scan",
|
||||||
new Progress<float>(),
|
new Progress<float>(),
|
||||||
new Dictionary<string, object> {{"slug", result.Value.Slug}});
|
new Dictionary<string, object> {{"slug", result.Value.Slug}});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id:int}/show")]
|
[HttpGet("{id:int}/show")]
|
||||||
[HttpGet("{id:int}/shows")]
|
[HttpGet("{id:int}/shows")]
|
||||||
[PartialPermission(Kind.Read)]
|
[PartialPermission(Kind.Read)]
|
||||||
@ -89,7 +89,7 @@ namespace Kyoo.Core.Api
|
|||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new {Error = ex.Message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id:int}/collection")]
|
[HttpGet("{id:int}/collection")]
|
||||||
[HttpGet("{id:int}/collections")]
|
[HttpGet("{id:int}/collections")]
|
||||||
[PartialPermission(Kind.Read)]
|
[PartialPermission(Kind.Read)]
|
||||||
@ -141,7 +141,7 @@ namespace Kyoo.Core.Api
|
|||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new {Error = ex.Message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id:int}/item")]
|
[HttpGet("{id:int}/item")]
|
||||||
[HttpGet("{id:int}/items")]
|
[HttpGet("{id:int}/items")]
|
||||||
[PartialPermission(Kind.Read)]
|
[PartialPermission(Kind.Read)]
|
||||||
@ -167,7 +167,7 @@ namespace Kyoo.Core.Api
|
|||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new {Error = ex.Message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{slug}/item")]
|
[HttpGet("{slug}/item")]
|
||||||
[HttpGet("{slug}/items")]
|
[HttpGet("{slug}/items")]
|
||||||
[PartialPermission(Kind.Read)]
|
[PartialPermission(Kind.Read)]
|
||||||
@ -194,4 +194,4 @@ namespace Kyoo.Core.Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
|
||||||
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="Kyoo.Host.WindowsTrait.target" Condition="$(IsWindows) == true" />
|
<Import Project="Kyoo.Host.WindowsTrait.target" Condition="$(IsWindows) == true" />
|
||||||
<Import Project="Kyoo.Host.WindowsTrait.linux.target" Condition="$(IsWindows) != true" />
|
<Import Project="Kyoo.Host.WindowsTrait.linux.target" Condition="$(IsWindows) != true" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="*.target" />
|
<None Remove="*.target" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@ using TMDbLib.Objects.General;
|
|||||||
using TMDbLib.Objects.People;
|
using TMDbLib.Objects.People;
|
||||||
using TMDbLib.Objects.Search;
|
using TMDbLib.Objects.Search;
|
||||||
using Images = Kyoo.Abstractions.Models.Images;
|
using Images = Kyoo.Abstractions.Models.Images;
|
||||||
using TvCast = TMDbLib.Objects.TvShows.Cast;
|
|
||||||
using MovieCast = TMDbLib.Objects.Movies.Cast;
|
using MovieCast = TMDbLib.Objects.Movies.Cast;
|
||||||
|
using TvCast = TMDbLib.Objects.TvShows.Cast;
|
||||||
|
|
||||||
namespace Kyoo.TheMovieDb
|
namespace Kyoo.TheMovieDb
|
||||||
{
|
{
|
||||||
@ -31,8 +31,8 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = cast.Name,
|
Name = cast.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = cast.ProfilePath != null
|
[Images.Poster] = cast.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -49,7 +49,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Role = cast.Character
|
Role = cast.Character
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a <see cref="TvCast"/> to a <see cref="PeopleRole"/>.
|
/// Convert a <see cref="TvCast"/> to a <see cref="PeopleRole"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,8 +66,8 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = cast.Name,
|
Name = cast.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = cast.ProfilePath != null
|
[Images.Poster] = cast.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -84,7 +84,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Role = cast.Character
|
Role = cast.Character
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a <see cref="Crew"/> to a <see cref="PeopleRole"/>.
|
/// Convert a <see cref="Crew"/> to a <see cref="PeopleRole"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -101,8 +101,8 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = crew.Name,
|
Name = crew.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = crew.ProfilePath != null
|
[Images.Poster] = crew.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{crew.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{crew.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -119,7 +119,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Role = crew.Job
|
Role = crew.Job
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a <see cref="Person"/> to a <see cref="People"/>.
|
/// Convert a <see cref="Person"/> to a <see cref="People"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -134,8 +134,8 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = person.Name,
|
Name = person.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = person.ProfilePath != null
|
[Images.Poster] = person.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -149,7 +149,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a <see cref="SearchPerson"/> to a <see cref="People"/>.
|
/// Convert a <see cref="SearchPerson"/> to a <see cref="People"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -164,8 +164,8 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = person.Name,
|
Name = person.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = person.ProfilePath != null
|
[Images.Poster] = person.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -180,4 +180,4 @@ namespace Kyoo.TheMovieDb
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
.Select(x => x.ToPeople(provider))
|
.Select(x => x.ToPeople(provider))
|
||||||
.Concat(tv.Credits.Crew.Select(x => x.ToPeople(provider)))
|
.Concat(tv.Credits.Crew.Select(x => x.ToPeople(provider)))
|
||||||
.ToArray(),
|
.ToArray(),
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a <see cref="SearchTv"/> to a <see cref="Show"/>.
|
/// Convert a <see cref="SearchTv"/> to a <see cref="Show"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -75,7 +75,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Title = tv.Name,
|
Title = tv.Name,
|
||||||
Overview = tv.Overview,
|
Overview = tv.Overview,
|
||||||
StartAir = tv.FirstAirDate,
|
StartAir = tv.FirstAirDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = tv.PosterPath != null
|
[Images.Poster] = tv.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{tv.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{tv.PosterPath}"
|
||||||
@ -84,7 +84,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
? $"https://image.tmdb.org/t/p/original{tv.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{tv.BackdropPath}"
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
@ -96,4 +96,4 @@ namespace Kyoo.TheMovieDb
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
{
|
{
|
||||||
Slug = Utility.ToSlug(company.Name),
|
Slug = Utility.ToSlug(company.Name),
|
||||||
Name = company.Name,
|
Name = company.Name,
|
||||||
ExternalIDs = new []
|
ExternalIDs = new[]
|
||||||
{
|
{
|
||||||
new MetadataID
|
new MetadataID
|
||||||
{
|
{
|
||||||
@ -58,4 +58,4 @@ namespace Kyoo.TheMovieDb
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,24 +14,6 @@ namespace Kyoo.TheMovieDb
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginTmdb : IPlugin
|
public class PluginTmdb : IPlugin
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
|
||||||
public string Slug => "the-moviedb";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string Name => "TheMovieDb";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string Description => "A metadata provider for TheMovieDB.";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public bool Enabled => !string.IsNullOrEmpty(_configuration.GetValue<string>("the-moviedb:apikey"));
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Dictionary<string, Type> Configuration => new()
|
|
||||||
{
|
|
||||||
{ TheMovieDbOptions.Path, typeof(TheMovieDbOptions) }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The configuration used to check if the api key is present or not.
|
/// The configuration used to check if the api key is present or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -46,14 +28,34 @@ namespace Kyoo.TheMovieDb
|
|||||||
{
|
{
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
|
{
|
||||||
logger.LogWarning("No API key configured for TheMovieDB provider. " +
|
logger.LogWarning("No API key configured for TheMovieDB provider. " +
|
||||||
"To enable TheMovieDB, specify one in the setting the-moviedb:APIKEY ");
|
"To enable TheMovieDB, specify one in the setting the-moviedb:APIKEY ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Slug => "the-moviedb";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Name => "TheMovieDb";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Description => "A metadata provider for TheMovieDB.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool Enabled => !string.IsNullOrEmpty(_configuration.GetValue<string>("the-moviedb:apikey"));
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Dictionary<string, Type> Configuration => new()
|
||||||
|
{
|
||||||
|
{ TheMovieDbOptions.Path, typeof(TheMovieDbOptions) }
|
||||||
|
};
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Configure(ContainerBuilder builder)
|
public void Configure(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
builder.RegisterProvider<TheMovieDbProvider>();
|
builder.RegisterProvider<TheMovieDbProvider>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ namespace Kyoo.TheMovieDb.Models
|
|||||||
public const string Path = "the-moviedb";
|
public const string Path = "the-moviedb";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The api key of TheMovieDb.
|
/// The api key of TheMovieDb.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace Kyoo.TheTvdb
|
|||||||
public static class Convertors
|
public static class Convertors
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert the string representation of the status in the tvdb API to a Kyoo's <see cref="Status"/> enum.
|
/// Convert the string representation of the status in the tvdb API to a Kyoo's <see cref="Status"/> enum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="status">The string representing the status.</param>
|
/// <param name="status">The string representing the status.</param>
|
||||||
/// <returns>A kyoo <see cref="Status"/> value or null.</returns>
|
/// <returns>A kyoo <see cref="Status"/> value or null.</returns>
|
||||||
@ -40,9 +40,9 @@ namespace Kyoo.TheTvdb
|
|||||||
? parsed
|
? parsed
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a series search to a show.
|
/// Convert a series search to a show.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="result">The search result</param>
|
/// <param name="result">The search result</param>
|
||||||
/// <param name="provider">The provider representing the tvdb inside kyoo</param>
|
/// <param name="provider">The provider representing the tvdb inside kyoo</param>
|
||||||
@ -60,7 +60,7 @@ namespace Kyoo.TheTvdb
|
|||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = !string.IsNullOrEmpty(result.Poster)
|
[Images.Poster] = !string.IsNullOrEmpty(result.Poster)
|
||||||
? $"https://www.thetvdb.com{result.Poster}"
|
? $"https://www.thetvdb.com{result.Poster}"
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -74,7 +74,7 @@ namespace Kyoo.TheTvdb
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a tvdb series to a kyoo show.
|
/// Convert a tvdb series to a kyoo show.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -94,10 +94,10 @@ namespace Kyoo.TheTvdb
|
|||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = !string.IsNullOrEmpty(series.Poster)
|
[Images.Poster] = !string.IsNullOrEmpty(series.Poster)
|
||||||
? $"https://www.thetvdb.com/banners/{series.Poster}"
|
? $"https://www.thetvdb.com/banners/{series.Poster}"
|
||||||
: null,
|
: null,
|
||||||
[Images.Thumbnail] = !string.IsNullOrEmpty(series.FanArt)
|
[Images.Thumbnail] = !string.IsNullOrEmpty(series.FanArt)
|
||||||
? $"https://www.thetvdb.com/banners/{series.FanArt}"
|
? $"https://www.thetvdb.com/banners/{series.FanArt}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
Genres = series.Genre.Select(y => new Genre(y)).ToList(),
|
Genres = series.Genre.Select(y => new Genre(y)).ToList(),
|
||||||
@ -112,7 +112,7 @@ namespace Kyoo.TheTvdb
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a tvdb actor to a kyoo <see cref="PeopleRole"/>.
|
/// Convert a tvdb actor to a kyoo <see cref="PeopleRole"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -126,10 +126,10 @@ namespace Kyoo.TheTvdb
|
|||||||
{
|
{
|
||||||
Slug = Utility.ToSlug(actor.Name),
|
Slug = Utility.ToSlug(actor.Name),
|
||||||
Name = actor.Name,
|
Name = actor.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Poster] = !string.IsNullOrEmpty(actor.Image)
|
[Images.Poster] = !string.IsNullOrEmpty(actor.Image)
|
||||||
? $"https://www.thetvdb.com/banners/{actor.Image}"
|
? $"https://www.thetvdb.com/banners/{actor.Image}"
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -155,8 +155,8 @@ namespace Kyoo.TheTvdb
|
|||||||
Overview = episode.Overview,
|
Overview = episode.Overview,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Images.Thumbnail] = !string.IsNullOrEmpty(episode.Filename)
|
[Images.Thumbnail] = !string.IsNullOrEmpty(episode.Filename)
|
||||||
? $"https://www.thetvdb.com/banners/{episode.Filename}"
|
? $"https://www.thetvdb.com/banners/{episode.Filename}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
ExternalIDs = new[]
|
ExternalIDs = new[]
|
||||||
@ -171,4 +171,4 @@ namespace Kyoo.TheTvdb
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
Kyoo.ruleset
Normal file
26
Kyoo.ruleset
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<RuleSet Name="Kyoo" ToolsVersion="10.0">
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.MaintainabilityRules">
|
||||||
|
<Rule Id="SA1413" Action="None" /> <!-- UseTrailingCommasInMultiLineInitializers -->
|
||||||
|
<Rule Id="SA1414" Action="None" /> <!-- UseTrailingCommasInMultiLineInitializers -->
|
||||||
|
</Rules>
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.NamingRules">
|
||||||
|
<Rule Id="SA1309" Action="None" /> <!-- FieldNamesMustNotBeginWithUnderscore -->
|
||||||
|
<Rule Id="SX1309" Action="Warning" /> <!-- FieldNamesMustBeginWithUnderscore -->
|
||||||
|
</Rules>
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.ReadabilityRules">
|
||||||
|
<Rule Id="SA1101" Action="None" /> <!-- PrefixLocalCallsWithThis -->
|
||||||
|
<Rule Id="SX1101" Action="Warning" /> <!-- DoNotPrefixLocalMembersWithThis -->
|
||||||
|
</Rules>
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.SpacingRules">
|
||||||
|
<Rule Id="SA1502" Action="None"/> <!-- DocumentationLinesMustBeginWithSingleSpace -->
|
||||||
|
</Rules>
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.CSharp.DocumentationRules">
|
||||||
|
<Rule Id="SA1642" Action="None" /> <!-- ConstructorSummaryDocumentationMustBeginWithStandardText -->
|
||||||
|
<Rule Id="SA1643" Action="None" /> <!-- DestructorSummaryDocumentationMustBeginWithStandardText -->
|
||||||
|
<Rule Id="SA1623" Action="None" /> <!-- PropertySummaryDocumentationMustMatchAccessors -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Rule Id="SA1633" Action="None" /> <!-- FileMustHaveHeader TODO remove this, this is only temporary -->
|
||||||
|
</Rules>
|
||||||
|
</RuleSet>
|
6
stylecop.json
Normal file
6
stylecop.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||||
|
"settings": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user