Fix all warnings in MediaBrowser.Providers
This commit is contained in:
parent
6dbdb4e9af
commit
b934b346e1
|
@ -264,7 +264,8 @@ namespace MediaBrowser.Providers.Manager
|
|||
var fileStreamOptions = AsyncFile.WriteOptions;
|
||||
fileStreamOptions.Mode = FileMode.Create;
|
||||
fileStreamOptions.PreallocationSize = source.Length;
|
||||
await using (var fs = new FileStream(path, fileStreamOptions))
|
||||
var fs = new FileStream(path, fileStreamOptions);
|
||||
await using (fs.ConfigureAwait(false))
|
||||
{
|
||||
await source.CopyToAsync(fs, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
|
|
@ -502,8 +502,9 @@ namespace MediaBrowser.Providers.Manager
|
|||
break;
|
||||
}
|
||||
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
await _providerManager.SaveImage(
|
||||
item,
|
||||
stream,
|
||||
|
@ -511,6 +512,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
type,
|
||||
null,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
result.UpdateType |= ItemUpdateType.ImageUpdate;
|
||||
return true;
|
||||
|
@ -626,7 +628,9 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
await _providerManager.SaveImage(
|
||||
item,
|
||||
stream,
|
||||
|
@ -634,6 +638,8 @@ namespace MediaBrowser.Providers.Manager
|
|||
imageType,
|
||||
null,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
result.UpdateType |= ItemUpdateType.ImageUpdate;
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
|
|
|
@ -182,7 +182,9 @@ namespace MediaBrowser.Providers.Manager
|
|||
contentType = MimeTypes.GetMimeType(url);
|
||||
}
|
||||
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
await SaveImage(
|
||||
item,
|
||||
stream,
|
||||
|
@ -191,6 +193,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
imageIndex,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken)
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Code Analyzers-->
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.3">
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
|
||||
if (attachmentStream is not null)
|
||||
{
|
||||
return await ExtractAttachment(item, attachmentStream, mediaSource, cancellationToken);
|
||||
return await ExtractAttachment(item, attachmentStream, mediaSource, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Fall back to EmbeddedImage streams
|
||||
|
|
|
@ -557,7 +557,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
CancellationToken cancellationToken)
|
||||
{
|
||||
var startIndex = currentStreams.Count == 0 ? 0 : (currentStreams.Select(i => i.Index).Max() + 1);
|
||||
var externalSubtitleStreams = await _subtitleResolver.GetExternalStreamsAsync(video, startIndex, options.DirectoryService, false, cancellationToken);
|
||||
var externalSubtitleStreams = await _subtitleResolver.GetExternalStreamsAsync(video, startIndex, options.DirectoryService, false, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var enableSubtitleDownloading = options.MetadataRefreshMode == MetadataRefreshMode.Default ||
|
||||
options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh;
|
||||
|
@ -611,7 +611,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
// Rescan
|
||||
if (downloadedLanguages.Count > 0)
|
||||
{
|
||||
externalSubtitleStreams = await _subtitleResolver.GetExternalStreamsAsync(video, startIndex, options.DirectoryService, true, cancellationToken);
|
||||
externalSubtitleStreams = await _subtitleResolver.GetExternalStreamsAsync(video, startIndex, options.DirectoryService, true, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
|
@ -42,11 +43,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
{
|
||||
ImageType.Primary,
|
||||
ImageType.Disc
|
||||
};
|
||||
yield return ImageType.Primary;
|
||||
yield return ImageType.Disc;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -60,7 +58,9 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
|
||||
var path = AudioDbAlbumProvider.GetAlbumInfoPath(_config.ApplicationPaths, id);
|
||||
|
||||
await using FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
await using (jsonStream.ConfigureAwait(false))
|
||||
{
|
||||
var obj = await JsonSerializer.DeserializeAsync<AudioDbAlbumProvider.RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (obj is not null && obj.album is not null && obj.album.Count > 0)
|
||||
|
@ -68,8 +68,9 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
return GetImages(obj.album[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new List<RemoteImageInfo>();
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
private IEnumerable<RemoteImageInfo> GetImages(AudioDbAlbumProvider.Album item)
|
||||
|
|
|
@ -68,7 +68,9 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
|
||||
var path = GetAlbumInfoPath(_config.ApplicationPaths, id);
|
||||
|
||||
await using FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
await using (jsonStream.ConfigureAwait(false))
|
||||
{
|
||||
var obj = await JsonSerializer.DeserializeAsync<RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (obj is not null && obj.album is not null && obj.album.Count > 0)
|
||||
|
@ -78,6 +80,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
ProcessResult(result.Item, obj.album[0], info.MetadataLanguage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -173,14 +176,19 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
var fileStreamOptions = AsyncFile.WriteOptions;
|
||||
fileStreamOptions.Mode = FileMode.Create;
|
||||
fileStreamOptions.PreallocationSize = stream.Length;
|
||||
await using var xmlFileStream = new FileStream(path, fileStreamOptions);
|
||||
var xmlFileStream = new FileStream(path, fileStreamOptions);
|
||||
await using (xmlFileStream.ConfigureAwait(false))
|
||||
{
|
||||
await stream.CopyToAsync(xmlFileStream, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAlbumDataPath(IApplicationPaths appPaths, string musicBrainzReleaseGroupId)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,9 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
|
||||
var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);
|
||||
|
||||
await using FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
await using (jsonStream.ConfigureAwait(false))
|
||||
{
|
||||
var obj = await JsonSerializer.DeserializeAsync<AudioDbArtistProvider.RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (obj is not null && obj.artists is not null && obj.artists.Count > 0)
|
||||
|
@ -70,6 +72,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
return GetImages(obj.artists[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new List<RemoteImageInfo>();
|
||||
}
|
||||
|
|
|
@ -67,7 +67,9 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
|
||||
var path = GetArtistInfoPath(_config.ApplicationPaths, id);
|
||||
|
||||
await using FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
FileStream jsonStream = AsyncFile.OpenRead(path);
|
||||
await using (jsonStream.ConfigureAwait(false))
|
||||
{
|
||||
var obj = await JsonSerializer.DeserializeAsync<RootObject>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (obj is not null && obj.artists is not null && obj.artists.Count > 0)
|
||||
|
@ -77,6 +79,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
ProcessResult(result.Item, obj.artists[0], info.MetadataLanguage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -151,17 +154,22 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
|||
|
||||
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
var path = GetArtistInfoPath(_config.ApplicationPaths, musicBrainzId);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
var fileStreamOptions = AsyncFile.WriteOptions;
|
||||
fileStreamOptions.Mode = FileMode.Create;
|
||||
fileStreamOptions.PreallocationSize = stream.Length;
|
||||
await using var xmlFileStream = new FileStream(path, fileStreamOptions);
|
||||
var xmlFileStream = new FileStream(path, fileStreamOptions);
|
||||
await using (xmlFileStream.ConfigureAwait(false))
|
||||
{
|
||||
await stream.CopyToAsync(xmlFileStream, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artist data path.
|
||||
|
|
|
@ -137,8 +137,9 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|||
var url = OmdbProvider.GetOmdbUrl(urlQuery.ToString());
|
||||
|
||||
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
if (isSearch)
|
||||
{
|
||||
var searchResultList = await JsonSerializer.DeserializeAsync<SearchResultList>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
@ -162,6 +163,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|||
return new[] { ResultToMetadataResult(result, searchInfo, indexNumberEnd) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Enumerable.Empty<RemoteSearchResult>();
|
||||
}
|
||||
|
|
|
@ -234,16 +234,22 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|||
internal async Task<RootObject> GetRootObject(string imdbId, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false);
|
||||
await using var stream = AsyncFile.OpenRead(path);
|
||||
var stream = AsyncFile.OpenRead(path);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
return await JsonSerializer.DeserializeAsync<RootObject>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false);
|
||||
await using var stream = AsyncFile.OpenRead(path);
|
||||
var stream = AsyncFile.OpenRead(path);
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
return await JsonSerializer.DeserializeAsync<SeasonRootObject>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets OMDB URL.</summary>
|
||||
/// <param name="query">Appends query string to URL.</param>
|
||||
|
@ -317,8 +323,11 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|||
imdbParam));
|
||||
|
||||
var rootObject = await _httpClientFactory.CreateClient(NamedClient.Default).GetFromJsonAsync<RootObject>(url, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
await using FileStream jsonFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
FileStream jsonFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
await using (jsonFileStream.ConfigureAwait(false))
|
||||
{
|
||||
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
@ -357,8 +366,11 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|||
seasonId));
|
||||
|
||||
var rootObject = await _httpClientFactory.CreateClient(NamedClient.Default).GetFromJsonAsync<SeasonRootObject>(url, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
await using FileStream jsonFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
FileStream jsonFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
await using (jsonFileStream.ConfigureAwait(false))
|
||||
{
|
||||
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -138,10 +138,16 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(file));
|
||||
await using var response = await httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
await using var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
var response = await httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
await using (response.ConfigureAwait(false))
|
||||
{
|
||||
var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
await using (fileStream.ConfigureAwait(false))
|
||||
{
|
||||
await response.CopyToAsync(fileStream, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
|||
var backdrops = collection.Images.Backdrops;
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count);
|
||||
|
||||
_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages);
|
||||
_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages);
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
|
||||
return remoteImages;
|
||||
}
|
||||
|
|
|
@ -100,9 +100,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
var logos = movie.Images.Logos;
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count + logos.Count);
|
||||
|
||||
_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages);
|
||||
_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages);
|
||||
_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language, remoteImages);
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language));
|
||||
|
||||
return remoteImages;
|
||||
}
|
||||
|
|
|
@ -69,12 +69,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var profiles = personResult.Images.Profiles;
|
||||
var remoteImages = new List<RemoteImageInfo>(profiles.Count);
|
||||
|
||||
_tmdbClientManager.ConvertProfilesToRemoteImageInfo(profiles, language, remoteImages);
|
||||
|
||||
return remoteImages;
|
||||
return _tmdbClientManager.ConvertProfilesToRemoteImageInfo(personResult.Images.Profiles, language);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -89,11 +89,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var remoteImages = new List<RemoteImageInfo>(stills.Count);
|
||||
|
||||
_tmdbClientManager.ConvertStillsToRemoteImageInfo(stills, language, remoteImages);
|
||||
|
||||
return remoteImages;
|
||||
return _tmdbClientManager.ConvertStillsToRemoteImageInfo(stills, language);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -80,11 +80,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count);
|
||||
|
||||
_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages);
|
||||
|
||||
return remoteImages;
|
||||
return _tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -83,9 +83,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
var logos = series.Images.Logos;
|
||||
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count + logos.Count);
|
||||
|
||||
_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages);
|
||||
_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages);
|
||||
_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language, remoteImages);
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language));
|
||||
remoteImages.AddRange(_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language));
|
||||
|
||||
return remoteImages;
|
||||
}
|
||||
|
|
|
@ -531,55 +531,45 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
/// </summary>
|
||||
/// <param name="images">The input images.</param>
|
||||
/// <param name="requestLanguage">The requested language.</param>
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertPostersToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.PosterSize, ImageType.Primary, requestLanguage, results);
|
||||
}
|
||||
/// <returns>The remote images.</returns>
|
||||
public IEnumerable<RemoteImageInfo> ConvertPostersToRemoteImageInfo(IReadOnlyList<ImageData> images, string requestLanguage)
|
||||
=> ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.PosterSize, ImageType.Primary, requestLanguage);
|
||||
|
||||
/// <summary>
|
||||
/// Converts backdrop <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
|
||||
/// </summary>
|
||||
/// <param name="images">The input images.</param>
|
||||
/// <param name="requestLanguage">The requested language.</param>
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertBackdropsToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.BackdropSize, ImageType.Backdrop, requestLanguage, results);
|
||||
}
|
||||
/// <returns>The remote images.</returns>
|
||||
public IEnumerable<RemoteImageInfo> ConvertBackdropsToRemoteImageInfo(IReadOnlyList<ImageData> images, string requestLanguage)
|
||||
=> ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.BackdropSize, ImageType.Backdrop, requestLanguage);
|
||||
|
||||
/// <summary>
|
||||
/// Converts logo <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
|
||||
/// </summary>
|
||||
/// <param name="images">The input images.</param>
|
||||
/// <param name="requestLanguage">The requested language.</param>
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertLogosToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.LogoSize, ImageType.Logo, requestLanguage, results);
|
||||
}
|
||||
/// <returns>The remote images.</returns>
|
||||
public IEnumerable<RemoteImageInfo> ConvertLogosToRemoteImageInfo(IReadOnlyList<ImageData> images, string requestLanguage)
|
||||
=> ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.LogoSize, ImageType.Logo, requestLanguage);
|
||||
|
||||
/// <summary>
|
||||
/// Converts profile <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
|
||||
/// </summary>
|
||||
/// <param name="images">The input images.</param>
|
||||
/// <param name="requestLanguage">The requested language.</param>
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertProfilesToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.ProfileSize, ImageType.Primary, requestLanguage, results);
|
||||
}
|
||||
/// <returns>The remote images.</returns>
|
||||
public IEnumerable<RemoteImageInfo> ConvertProfilesToRemoteImageInfo(IReadOnlyList<ImageData> images, string requestLanguage)
|
||||
=> ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.ProfileSize, ImageType.Primary, requestLanguage);
|
||||
|
||||
/// <summary>
|
||||
/// Converts still <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
|
||||
/// </summary>
|
||||
/// <param name="images">The input images.</param>
|
||||
/// <param name="requestLanguage">The requested language.</param>
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertStillsToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.StillSize, ImageType.Primary, requestLanguage, results);
|
||||
}
|
||||
/// <returns>The remote images.</returns>
|
||||
public IEnumerable<RemoteImageInfo> ConvertStillsToRemoteImageInfo(IReadOnlyList<ImageData> images, string requestLanguage)
|
||||
=> ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.StillSize, ImageType.Primary, requestLanguage);
|
||||
|
||||
/// <summary>
|
||||
/// Converts <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
|
||||
|
@ -588,8 +578,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
/// <param name="size">The size of the image to fetch.</param>
|
||||
/// <param name="type">The type of the image.</param>
|
||||
/// <param name="requestLanguage">The requested language.</param>
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
private void ConvertToRemoteImageInfo(List<ImageData> images, string size, ImageType type, string requestLanguage, List<RemoteImageInfo> results)
|
||||
/// <returns>The remote images.</returns>
|
||||
private IEnumerable<RemoteImageInfo> ConvertToRemoteImageInfo(IReadOnlyList<ImageData> images, string size, ImageType type, string requestLanguage)
|
||||
{
|
||||
// sizes provided are for original resolution, don't store them when downloading scaled images
|
||||
var scaleImage = !string.Equals(size, "original", StringComparison.OrdinalIgnoreCase);
|
||||
|
@ -598,7 +588,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
{
|
||||
var image = images[i];
|
||||
|
||||
results.Add(new RemoteImageInfo
|
||||
yield return new RemoteImageInfo
|
||||
{
|
||||
Url = GetUrl(size, image.FilePath),
|
||||
CommunityRating = image.VoteAverage,
|
||||
|
@ -609,7 +599,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
ProviderName = TmdbUtils.ProviderName,
|
||||
Type = type,
|
||||
RatingType = RatingType.Score
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,10 +188,16 @@ namespace MediaBrowser.Providers.Subtitles
|
|||
{
|
||||
var saveInMediaFolder = libraryOptions.SaveSubtitlesWithMedia;
|
||||
|
||||
await using var stream = response.Stream;
|
||||
await using var memoryStream = new MemoryStream();
|
||||
var memoryStream = new MemoryStream();
|
||||
await using (memoryStream.ConfigureAwait(false))
|
||||
{
|
||||
var stream = response.Stream;
|
||||
await using (stream.ConfigureAwait(false))
|
||||
{
|
||||
await stream.CopyToAsync(memoryStream).ConfigureAwait(false);
|
||||
memoryStream.Position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var savePaths = new List<string>();
|
||||
var saveFileName = Path.GetFileNameWithoutExtension(video.Path) + "." + response.Language.ToLowerInvariant();
|
||||
|
|
Loading…
Reference in New Issue
Block a user