Merge pull request #8541 from Bond-009/minor

pull/8540/head
Claus Vium 2 years ago committed by GitHub
commit 99e31846bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns>`0.</returns> /// <returns>`0.</returns>
public override T Resolve(ItemResolveArgs args) protected override T Resolve(ItemResolveArgs args)
{ {
return ResolveVideo<T>(args, false); return ResolveVideo<T>(args, false);
} }

@ -8,15 +8,16 @@ using System.Linq;
using Jellyfin.Extensions; using Jellyfin.Extensions;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
namespace Emby.Server.Implementations.Library.Resolvers.Books namespace Emby.Server.Implementations.Library.Resolvers.Books
{ {
public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver<Book> public class BookResolver : ItemResolver<Book>
{ {
private readonly string[] _validExtensions = { ".azw", ".azw3", ".cb7", ".cbr", ".cbt", ".cbz", ".epub", ".mobi", ".pdf" }; private readonly string[] _validExtensions = { ".azw", ".azw3", ".cb7", ".cbr", ".cbt", ".cbz", ".epub", ".mobi", ".pdf" };
public override Book Resolve(ItemResolveArgs args) protected override Book Resolve(ItemResolveArgs args)
{ {
var collectionType = args.GetCollectionType(); var collectionType = args.GetCollectionType();

@ -2,6 +2,7 @@
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
namespace Emby.Server.Implementations.Library.Resolvers namespace Emby.Server.Implementations.Library.Resolvers
{ {

@ -1,58 +0,0 @@
#nullable disable
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
namespace Emby.Server.Implementations.Library.Resolvers
{
/// <summary>
/// Class ItemResolver.
/// </summary>
/// <typeparam name="T">The type of BaseItem.</typeparam>
public abstract class ItemResolver<T> : IItemResolver
where T : BaseItem, new()
{
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary>
/// Resolves the specified args.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>`0.</returns>
protected virtual T Resolve(ItemResolveArgs args)
{
return null;
}
/// <summary>
/// Sets initial values on the newly resolved item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="args">The args.</param>
protected virtual void SetInitialItemValues(T item, ItemResolveArgs args)
{
}
/// <summary>
/// Resolves the path.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>BaseItem.</returns>
BaseItem IItemResolver.ResolvePath(ItemResolveArgs args)
{
var item = Resolve(args);
if (item != null)
{
SetInitialItemValues(item, args);
}
return item;
}
}
}

@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns>Video.</returns> /// <returns>Video.</returns>
public override Video Resolve(ItemResolveArgs args) protected override Video Resolve(ItemResolveArgs args)
{ {
var collectionType = args.GetCollectionType(); var collectionType = args.GetCollectionType();

@ -12,6 +12,7 @@ using Jellyfin.Extensions;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
namespace Emby.Server.Implementations.Library.Resolvers namespace Emby.Server.Implementations.Library.Resolvers

@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns>Episode.</returns> /// <returns>Episode.</returns>
public override Episode Resolve(ItemResolveArgs args) protected override Episode Resolve(ItemResolveArgs args)
{ {
var parent = args.Parent; var parent = args.Parent;

@ -2218,9 +2218,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
continue; continue;
} }
// Skip ShowId without SubKey from duplicate removal actions - https://github.com/jellyfin/jellyfin/issues/5856 // Skip ShowId without SubKey from duplicate removal actions - https://github.com/jellyfin/jellyfin/issues/5856
if (group.Key.EndsWith("0000")) if (group.Key.EndsWith("0000", StringComparison.Ordinal))
{ {
continue; continue;
} }

@ -88,25 +88,20 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(info.Path, cancellationToken).ConfigureAwait(false); using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(info.Path, cancellationToken).ConfigureAwait(false);
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
return await UnzipIfNeededAndCopy(info.Path, stream, cacheFile, cancellationToken).ConfigureAwait(false); return await UnzipIfNeededAndCopy(info.Path, stream, cacheFile, cancellationToken).ConfigureAwait(false);
} }
else else
{ {
await using var stream = new FileStream(info.Path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous); await using var stream = AsyncFile.OpenRead(info.Path);
return await UnzipIfNeededAndCopy(info.Path, stream, cacheFile, cancellationToken).ConfigureAwait(false); return await UnzipIfNeededAndCopy(info.Path, stream, cacheFile, cancellationToken).ConfigureAwait(false);
} }
} }
private async Task<string> UnzipIfNeededAndCopy(string originalUrl, Stream stream, string file, CancellationToken cancellationToken) private async Task<string> UnzipIfNeededAndCopy(string originalUrl, Stream stream, string file, CancellationToken cancellationToken)
{ {
int index = originalUrl.IndexOf('?', StringComparison.CurrentCulture); await using var fileStream = new FileStream(file, FileMode.CreateNew, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
string ext = Path.GetExtension(index > -1 ? originalUrl.Remove(index) : originalUrl);
await using var fileStream = new FileStream(file, FileMode.CreateNew, FileAccess.Write, FileShare.None, IODefaults.CopyToBufferSize, FileOptions.Asynchronous);
if (ext.Equals(".gz", StringComparison.OrdinalIgnoreCase)) if (Path.GetExtension(originalUrl.AsSpan().LeftPart('?')).Equals(".gz", StringComparison.OrdinalIgnoreCase))
{ {
try try
{ {
@ -166,16 +161,16 @@ namespace Emby.Server.Implementations.LiveTv.Listings
IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)), IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)), IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)), IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
ImageUrl = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null, ImageUrl = string.IsNullOrEmpty(program.Icon?.Source) ? null : program.Icon.Source,
HasImage = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source), HasImage = !string.IsNullOrEmpty(program.Icon?.Source),
OfficialRating = program.Rating != null && !string.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null, OfficialRating = string.IsNullOrEmpty(program.Rating?.Value) ? null : program.Rating.Value,
CommunityRating = program.StarRating, CommunityRating = program.StarRating,
SeriesId = program.Episode == null ? null : program.Title.GetMD5().ToString("N", CultureInfo.InvariantCulture) SeriesId = program.Episode == null ? null : program.Title.GetMD5().ToString("N", CultureInfo.InvariantCulture)
}; };
if (string.IsNullOrWhiteSpace(program.ProgramId)) if (string.IsNullOrWhiteSpace(program.ProgramId))
{ {
string uniqueString = (program.Title ?? string.Empty) + (episodeTitle ?? string.Empty) /*+ (p.IceTvEpisodeNumber ?? string.Empty)*/; string uniqueString = (program.Title ?? string.Empty) + (episodeTitle ?? string.Empty);
if (programInfo.SeasonNumber.HasValue) if (programInfo.SeasonNumber.HasValue)
{ {

@ -274,7 +274,7 @@ namespace Jellyfin.Api.Controllers
}; };
playbackProgressInfo.PlayMethod = ValidatePlayMethod(playbackProgressInfo.PlayMethod, playbackProgressInfo.PlaySessionId); playbackProgressInfo.PlayMethod = ValidatePlayMethod(playbackProgressInfo.PlayMethod, playbackProgressInfo.PlaySessionId);
playbackProgressInfo.SessionId = await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);; playbackProgressInfo.SessionId = await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
await _sessionManager.OnPlaybackProgress(playbackProgressInfo).ConfigureAwait(false); await _sessionManager.OnPlaybackProgress(playbackProgressInfo).ConfigureAwait(false);
return NoContent(); return NoContent();
} }
@ -319,7 +319,7 @@ namespace Jellyfin.Api.Controllers
await _transcodingJobHelper.KillTranscodingJobs(User.GetDeviceId()!, playbackStopInfo.PlaySessionId, s => true).ConfigureAwait(false); await _transcodingJobHelper.KillTranscodingJobs(User.GetDeviceId()!, playbackStopInfo.PlaySessionId, s => true).ConfigureAwait(false);
} }
playbackStopInfo.SessionId = await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);; playbackStopInfo.SessionId = await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
await _sessionManager.OnPlaybackStopped(playbackStopInfo).ConfigureAwait(false); await _sessionManager.OnPlaybackStopped(playbackStopInfo).ConfigureAwait(false);
return NoContent(); return NoContent();
} }

@ -182,7 +182,7 @@ namespace Jellyfin.Api.Controllers
}; };
await _sessionManager.SendPlayCommand( await _sessionManager.SendPlayCommand(
await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false), await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false),
sessionId, sessionId,
playRequest, playRequest,
CancellationToken.None) CancellationToken.None)
@ -210,7 +210,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? controllingUserId) [FromQuery] string? controllingUserId)
{ {
await _sessionManager.SendPlaystateCommand( await _sessionManager.SendPlaystateCommand(
await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false), await RequestHelpers.GetSessionId(_sessionManager, _userManager, HttpContext).ConfigureAwait(false),
sessionId, sessionId,
new PlaystateRequest() new PlaystateRequest()
{ {

@ -108,7 +108,7 @@ namespace Jellyfin.Api.Controllers
{ {
var deviceProfile = GetDeviceProfile(container, transcodingContainer, audioCodec, transcodingProtocol, breakOnNonKeyFrames, transcodingAudioChannels, maxAudioSampleRate, maxAudioBitDepth, maxAudioChannels); var deviceProfile = GetDeviceProfile(container, transcodingContainer, audioCodec, transcodingProtocol, breakOnNonKeyFrames, transcodingAudioChannels, maxAudioSampleRate, maxAudioBitDepth, maxAudioChannels);
if (!userId.HasValue || userId.Value.Equals(Guid.Empty)) if (!userId.HasValue || userId.Value.Equals(default))
{ {
userId = User.GetUserId(); userId = User.GetUserId();
} }

@ -1,5 +1,6 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@ -14,6 +15,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("Jellyfin.Server.Implementations.Tests")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from

@ -23,7 +23,7 @@ namespace MediaBrowser.Controller.Resolvers
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns>`0.</returns> /// <returns>`0.</returns>
public virtual T Resolve(ItemResolveArgs args) protected internal virtual T Resolve(ItemResolveArgs args)
{ {
return null; return null;
} }
@ -42,7 +42,7 @@ namespace MediaBrowser.Controller.Resolvers
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns>BaseItem.</returns> /// <returns>BaseItem.</returns>
BaseItem IItemResolver.ResolvePath(ItemResolveArgs args) public BaseItem ResolvePath(ItemResolveArgs args)
{ {
var item = Resolve(args); var item = Resolve(args);

@ -5,8 +5,16 @@
<Rule Id="SA1000" Action="Error" /> <Rule Id="SA1000" Action="Error" />
<!-- error on SA1001: Commas should not be preceded by whitespace --> <!-- error on SA1001: Commas should not be preceded by whitespace -->
<Rule Id="SA1001" Action="Error" /> <Rule Id="SA1001" Action="Error" />
<!-- error on SA1106: Code should not contain empty statements -->
<Rule Id="SA1106" Action="Error" />
<!-- error on SA1107: Code should not contain multiple statements on one line -->
<Rule Id="SA1107" Action="Error" />
<!-- error on SA1028: Code should not contain trailing whitespace -->
<Rule Id="SA1028" Action="Error" />
<!-- error on SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line --> <!-- error on SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line -->
<Rule Id="SA1117" Action="Error" /> <Rule Id="SA1117" Action="Error" />
<!-- error on SA1137: Elements should have the same indentation -->
<Rule Id="SA1137" Action="Error" />
<!-- error on SA1142: Refer to tuple fields by name --> <!-- error on SA1142: Refer to tuple fields by name -->
<Rule Id="SA1142" Action="Error" /> <Rule Id="SA1142" Action="Error" />
<!-- error on SA1210: Using directives should be ordered alphabetically by the namespaces --> <!-- error on SA1210: Using directives should be ordered alphabetically by the namespaces -->
@ -69,6 +77,8 @@
<Rule Id="CA1307" Action="Error" /> <Rule Id="CA1307" Action="Error" />
<!-- error on CA1309: Use ordinal StringComparison --> <!-- error on CA1309: Use ordinal StringComparison -->
<Rule Id="CA1309" Action="Error" /> <Rule Id="CA1309" Action="Error" />
<!-- error on CA1310: Specify StringComparison for correctness -->
<Rule Id="CA1310" Action="Error" />
<!-- error on CA1725: Parameter names should match base declaration --> <!-- error on CA1725: Parameter names should match base declaration -->
<Rule Id="CA1725" Action="Error" /> <Rule Id="CA1725" Action="Error" />
<!-- error on CA1725: Call async methods when in an async method --> <!-- error on CA1725: Call async methods when in an async method -->

Loading…
Cancel
Save