MediaBrowser.Providers: Remove some warnings

This commit is contained in:
Bond_009 2021-06-27 02:00:17 +02:00
parent 9405604913
commit cf061f7563
14 changed files with 56 additions and 62 deletions

View file

@ -102,7 +102,7 @@ namespace MediaBrowser.Providers.Manager
{ {
if (provider is IRemoteImageProvider remoteProvider) if (provider is IRemoteImageProvider remoteProvider)
{ {
await RefreshFromProvider(item, libraryOptions, remoteProvider, refreshOptions, typeOptions, backdropLimit, screenshotLimit, downloadedImages, result, cancellationToken).ConfigureAwait(false); await RefreshFromProvider(item, remoteProvider, refreshOptions, typeOptions, backdropLimit, screenshotLimit, downloadedImages, result, cancellationToken).ConfigureAwait(false);
continue; continue;
} }
@ -235,7 +235,6 @@ namespace MediaBrowser.Providers.Manager
/// Refreshes from provider. /// Refreshes from provider.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="libraryOptions">The library options.</param>
/// <param name="provider">The provider.</param> /// <param name="provider">The provider.</param>
/// <param name="refreshOptions">The refresh options.</param> /// <param name="refreshOptions">The refresh options.</param>
/// <param name="savedOptions">The saved options.</param> /// <param name="savedOptions">The saved options.</param>
@ -247,7 +246,6 @@ namespace MediaBrowser.Providers.Manager
/// <returns>Task.</returns> /// <returns>Task.</returns>
private async Task RefreshFromProvider( private async Task RefreshFromProvider(
BaseItem item, BaseItem item,
LibraryOptions libraryOptions,
IRemoteImageProvider provider, IRemoteImageProvider provider,
ImageRefreshOptions refreshOptions, ImageRefreshOptions refreshOptions,
TypeOptions savedOptions, TypeOptions savedOptions,
@ -295,7 +293,7 @@ namespace MediaBrowser.Providers.Manager
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType))) if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
{ {
minWidth = savedOptions.GetMinWidth(imageType); minWidth = savedOptions.GetMinWidth(imageType);
var downloaded = await DownloadImage(item, libraryOptions, provider, result, list, minWidth, imageType, cancellationToken).ConfigureAwait(false); var downloaded = await DownloadImage(item, provider, result, list, minWidth, imageType, cancellationToken).ConfigureAwait(false);
if (downloaded) if (downloaded)
{ {
@ -305,12 +303,12 @@ namespace MediaBrowser.Providers.Manager
} }
minWidth = savedOptions.GetMinWidth(ImageType.Backdrop); minWidth = savedOptions.GetMinWidth(ImageType.Backdrop);
await DownloadBackdrops(item, libraryOptions, ImageType.Backdrop, backdropLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false); await DownloadBackdrops(item, ImageType.Backdrop, backdropLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
if (item is IHasScreenshots hasScreenshots) if (item is IHasScreenshots hasScreenshots)
{ {
minWidth = savedOptions.GetMinWidth(ImageType.Screenshot); minWidth = savedOptions.GetMinWidth(ImageType.Screenshot);
await DownloadBackdrops(item, libraryOptions, ImageType.Screenshot, screenshotLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false); await DownloadBackdrops(item, ImageType.Screenshot, screenshotLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
} }
} }
catch (OperationCanceledException) catch (OperationCanceledException)
@ -360,7 +358,7 @@ namespace MediaBrowser.Providers.Manager
} }
} }
public bool MergeImages(BaseItem item, List<LocalImageInfo> images) public bool MergeImages(BaseItem item, IReadOnlyList<LocalImageInfo> images)
{ {
var changed = false; var changed = false;
@ -444,12 +442,12 @@ namespace MediaBrowser.Providers.Manager
return null; return null;
} }
private bool UpdateMultiImages(BaseItem item, List<LocalImageInfo> images, ImageType type) private bool UpdateMultiImages(BaseItem item, IReadOnlyList<LocalImageInfo> images, ImageType type)
{ {
var changed = false; var changed = false;
var newImageFileInfos = images var newImageFileInfos = images
.FindAll(i => i.Type == type) .Where(i => i.Type == type)
.Select(i => i.FileInfo) .Select(i => i.FileInfo)
.ToList(); .ToList();
@ -463,7 +461,6 @@ namespace MediaBrowser.Providers.Manager
private async Task<bool> DownloadImage( private async Task<bool> DownloadImage(
BaseItem item, BaseItem item,
LibraryOptions libraryOptions,
IRemoteImageProvider provider, IRemoteImageProvider provider,
RefreshResult result, RefreshResult result,
IEnumerable<RemoteImageInfo> images, IEnumerable<RemoteImageInfo> images,
@ -475,7 +472,7 @@ namespace MediaBrowser.Providers.Manager
.Where(i => i.Type == type && !(i.Width.HasValue && i.Width.Value < minWidth)) .Where(i => i.Type == type && !(i.Width.HasValue && i.Width.Value < minWidth))
.ToList(); .ToList();
if (EnableImageStub(item, libraryOptions) && eligibleImages.Count > 0) if (EnableImageStub(item) && eligibleImages.Count > 0)
{ {
SaveImageStub(item, type, eligibleImages.Select(i => i.Url)); SaveImageStub(item, type, eligibleImages.Select(i => i.Url));
result.UpdateType |= ItemUpdateType.ImageUpdate; result.UpdateType |= ItemUpdateType.ImageUpdate;
@ -519,7 +516,7 @@ namespace MediaBrowser.Providers.Manager
return false; return false;
} }
private bool EnableImageStub(BaseItem item, LibraryOptions libraryOptions) private bool EnableImageStub(BaseItem item)
{ {
if (item is LiveTvProgram) if (item is LiveTvProgram)
{ {
@ -563,7 +560,7 @@ namespace MediaBrowser.Providers.Manager
newIndex); newIndex);
} }
private async Task DownloadBackdrops(BaseItem item, LibraryOptions libraryOptions, ImageType imageType, int limit, IRemoteImageProvider provider, RefreshResult result, IEnumerable<RemoteImageInfo> images, int minWidth, CancellationToken cancellationToken) private async Task DownloadBackdrops(BaseItem item, ImageType imageType, int limit, IRemoteImageProvider provider, RefreshResult result, IEnumerable<RemoteImageInfo> images, int minWidth, CancellationToken cancellationToken)
{ {
foreach (var image in images.Where(i => i.Type == imageType)) foreach (var image in images.Where(i => i.Type == imageType))
{ {
@ -579,7 +576,7 @@ namespace MediaBrowser.Providers.Manager
var url = image.Url; var url = image.Url;
if (EnableImageStub(item, libraryOptions)) if (EnableImageStub(item))
{ {
SaveImageStub(item, imageType, new[] { url }); SaveImageStub(item, imageType, new[] { url });
result.UpdateType |= ItemUpdateType.ImageUpdate; result.UpdateType |= ItemUpdateType.ImageUpdate;

View file

@ -617,7 +617,7 @@ namespace MediaBrowser.Providers.Manager
MetadataResult<TItemType> metadata, MetadataResult<TItemType> metadata,
TIdType id, TIdType id,
MetadataRefreshOptions options, MetadataRefreshOptions options,
List<IMetadataProvider> providers, ICollection<IMetadataProvider> providers,
ItemImageProvider imageService, ItemImageProvider imageService,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {

View file

@ -215,18 +215,19 @@ namespace MediaBrowser.Providers.Music
return result; return result;
} }
public async Task<MetadataResult<MusicArtist>> GetMetadata(ArtistInfo id, CancellationToken cancellationToken) /// <inheritdoc />
public async Task<MetadataResult<MusicArtist>> GetMetadata(ArtistInfo info, CancellationToken cancellationToken)
{ {
var result = new MetadataResult<MusicArtist> var result = new MetadataResult<MusicArtist>
{ {
Item = new MusicArtist() Item = new MusicArtist()
}; };
var musicBrainzId = id.GetMusicBrainzArtistId(); var musicBrainzId = info.GetMusicBrainzArtistId();
if (string.IsNullOrWhiteSpace(musicBrainzId)) if (string.IsNullOrWhiteSpace(musicBrainzId))
{ {
var searchResults = await GetSearchResults(id, cancellationToken).ConfigureAwait(false); var searchResults = await GetSearchResults(info, cancellationToken).ConfigureAwait(false);
var singleResult = searchResults.FirstOrDefault(); var singleResult = searchResults.FirstOrDefault();

View file

@ -41,7 +41,6 @@ namespace MediaBrowser.Providers.Music
private readonly long _musicBrainzQueryIntervalMs; private readonly long _musicBrainzQueryIntervalMs;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly IApplicationHost _appHost;
private readonly ILogger<MusicBrainzAlbumProvider> _logger; private readonly ILogger<MusicBrainzAlbumProvider> _logger;
private readonly string _musicBrainzBaseUrl; private readonly string _musicBrainzBaseUrl;
@ -51,11 +50,9 @@ namespace MediaBrowser.Providers.Music
public MusicBrainzAlbumProvider( public MusicBrainzAlbumProvider(
IHttpClientFactory httpClientFactory, IHttpClientFactory httpClientFactory,
IApplicationHost appHost,
ILogger<MusicBrainzAlbumProvider> logger) ILogger<MusicBrainzAlbumProvider> logger)
{ {
_httpClientFactory = httpClientFactory; _httpClientFactory = httpClientFactory;
_appHost = appHost;
_logger = logger; _logger = logger;
_musicBrainzBaseUrl = Plugin.Instance.Configuration.Server; _musicBrainzBaseUrl = Plugin.Instance.Configuration.Server;
@ -174,10 +171,10 @@ namespace MediaBrowser.Providers.Music
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<MetadataResult<MusicAlbum>> GetMetadata(AlbumInfo id, CancellationToken cancellationToken) public async Task<MetadataResult<MusicAlbum>> GetMetadata(AlbumInfo info, CancellationToken cancellationToken)
{ {
var releaseId = id.GetReleaseId(); var releaseId = info.GetReleaseId();
var releaseGroupId = id.GetReleaseGroupId(); var releaseGroupId = info.GetReleaseGroupId();
var result = new MetadataResult<MusicAlbum> var result = new MetadataResult<MusicAlbum>
{ {
@ -193,9 +190,9 @@ namespace MediaBrowser.Providers.Music
if (string.IsNullOrWhiteSpace(releaseId)) if (string.IsNullOrWhiteSpace(releaseId))
{ {
var artistMusicBrainzId = id.GetMusicBrainzArtistId(); var artistMusicBrainzId = info.GetMusicBrainzArtistId();
var releaseResult = await GetReleaseResult(artistMusicBrainzId, id.GetAlbumArtist(), id.Name, cancellationToken).ConfigureAwait(false); var releaseResult = await GetReleaseResult(artistMusicBrainzId, info.GetAlbumArtist(), info.Name, cancellationToken).ConfigureAwait(false);
if (releaseResult != null) if (releaseResult != null)
{ {
@ -499,12 +496,11 @@ namespace MediaBrowser.Providers.Music
using var subReader = reader.ReadSubtree(); using var subReader = reader.ReadSubtree();
return ParseArtistNameCredit(subReader); return ParseArtistNameCredit(subReader);
} }
default: default:
{ {
reader.Skip(); reader.Skip();
break; break;
} }
} }
} }
else else

View file

@ -11,6 +11,12 @@ namespace MediaBrowser.Providers.Plugins.MusicBrainz
{ {
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{ {
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
public static Plugin Instance { get; private set; } public static Plugin Instance { get; private set; }
public override Guid Id => new Guid("8c95c4d2-e50c-4fb0-a4f3-6c06ff0f9a1a"); public override Guid Id => new Guid("8c95c4d2-e50c-4fb0-a4f3-6c06ff0f9a1a");
@ -26,12 +32,6 @@ namespace MediaBrowser.Providers.Plugins.MusicBrainz
// TODO remove when plugin removed from server. // TODO remove when plugin removed from server.
public override string ConfigurationFileName => "Jellyfin.Plugin.MusicBrainz.xml"; public override string ConfigurationFileName => "Jellyfin.Plugin.MusicBrainz.xml";
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
public IEnumerable<PluginPageInfo> GetPages() public IEnumerable<PluginPageInfo> GetPages()
{ {
yield return new PluginPageInfo yield return new PluginPageInfo

View file

@ -9,9 +9,8 @@ using System.Net.Http;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common;
using Jellyfin.Extensions.Json; using Jellyfin.Extensions.Json;
using Jellyfin.Extensions.Json.Converters; using MediaBrowser.Common;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;

View file

@ -9,9 +9,8 @@ using System.Net.Http;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common;
using Jellyfin.Extensions.Json; using Jellyfin.Extensions.Json;
using Jellyfin.Extensions.Json.Converters; using MediaBrowser.Common;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
@ -213,19 +212,19 @@ namespace MediaBrowser.Providers.Plugins.Omdb
{ {
var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false); var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false);
await using var stream = File.OpenRead(path); await using var stream = File.OpenRead(path);
return await JsonSerializer.DeserializeAsync<RootObject>(stream, _jsonOptions, cancellationToken); return await JsonSerializer.DeserializeAsync<RootObject>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
} }
internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken) internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken)
{ {
var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false); var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false);
await using var stream = File.OpenRead(path); await using var stream = File.OpenRead(path);
return await JsonSerializer.DeserializeAsync<SeasonRootObject>(stream, _jsonOptions, cancellationToken); return await JsonSerializer.DeserializeAsync<SeasonRootObject>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
} }
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds) internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
{ {
if (seriesProviderIds.TryGetValue(MetadataProvider.Imdb.ToString(), out string id) && !string.IsNullOrEmpty(id)) if (seriesProviderIds.TryGetValue(MetadataProvider.Imdb.ToString(), out string id))
{ {
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))

View file

@ -11,6 +11,12 @@ namespace MediaBrowser.Providers.Plugins.Omdb
{ {
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{ {
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
public static Plugin Instance { get; private set; } public static Plugin Instance { get; private set; }
public override Guid Id => new Guid("a628c0da-fac5-4c7e-9d1a-7134223f14c8"); public override Guid Id => new Guid("a628c0da-fac5-4c7e-9d1a-7134223f14c8");
@ -22,12 +28,6 @@ namespace MediaBrowser.Providers.Plugins.Omdb
// TODO remove when plugin removed from server. // TODO remove when plugin removed from server.
public override string ConfigurationFileName => "Jellyfin.Plugin.Omdb.xml"; public override string ConfigurationFileName => "Jellyfin.Plugin.Omdb.xml";
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
public IEnumerable<PluginPageInfo> GetPages() public IEnumerable<PluginPageInfo> GetPages()
{ {
yield return new PluginPageInfo yield return new PluginPageInfo

View file

@ -79,16 +79,16 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
return collections; return collections;
} }
public async Task<MetadataResult<BoxSet>> GetMetadata(BoxSetInfo id, CancellationToken cancellationToken) public async Task<MetadataResult<BoxSet>> GetMetadata(BoxSetInfo info, CancellationToken cancellationToken)
{ {
var tmdbId = Convert.ToInt32(id.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture); var tmdbId = Convert.ToInt32(info.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
var language = id.MetadataLanguage; var language = info.MetadataLanguage;
// We don't already have an Id, need to fetch it // We don't already have an Id, need to fetch it
if (tmdbId <= 0) if (tmdbId <= 0)
{ {
// ParseName is required here. // ParseName is required here.
// Caller provides the filename with extension stripped and NOT the parsed filename // Caller provides the filename with extension stripped and NOT the parsed filename
var parsedName = _libraryManager.ParseName(id.Name); var parsedName = _libraryManager.ParseName(info.Name);
var cleanedName = TmdbUtils.CleanName(parsedName.Name); var cleanedName = TmdbUtils.CleanName(parsedName.Name);
var searchResults = await _tmdbClientManager.SearchCollectionAsync(cleanedName, language, cancellationToken).ConfigureAwait(false); var searchResults = await _tmdbClientManager.SearchCollectionAsync(cleanedName, language, cancellationToken).ConfigureAwait(false);

View file

@ -154,7 +154,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
var movieResultFromImdbId = await _tmdbClientManager.FindByExternalIdAsync(imdbId, FindExternalSource.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false); var movieResultFromImdbId = await _tmdbClientManager.FindByExternalIdAsync(imdbId, FindExternalSource.Imdb, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
if (movieResultFromImdbId?.MovieResults.Count > 0) if (movieResultFromImdbId?.MovieResults.Count > 0)
{ {
tmdbId = movieResultFromImdbId.MovieResults[0].Id.ToString(); tmdbId = movieResultFromImdbId.MovieResults[0].Id.ToString(CultureInfo.InvariantCulture);
} }
} }

View file

@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
result.Item = new Season result.Item = new Season
{ {
IndexNumber = seasonNumber, IndexNumber = seasonNumber,
Overview = seasonResult?.Overview Overview = seasonResult.Overview
}; };
if (!string.IsNullOrEmpty(seasonResult.ExternalIds?.TvdbId)) if (!string.IsNullOrEmpty(seasonResult.ExternalIds?.TvdbId))

View file

@ -242,7 +242,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
await EnsureClientConfigAsync().ConfigureAwait(false); await EnsureClientConfigAsync().ConfigureAwait(false);
var group = await GetSeriesGroupAsync(tvShowId, displayOrder, language, imageLanguages, cancellationToken); var group = await GetSeriesGroupAsync(tvShowId, displayOrder, language, imageLanguages, cancellationToken).ConfigureAwait(false);
if (group != null) if (group != null)
{ {
var season = group.Groups.Find(s => s.Order == seasonNumber); var season = group.Groups.Find(s => s.Order == seasonNumber);

View file

@ -370,15 +370,15 @@ namespace MediaBrowser.Providers.Subtitles
} }
/// <inheritdoc /> /// <inheritdoc />
public SubtitleProviderInfo[] GetSupportedProviders(BaseItem video) public SubtitleProviderInfo[] GetSupportedProviders(BaseItem item)
{ {
VideoContentType mediaType; VideoContentType mediaType;
if (video is Episode) if (item is Episode)
{ {
mediaType = VideoContentType.Episode; mediaType = VideoContentType.Episode;
} }
else if (video is Movie) else if (item is Movie)
{ {
mediaType = VideoContentType.Movie; mediaType = VideoContentType.Movie;
} }

View file

@ -43,6 +43,8 @@
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token --> or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
<Rule Id="CA2016" Action="Error" /> <Rule Id="CA2016" Action="Error" />
<!-- disable warning CA1014: Mark assemblies with CLSCompliantAttribute -->
<Rule Id="CA1014" Action="Info" />
<!-- disable warning CA1024: Use properties where appropriate --> <!-- disable warning CA1024: Use properties where appropriate -->
<Rule Id="CA1024" Action="Info" /> <Rule Id="CA1024" Action="Info" />
<!-- disable warning CA1031: Do not catch general exception types --> <!-- disable warning CA1031: Do not catch general exception types -->
@ -68,8 +70,6 @@
<!-- disable warning CA5394: Do not use insecure randomness --> <!-- disable warning CA5394: Do not use insecure randomness -->
<Rule Id="CA5394" Action="Info" /> <Rule Id="CA5394" Action="Info" />
<!-- disable warning CA1014: Mark assemblies with CLSCompliantAttribute -->
<Rule Id="CA1014" Action="Info" />
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri --> <!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
<Rule Id="CA1054" Action="None" /> <Rule Id="CA1054" Action="None" />
<!-- disable warning CA1055: URI return values should not be strings --> <!-- disable warning CA1055: URI return values should not be strings -->
@ -82,5 +82,7 @@
<Rule Id="CA1308" Action="None" /> <Rule Id="CA1308" Action="None" />
<!-- disable warning CA2101: Specify marshaling for P/Invoke string arguments --> <!-- disable warning CA2101: Specify marshaling for P/Invoke string arguments -->
<Rule Id="CA2101" Action="None" /> <Rule Id="CA2101" Action="None" />
<!-- disable warning CA2234: Pass System.Uri objects instead of strings -->
<Rule Id="CA2234" Action="None" />
</Rules> </Rules>
</RuleSet> </RuleSet>