Merge pull request #1775 from Bond-009/fixes

Fix multiple mistakes and warnings
This commit is contained in:
Vasily 2019-09-24 19:08:39 +03:00 committed by GitHub
commit ac9dfa8e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 94 additions and 104 deletions

View File

@ -212,7 +212,6 @@ namespace BDInfo
public void Scan() public void Scan()
{ {
var errorStreamClipFiles = new List<TSStreamClipFile>();
foreach (var streamClipFile in StreamClipFiles.Values) foreach (var streamClipFile in StreamClipFiles.Values)
{ {
try try
@ -221,7 +220,6 @@ namespace BDInfo
} }
catch (Exception ex) catch (Exception ex)
{ {
errorStreamClipFiles.Add(streamClipFile);
if (StreamClipFileScanError != null) if (StreamClipFileScanError != null)
{ {
if (StreamClipFileScanError(streamClipFile, ex)) if (StreamClipFileScanError(streamClipFile, ex))
@ -250,7 +248,6 @@ namespace BDInfo
StreamFiles.Values.CopyTo(streamFiles, 0); StreamFiles.Values.CopyTo(streamFiles, 0);
Array.Sort(streamFiles, CompareStreamFiles); Array.Sort(streamFiles, CompareStreamFiles);
var errorPlaylistFiles = new List<TSPlaylistFile>();
foreach (var playlistFile in PlaylistFiles.Values) foreach (var playlistFile in PlaylistFiles.Values)
{ {
try try
@ -259,7 +256,6 @@ namespace BDInfo
} }
catch (Exception ex) catch (Exception ex)
{ {
errorPlaylistFiles.Add(playlistFile);
if (PlaylistFileScanError != null) if (PlaylistFileScanError != null)
{ {
if (PlaylistFileScanError(playlistFile, ex)) if (PlaylistFileScanError(playlistFile, ex))
@ -275,7 +271,6 @@ namespace BDInfo
} }
} }
var errorStreamFiles = new List<TSStreamFile>();
foreach (var streamFile in streamFiles) foreach (var streamFile in streamFiles)
{ {
try try
@ -296,7 +291,6 @@ namespace BDInfo
} }
catch (Exception ex) catch (Exception ex)
{ {
errorStreamFiles.Add(streamFile);
if (StreamFileScanError != null) if (StreamFileScanError != null)
{ {
if (StreamFileScanError(streamFile, ex)) if (StreamFileScanError(streamFile, ex))
@ -431,7 +425,7 @@ namespace BDInfo
{ {
return 1; return 1;
} }
else if ((x != null || x.FileInfo != null) && (y == null || y.FileInfo == null)) else if ((x != null && x.FileInfo != null) && (y == null || y.FileInfo == null))
{ {
return -1; return -1;
} }
@ -451,6 +445,5 @@ namespace BDInfo
} }
} }
} }
} }
} }

View File

@ -218,14 +218,12 @@ namespace Emby.Server.Implementations.Dto
AttachUserSpecificInfo(dto, item, user, options); AttachUserSpecificInfo(dto, item, user, options);
} }
if (item is IHasMediaSources hasMediaSources) if (item is IHasMediaSources
&& options.ContainsField(ItemFields.MediaSources))
{ {
if (options.ContainsField(ItemFields.MediaSources)) dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(item, true, user).ToArray();
{
dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(item, true, user).ToArray();
NormalizeMediaSourceContainers(dto); NormalizeMediaSourceContainers(dto);
}
} }
if (options.ContainsField(ItemFields.Studios)) if (options.ContainsField(ItemFields.Studios))

View File

@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
var user = auth.User; var user = auth.User;
if (user == null & !auth.UserId.Equals(Guid.Empty)) if (user == null && auth.UserId != Guid.Empty)
{ {
throw new SecurityException("User with Id " + auth.UserId + " not found"); throw new SecurityException("User with Id " + auth.UserId + " not found");
} }

View File

@ -57,7 +57,6 @@ namespace Emby.Server.Implementations.Library
} }
var filename = fileInfo.Name; var filename = fileInfo.Name;
var path = fileInfo.FullName;
// Ignore hidden files on UNIX // Ignore hidden files on UNIX
if (Environment.OSVersion.Platform != PlatformID.Win32NT if (Environment.OSVersion.Platform != PlatformID.Win32NT

View File

@ -273,14 +273,12 @@ namespace Emby.Server.Implementations.Library
var user = Users.FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase)); var user = Users.FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
var success = false; var success = false;
string updatedUsername = null;
IAuthenticationProvider authenticationProvider = null; IAuthenticationProvider authenticationProvider = null;
if (user != null) if (user != null)
{ {
var authResult = await AuthenticateLocalUser(username, password, hashedPassword, user, remoteEndPoint).ConfigureAwait(false); var authResult = await AuthenticateLocalUser(username, password, hashedPassword, user, remoteEndPoint).ConfigureAwait(false);
authenticationProvider = authResult.authenticationProvider; authenticationProvider = authResult.authenticationProvider;
updatedUsername = authResult.username;
success = authResult.success; success = authResult.success;
} }
else else
@ -288,7 +286,7 @@ namespace Emby.Server.Implementations.Library
// user is null // user is null
var authResult = await AuthenticateLocalUser(username, password, hashedPassword, null, remoteEndPoint).ConfigureAwait(false); var authResult = await AuthenticateLocalUser(username, password, hashedPassword, null, remoteEndPoint).ConfigureAwait(false);
authenticationProvider = authResult.authenticationProvider; authenticationProvider = authResult.authenticationProvider;
updatedUsername = authResult.username; string updatedUsername = authResult.username;
success = authResult.success; success = authResult.success;
if (success if (success

View File

@ -236,7 +236,7 @@ namespace Emby.Server.Implementations.Library
if (!parentId.Equals(Guid.Empty)) if (!parentId.Equals(Guid.Empty))
{ {
var parentItem = _libraryManager.GetItemById(parentId); var parentItem = _libraryManager.GetItemById(parentId);
if (parentItem is Channel parentItemChannel) if (parentItem is Channel)
{ {
return _channelManager.GetLatestChannelItemsInternal( return _channelManager.GetLatestChannelItemsInternal(
new InternalItemsQuery(user) new InternalItemsQuery(user)
@ -248,7 +248,7 @@ namespace Emby.Server.Implementations.Library
IncludeItemTypes = request.IncludeItemTypes, IncludeItemTypes = request.IncludeItemTypes,
EnableTotalRecordCount = false EnableTotalRecordCount = false
}, },
CancellationToken.None).Result.Items; CancellationToken.None).GetAwaiter().GetResult().Items;
} }
if (parentItem is Folder parent) if (parentItem is Folder parent)

View File

@ -208,9 +208,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private static string GetAudioArgs(MediaSourceInfo mediaSource) private static string GetAudioArgs(MediaSourceInfo mediaSource)
{ {
var mediaStreams = mediaSource.MediaStreams ?? new List<MediaStream>();
var inputAudioCodec = mediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).FirstOrDefault() ?? string.Empty;
return "-codec:a:0 copy"; return "-codec:a:0 copy";
//var audioChannels = 2; //var audioChannels = 2;

View File

@ -17,7 +17,6 @@ using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
namespace Emby.Server.Implementations.LiveTv.Listings namespace Emby.Server.Implementations.LiveTv.Listings
{ {
@ -41,6 +40,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private string UserAgent => _appHost.ApplicationUserAgent; private string UserAgent => _appHost.ApplicationUserAgent;
/// <inheritdoc />
public string Name => "Schedules Direct";
/// <inheritdoc />
public string Type => nameof(SchedulesDirect);
private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc) private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
{ {
var dates = new List<string>(); var dates = new List<string>();
@ -103,7 +108,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
using (var response = await Post(httpOptions, true, info).ConfigureAwait(false)) using (var response = await Post(httpOptions, true, info).ConfigureAwait(false))
using (var reader = new StreamReader(response.Content))
{ {
var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(response.Content).ConfigureAwait(false); var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(response.Content).ConfigureAwait(false);
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId); _logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
@ -122,7 +126,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestContent = "[\"" + string.Join("\", \"", programsID) + "\"]"; httpOptions.RequestContent = "[\"" + string.Join("\", \"", programsID) + "\"]";
using (var innerResponse = await Post(httpOptions, true, info).ConfigureAwait(false)) using (var innerResponse = await Post(httpOptions, true, info).ConfigureAwait(false))
using (var innerReader = new StreamReader(innerResponse.Content))
{ {
var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponse.Content).ConfigureAwait(false); var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponse.Content).ConfigureAwait(false);
var programDict = programDetails.ToDictionary(p => p.programID, y => y); var programDict = programDetails.ToDictionary(p => p.programID, y => y);
@ -152,14 +155,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var imagesWithText = allImages.Where(i => string.Equals(i.text, "yes", StringComparison.OrdinalIgnoreCase)); var imagesWithText = allImages.Where(i => string.Equals(i.text, "yes", StringComparison.OrdinalIgnoreCase));
var imagesWithoutText = allImages.Where(i => string.Equals(i.text, "no", StringComparison.OrdinalIgnoreCase)); var imagesWithoutText = allImages.Where(i => string.Equals(i.text, "no", StringComparison.OrdinalIgnoreCase));
const double desiredAspect = 0.666666667; const double DesiredAspect = 2.0 / 3;
programEntry.primaryImage = GetProgramImage(ApiUrl, imagesWithText, true, desiredAspect) ?? programEntry.primaryImage = GetProgramImage(ApiUrl, imagesWithText, true, DesiredAspect) ??
GetProgramImage(ApiUrl, allImages, true, desiredAspect); GetProgramImage(ApiUrl, allImages, true, DesiredAspect);
const double wideAspect = 1.77777778; const double WideAspect = 16.0 / 9;
programEntry.thumbImage = GetProgramImage(ApiUrl, imagesWithText, true, wideAspect); programEntry.thumbImage = GetProgramImage(ApiUrl, imagesWithText, true, WideAspect);
// Don't supply the same image twice // Don't supply the same image twice
if (string.Equals(programEntry.primaryImage, programEntry.thumbImage, StringComparison.Ordinal)) if (string.Equals(programEntry.primaryImage, programEntry.thumbImage, StringComparison.Ordinal))
@ -167,7 +170,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
programEntry.thumbImage = null; programEntry.thumbImage = null;
} }
programEntry.backdropImage = GetProgramImage(ApiUrl, imagesWithoutText, true, wideAspect); programEntry.backdropImage = GetProgramImage(ApiUrl, imagesWithoutText, true, WideAspect);
//programEntry.bannerImage = GetProgramImage(ApiUrl, data, "Banner", false) ?? //programEntry.bannerImage = GetProgramImage(ApiUrl, data, "Banner", false) ??
// GetProgramImage(ApiUrl, data, "Banner-L1", false) ?? // GetProgramImage(ApiUrl, data, "Banner-L1", false) ??
@ -178,6 +181,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
programsInfo.Add(GetProgram(channelId, schedule, programDict[schedule.programID])); programsInfo.Add(GetProgram(channelId, schedule, programDict[schedule.programID]));
} }
return programsInfo; return programsInfo;
} }
} }
@ -185,12 +189,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private static int GetSizeOrder(ScheduleDirect.ImageData image) private static int GetSizeOrder(ScheduleDirect.ImageData image)
{ {
if (!string.IsNullOrWhiteSpace(image.height)) if (!string.IsNullOrWhiteSpace(image.height)
&& int.TryParse(image.height, out int value))
{ {
if (int.TryParse(image.height, out int value)) return value;
{
return value;
}
} }
return 0; return 0;
@ -736,16 +738,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
using (var response = await _httpClient.SendAsync(httpOptions, "PUT")) using (await _httpClient.SendAsync(httpOptions, "PUT"))
{ {
} }
} }
public string Name => "Schedules Direct";
public static string TypeName = "SchedulesDirect";
public string Type => TypeName;
private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken) private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(info.ListingsId)) if (string.IsNullOrEmpty(info.ListingsId))

View File

@ -60,16 +60,6 @@ namespace Emby.Server.Implementations.LiveTv
private IListingsProvider[] _listingProviders = Array.Empty<IListingsProvider>(); private IListingsProvider[] _listingProviders = Array.Empty<IListingsProvider>();
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCancelled;
public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;
public string GetEmbyTvActiveRecordingPath(string id)
{
return EmbyTV.EmbyTV.Current.GetActiveRecordingPath(id);
}
public LiveTvManager( public LiveTvManager(
IServerApplicationHost appHost, IServerApplicationHost appHost,
IServerConfigurationManager config, IServerConfigurationManager config,
@ -102,17 +92,34 @@ namespace Emby.Server.Implementations.LiveTv
_tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, loggerFactory, appHost, _libraryManager); _tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, loggerFactory, appHost, _libraryManager);
} }
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCancelled;
public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;
/// <summary> /// <summary>
/// Gets the services. /// Gets the services.
/// </summary> /// </summary>
/// <value>The services.</value> /// <value>The services.</value>
public IReadOnlyList<ILiveTvService> Services => _services; public IReadOnlyList<ILiveTvService> Services => _services;
public ITunerHost[] TunerHosts => _tunerHosts;
public IListingsProvider[] ListingProviders => _listingProviders;
private LiveTvOptions GetConfiguration() private LiveTvOptions GetConfiguration()
{ {
return _config.GetConfiguration<LiveTvOptions>("livetv"); return _config.GetConfiguration<LiveTvOptions>("livetv");
} }
public string GetEmbyTvActiveRecordingPath(string id)
{
return EmbyTV.EmbyTV.Current.GetActiveRecordingPath(id);
}
/// <summary> /// <summary>
/// Adds the parts. /// Adds the parts.
/// </summary> /// </summary>
@ -130,13 +137,13 @@ namespace Emby.Server.Implementations.LiveTv
{ {
if (service is EmbyTV.EmbyTV embyTv) if (service is EmbyTV.EmbyTV embyTv)
{ {
embyTv.TimerCreated += EmbyTv_TimerCreated; embyTv.TimerCreated += OnEmbyTvTimerCreated;
embyTv.TimerCancelled += EmbyTv_TimerCancelled; embyTv.TimerCancelled += OnEmbyTvTimerCancelled;
} }
} }
} }
private void EmbyTv_TimerCancelled(object sender, GenericEventArgs<string> e) private void OnEmbyTvTimerCancelled(object sender, GenericEventArgs<string> e)
{ {
var timerId = e.Argument; var timerId = e.Argument;
@ -149,10 +156,9 @@ namespace Emby.Server.Implementations.LiveTv
}); });
} }
private void EmbyTv_TimerCreated(object sender, GenericEventArgs<TimerInfo> e) private void OnEmbyTvTimerCreated(object sender, GenericEventArgs<TimerInfo> e)
{ {
var timer = e.Argument; var timer = e.Argument;
var service = sender as ILiveTvService;
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo> TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
{ {
@ -164,10 +170,6 @@ namespace Emby.Server.Implementations.LiveTv
}); });
} }
public ITunerHost[] TunerHosts => _tunerHosts;
public IListingsProvider[] ListingProviders => _listingProviders;
public List<NameIdPair> GetTunerHostTypes() public List<NameIdPair> GetTunerHostTypes()
{ {
return _tunerHosts.OrderBy(i => i.Name).Select(i => new NameIdPair return _tunerHosts.OrderBy(i => i.Name).Select(i => new NameIdPair
@ -966,9 +968,6 @@ namespace Emby.Server.Implementations.LiveTv
private async Task AddRecordingInfo(IEnumerable<Tuple<BaseItemDto, string, string>> programs, CancellationToken cancellationToken) private async Task AddRecordingInfo(IEnumerable<Tuple<BaseItemDto, string, string>> programs, CancellationToken cancellationToken)
{ {
var timers = new Dictionary<string, List<TimerInfo>>();
var seriesTimers = new Dictionary<string, List<SeriesTimerInfo>>();
IReadOnlyList<TimerInfo> timerList = null; IReadOnlyList<TimerInfo> timerList = null;
IReadOnlyList<SeriesTimerInfo> seriesTimerList = null; IReadOnlyList<SeriesTimerInfo> seriesTimerList = null;
@ -1601,8 +1600,6 @@ namespace Emby.Server.Implementations.LiveTv
if (!string.IsNullOrEmpty(query.Id)) if (!string.IsNullOrEmpty(query.Id))
{ {
var guid = new Guid(query.Id);
timers = timers timers = timers
.Where(i => string.Equals(_tvDtoService.GetInternalTimerId(i.Item1.Id), query.Id, StringComparison.OrdinalIgnoreCase)); .Where(i => string.Equals(_tvDtoService.GetInternalTimerId(i.Item1.Id), query.Id, StringComparison.OrdinalIgnoreCase));
} }

View File

@ -424,14 +424,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return false; return false;
} }
var nameTag = buf[offset++]; offset++; // Name Tag
var nameLength = buf[offset++]; var nameLength = buf[offset++];
// skip the name field to get to value for return // skip the name field to get to value for return
offset += nameLength; offset += nameLength;
var valueTag = buf[offset++]; offset++; // Value Tag
var valueLength = buf[offset++]; var valueLength = buf[offset++];

View File

@ -15,7 +15,7 @@ namespace Emby.Server.Implementations.Services
{ {
PropertySetFn = propertySetFn; PropertySetFn = propertySetFn;
PropertyParseStringFn = propertyParseStringFn; PropertyParseStringFn = propertyParseStringFn;
PropertyType = PropertyType; PropertyType = propertyType;
} }
public Action<object, object> PropertySetFn { get; private set; } public Action<object, object> PropertySetFn { get; private set; }

View File

@ -22,7 +22,7 @@
<EmbeddedResource Include="Resources/Configuration/*" /> <EmbeddedResource Include="Resources/Configuration/*" />
</ItemGroup> </ItemGroup>
<!-- Code analysers--> <!-- Code analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />

View File

@ -455,9 +455,7 @@ namespace MediaBrowser.Api.UserLibrary
IncludeItemTypes = new[] { typeof(MusicAlbum).Name }, IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
Name = i, Name = i,
Limit = 1 Limit = 1
});
}).Select(albumId => albumId);
}).ToArray(); }).ToArray();
} }

View File

@ -14,20 +14,20 @@ namespace MediaBrowser.Common.Extensions
/// Strips the HTML. /// Strips the HTML.
/// </summary> /// </summary>
/// <param name="htmlString">The HTML string.</param> /// <param name="htmlString">The HTML string.</param>
/// <returns>System.String.</returns> /// <returns><see cref="string" />.</returns>
public static string StripHtml(this string htmlString) public static string StripHtml(this string htmlString)
{ {
// http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
const string pattern = @"<(.|\n)*?>"; const string Pattern = @"<(.|\n)*?>";
return Regex.Replace(htmlString, pattern, string.Empty).Trim(); return Regex.Replace(htmlString, Pattern, string.Empty).Trim();
} }
/// <summary> /// <summary>
/// Gets the M d5. /// Gets the Md5.
/// </summary> /// </summary>
/// <param name="str">The STR.</param> /// <param name="str">The string.</param>
/// <returns>Guid.</returns> /// <returns><see cref="Guid" />.</returns>
public static Guid GetMD5(this string str) public static Guid GetMD5(this string str)
{ {
using (var provider = MD5.Create()) using (var provider = MD5.Create())

View File

@ -5,13 +5,28 @@ namespace MediaBrowser.Common.Extensions
// The MS CollectionExtensions are only available in netcoreapp // The MS CollectionExtensions are only available in netcoreapp
public static class CollectionExtensions public static class CollectionExtensions
{ {
public static TValue GetValueOrDefault<TKey, TValue> (this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
{ {
dictionary.TryGetValue(key, out var ret); dictionary.TryGetValue(key, out var ret);
return ret; return ret;
} }
// REVIEW: Inline? /// <summary>
/// Copies all the elements of the current collection to the specified list
/// starting at the specified destination array index. The index is specified as a 32-bit integer.
/// </summary>
/// <param name="source">The current collection that is the source of the elements.</param>
/// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
/// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
/// <typeparam name="T"></typeparam>
public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0)
{
for (int i = 0; i < source.Count; i++)
{
destination[index + i] = source[i];
}
}
/// <summary> /// <summary>
/// Copies all the elements of the current collection to the specified list /// Copies all the elements of the current collection to the specified list
/// starting at the specified destination array index. The index is specified as a 32-bit integer. /// starting at the specified destination array index. The index is specified as a 32-bit integer.

View File

@ -2045,7 +2045,7 @@ namespace MediaBrowser.Controller.Entities
if (itemByPath == null) if (itemByPath == null)
{ {
//Logger.LogWarning("Unable to find linked item at path {0}", info.Path); Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
} }
return itemByPath; return itemByPath;
@ -2057,7 +2057,7 @@ namespace MediaBrowser.Controller.Entities
if (item == null) if (item == null)
{ {
//Logger.LogWarning("Unable to find linked item at path {0}", info.Path); Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
} }
return item; return item;
@ -2085,14 +2085,17 @@ namespace MediaBrowser.Controller.Entities
if (!current.Contains(name, StringComparer.OrdinalIgnoreCase)) if (!current.Contains(name, StringComparer.OrdinalIgnoreCase))
{ {
if (current.Length == 0) int curLen = current.Length;
if (curLen == 0)
{ {
Studios = new[] { name }; Studios = new[] { name };
} }
else else
{ {
var list = var newArr = new string[curLen + 1];
Studios = current.Concat(new[] { name }).ToArray(); current.CopyTo(newArr, 0);
newArr[curLen] = name;
Studios = newArr;
} }
} }
} }
@ -2231,8 +2234,12 @@ namespace MediaBrowser.Controller.Entities
else else
{ {
var currentCount = ImageInfos.Length; var current = ImageInfos;
ImageInfos = ImageInfos.Concat(new[] { image }).ToArray(); var currentCount = current.Length;
var newArr = new ItemImageInfo[currentCount + 1];
current.CopyTo(newArr, 0);
current[currentCount] = image;
ImageInfos = current;
} }
} }

View File

@ -1252,9 +1252,6 @@ namespace MediaBrowser.Controller.MediaEncoding
{ {
if (request.AudioBitRate.HasValue) if (request.AudioBitRate.HasValue)
{ {
// Make sure we don't request a bitrate higher than the source
var currentBitrate = audioStream == null ? request.AudioBitRate.Value : audioStream.BitRate ?? request.AudioBitRate.Value;
// Don't encode any higher than this // Don't encode any higher than this
return Math.Min(384000, request.AudioBitRate.Value); return Math.Min(384000, request.AudioBitRate.Value);
} }

View File

@ -158,8 +158,6 @@ namespace MediaBrowser.LocalMetadata.Savers
/// <returns>Task.</returns> /// <returns>Task.</returns>
public static void AddCommonNodes(BaseItem item, XmlWriter writer, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepo, IFileSystem fileSystem, IServerConfigurationManager config) public static void AddCommonNodes(BaseItem item, XmlWriter writer, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepo, IFileSystem fileSystem, IServerConfigurationManager config)
{ {
var writtenProviderIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
if (!string.IsNullOrEmpty(item.OfficialRating)) if (!string.IsNullOrEmpty(item.OfficialRating))
{ {
writer.WriteElementString("ContentRating", item.OfficialRating); writer.WriteElementString("ContentRating", item.OfficialRating);

View File

@ -506,12 +506,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
if (failed) if (failed)
{ {
var msg = string.Format("ffmpeg subtitle conversion failed for {Path}", inputPath); _logger.LogError("ffmpeg subtitle conversion failed for {Path}", inputPath);
_logger.LogError(msg); throw new Exception(
string.Format(CultureInfo.InvariantCulture, "ffmpeg subtitle conversion failed for {0}", inputPath));
throw new Exception(msg);
} }
await SetAssFont(outputPath).ConfigureAwait(false); await SetAssFont(outputPath).ConfigureAwait(false);
_logger.LogInformation("ffmpeg subtitle conversion succeeded for {Path}", inputPath); _logger.LogInformation("ffmpeg subtitle conversion succeeded for {Path}", inputPath);

View File

@ -31,7 +31,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
/// <inheritdoc /> /// <inheritdoc />
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType) public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
=> !item.SupportsLocalMetadata && item is Episode && updateType >= MinimumUpdateType; => item.SupportsLocalMetadata && item is Episode && updateType >= MinimumUpdateType;
/// <inheritdoc /> /// <inheritdoc />
protected override void WriteCustomElements(BaseItem item, XmlWriter writer) protected override void WriteCustomElements(BaseItem item, XmlWriter writer)

View File

@ -86,7 +86,6 @@ namespace Rssdp.Infrastructure
ThrowIfDisposed(); ThrowIfDisposed();
var minCacheTime = TimeSpan.Zero;
bool wasAdded = false; bool wasAdded = false;
lock (_Devices) lock (_Devices)
{ {
@ -94,7 +93,6 @@ namespace Rssdp.Infrastructure
{ {
_Devices.Add(device); _Devices.Add(device);
wasAdded = true; wasAdded = true;
minCacheTime = GetMinimumNonZeroCacheLifetime();
} }
} }
@ -120,14 +118,12 @@ namespace Rssdp.Infrastructure
if (device == null) throw new ArgumentNullException(nameof(device)); if (device == null) throw new ArgumentNullException(nameof(device));
bool wasRemoved = false; bool wasRemoved = false;
var minCacheTime = TimeSpan.Zero;
lock (_Devices) lock (_Devices)
{ {
if (_Devices.Contains(device)) if (_Devices.Contains(device))
{ {
_Devices.Remove(device); _Devices.Remove(device);
wasRemoved = true; wasRemoved = true;
minCacheTime = GetMinimumNonZeroCacheLifetime();
} }
} }