Remove conditions that are always true/false

This commit is contained in:
Bond_009 2019-01-21 20:18:52 +01:00
parent edcfd8b565
commit 722120af74
12 changed files with 56 additions and 116 deletions

View file

@ -932,13 +932,7 @@ namespace Emby.Dlna.Didl
private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlWriter writer) private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlWriter writer)
{ {
ImageDownloadInfo imageInfo = null; ImageDownloadInfo imageInfo = GetImageInfo(item);;
// Finally, just use the image from the item
if (imageInfo == null)
{
imageInfo = GetImageInfo(item);
}
if (imageInfo == null) if (imageInfo == null)
{ {

View file

@ -270,17 +270,10 @@ namespace Emby.Drawing
// create the bitmap // create the bitmap
var bitmap = new SKBitmap(codec.Info.Width, codec.Info.Height, !requiresTransparencyHack); var bitmap = new SKBitmap(codec.Info.Width, codec.Info.Height, !requiresTransparencyHack);
if (bitmap != null) // decode
{ codec.GetPixels(bitmap.Info, bitmap.GetPixels());
// decode
codec.GetPixels(bitmap.Info, bitmap.GetPixels());
origin = codec.EncodedOrigin; origin = codec.EncodedOrigin;
}
else
{
origin = GetSKEncodedOrigin(orientation);
}
return bitmap; return bitmap;
} }

View file

@ -30,8 +30,11 @@ namespace Emby.Naming.AudioBook
{ {
throw new ArgumentNullException(nameof(path)); throw new ArgumentNullException(nameof(path));
} }
if (IsDirectory)
if (IsDirectory) // TODO
{
return null; return null;
}
var extension = Path.GetExtension(path) ?? string.Empty; var extension = Path.GetExtension(path) ?? string.Empty;
// Check supported extensions // Check supported extensions

View file

@ -681,22 +681,17 @@ namespace Emby.Server.Implementations.Channels
// Find the corresponding channel provider plugin // Find the corresponding channel provider plugin
var channelProvider = GetChannelProvider(channel); var channelProvider = GetChannelProvider(channel);
var user = query.User; var parentItem = query.ParentId == Guid.Empty ? channel : _libraryManager.GetItemById(query.ParentId);
ChannelItemSortField? sortField = null;
var sortDescending = false;
var parentItem = !query.ParentId.Equals(Guid.Empty) ? _libraryManager.GetItemById(query.ParentId) : channel;
var itemsResult = await GetChannelItems(channelProvider, var itemsResult = await GetChannelItems(channelProvider,
user, query.User,
parentItem is Channel ? null : parentItem.ExternalId, parentItem is Channel ? null : parentItem.ExternalId,
sortField, null,
sortDescending, false,
cancellationToken) cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
if (query.ParentId.Equals(Guid.Empty)) if (query.ParentId == Guid.Empty)
{ {
query.Parent = channel; query.Parent = channel;
} }

View file

@ -469,7 +469,7 @@ namespace Emby.Server.Implementations.Library
} }
// TODO: Don't hardcode this // TODO: Don't hardcode this
var isAudio = false; const bool isAudio = false;
try try
{ {
@ -480,9 +480,11 @@ namespace Emby.Server.Implementations.Library
else else
{ {
// hack - these two values were taken from LiveTVMediaSourceProvider // hack - these two values were taken from LiveTVMediaSourceProvider
var cacheKey = request.OpenToken; string cacheKey = request.OpenToken;
await new LiveStreamHelper(_mediaEncoder(), _logger, _jsonSerializer, _appPaths).AddMediaInfoWithProbe(mediaSource, isAudio, cacheKey, true, cancellationToken).ConfigureAwait(false); await new LiveStreamHelper(_mediaEncoder(), _logger, _jsonSerializer, _appPaths)
.AddMediaInfoWithProbe(mediaSource, isAudio, cacheKey, true, cancellationToken)
.ConfigureAwait(false);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -491,6 +493,7 @@ namespace Emby.Server.Implementations.Library
AddMediaInfo(mediaSource, isAudio); AddMediaInfo(mediaSource, isAudio);
} }
// TODO: @bond Fix
var json = _jsonSerializer.SerializeToString(mediaSource); var json = _jsonSerializer.SerializeToString(mediaSource);
_logger.LogInformation("Live stream opened: " + json); _logger.LogInformation("Live stream opened: " + json);
var clone = _jsonSerializer.DeserializeFromString<MediaSourceInfo>(json); var clone = _jsonSerializer.DeserializeFromString<MediaSourceInfo>(json);

View file

@ -86,12 +86,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent)) .Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
.ToList(); .ToList();
if (isBooksCollectionType) return FindAudio<AudioBook>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
{
return FindAudio<AudioBook>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
}
return null;
} }
if (LibraryManager.IsAudioFile(args.Path, libraryOptions)) if (LibraryManager.IsAudioFile(args.Path, libraryOptions))
@ -145,36 +140,19 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
private T FindAudio<T>(ItemResolveArgs args, string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool parseName) private T FindAudio<T>(ItemResolveArgs args, string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool parseName)
where T : MediaBrowser.Controller.Entities.Audio.Audio, new() where T : MediaBrowser.Controller.Entities.Audio.Audio, new()
{ {
var multiDiscFolders = new List<FileSystemMetadata>();
var libraryOptions = args.GetLibraryOptions();
var filesFromOtherItems = new List<FileSystemMetadata>();
// TODO: Allow GetMultiDiscMovie in here // TODO: Allow GetMultiDiscMovie in here
var supportsMultiVersion = false; const bool supportsMultiVersion = false;
var result = ResolveMultipleAudio<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ?? var result = ResolveMultipleAudio<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ??
new MultiItemResolverResult(); new MultiItemResolverResult();
if (result.Items.Count == 1) if (result.Items.Count == 1)
{ {
var videoPath = result.Items[0].Path;
// If we were supporting this we'd be checking filesFromOtherItems // If we were supporting this we'd be checking filesFromOtherItems
var hasOtherItems = false; var item = (T)result.Items[0];
item.IsInMixedFolder = false;
if (!hasOtherItems) item.Name = Path.GetFileName(item.ContainingFolderPath);
{ return item;
var item = (T)result.Items[0];
item.IsInMixedFolder = false;
item.Name = Path.GetFileName(item.ContainingFolderPath);
return item;
}
}
if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
{
//return GetMultiDiscAudio<T>(multiDiscFolders, directoryService);
} }
return null; return null;
@ -194,11 +172,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{ {
leftOver.Add(child); leftOver.Add(child);
} }
else if (IsIgnored(child.Name)) else if (!IsIgnored(child.Name))
{
}
else
{ {
files.Add(child); files.Add(child);
} }

View file

@ -410,7 +410,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
} }
// TODO: Allow GetMultiDiscMovie in here // TODO: Allow GetMultiDiscMovie in here
var supportsMultiVersion = true; const bool supportsMultiVersion = true;
var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ?? var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ??
new MultiItemResolverResult(); new MultiItemResolverResult();

View file

@ -153,16 +153,8 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var namingOptions = ((LibraryManager)libraryManager).GetNamingOptions(); var namingOptions = ((LibraryManager)libraryManager).GetNamingOptions();
var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions); var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions);
bool? isNamed = null;
bool? isOptimistic = null;
if (!isTvContentType) var episodeInfo = episodeResolver.Resolve(fullName, false, true, false, fillExtendedInfo: false);
{
isNamed = true;
isOptimistic = false;
}
var episodeInfo = episodeResolver.Resolve(fullName, false, isNamed, isOptimistic, fillExtendedInfo: false);
if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue) if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)
{ {
return true; return true;

View file

@ -322,17 +322,14 @@ namespace Emby.Server.Implementations.Library
throw new SecurityException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name)); throw new SecurityException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name));
} }
if (user != null) if (!user.Policy.EnableRemoteAccess && !_networkManager.IsInLocalNetwork(remoteEndPoint))
{ {
if (!user.Policy.EnableRemoteAccess && !_networkManager.IsInLocalNetwork(remoteEndPoint)) throw new SecurityException("Forbidden.");
{ }
throw new SecurityException("Forbidden.");
}
if (!user.IsParentalScheduleAllowed()) if (!user.IsParentalScheduleAllowed())
{ {
throw new SecurityException("User is not allowed access at this time."); throw new SecurityException("User is not allowed access at this time.");
}
} }
// Update LastActivityDate and LastLoginDate, then save // Update LastActivityDate and LastLoginDate, then save
@ -463,26 +460,26 @@ namespace Emby.Server.Implementations.Library
{ {
user.Policy.InvalidLoginAttemptCount = newValue; user.Policy.InvalidLoginAttemptCount = newValue;
var maxCount = user.Policy.IsAdministrator ? var maxCount = user.Policy.IsAdministrator ? 3 : 5;
3 :
5;
// TODO: Fix
/*
var fireLockout = false; var fireLockout = false;
if (newValue >= maxCount) if (newValue >= maxCount)
{ {
//_logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue.ToString(CultureInfo.InvariantCulture)); _logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue.ToString(CultureInfo.InvariantCulture));
//user.Policy.IsDisabled = true; user.Policy.IsDisabled = true;
//fireLockout = true; fireLockout = true;
} }*/
UpdateUserPolicy(user, user.Policy, false); UpdateUserPolicy(user, user.Policy, false);
if (fireLockout) /* if (fireLockout)
{ {
UserLockedOut?.Invoke(this, new GenericEventArgs<User>(user)); UserLockedOut?.Invoke(this, new GenericEventArgs<User>(user));
} }*/
} }
} }

View file

@ -1133,8 +1133,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
IgnoreIndex = true IgnoreIndex = true
}; };
var isAudio = false; await new LiveStreamHelper(_mediaEncoder, _logger, _jsonSerializer, _config.CommonApplicationPaths)
await new LiveStreamHelper(_mediaEncoder, _logger, _jsonSerializer, _config.CommonApplicationPaths).AddMediaInfoWithProbe(stream, isAudio, false, cancellationToken).ConfigureAwait(false); .AddMediaInfoWithProbe(stream, false, false, cancellationToken).ConfigureAwait(false);
return new List<MediaSourceInfo> return new List<MediaSourceInfo>
{ {
@ -1149,12 +1149,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public Task RecordLiveStream(string id, CancellationToken cancellationToken) public Task RecordLiveStream(string id, CancellationToken cancellationToken)
{ {
return Task.FromResult(0); return Task.CompletedTask;
} }
public Task ResetTuner(string id, CancellationToken cancellationToken) public Task ResetTuner(string id, CancellationToken cancellationToken)
{ {
return Task.FromResult(0); return Task.CompletedTask;
} }
async void _timerProvider_TimerFired(object sender, GenericEventArgs<TimerInfo> e) async void _timerProvider_TimerFired(object sender, GenericEventArgs<TimerInfo> e)

View file

@ -175,12 +175,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
var videoStream = mediaSource.VideoStream; var videoStream = mediaSource.VideoStream;
string videoDecoder = null;
if (!string.IsNullOrEmpty(videoDecoder))
{
inputModifier += " " + videoDecoder;
}
if (mediaSource.ReadAtNativeFramerate) if (mediaSource.ReadAtNativeFramerate)
{ {

View file

@ -354,10 +354,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
int? height = null; int? height = null;
bool isInterlaced = true; bool isInterlaced = true;
string videoCodec = null; string videoCodec = null;
string audioCodec = null;
int? videoBitrate = null; int? videoBitrate = null;
int? audioBitrate = null;
var isHd = channelInfo.IsHD ?? true; var isHd = channelInfo.IsHD ?? true;
@ -427,20 +425,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
} }
} }
if (channelInfo != null) if (string.IsNullOrWhiteSpace(videoCodec))
{ {
if (string.IsNullOrWhiteSpace(videoCodec)) videoCodec = channelInfo.VideoCodec;
{
videoCodec = channelInfo.VideoCodec;
}
audioCodec = channelInfo.AudioCodec;
if (!videoBitrate.HasValue)
{
videoBitrate = isHd ? 15000000 : 2000000;
}
audioBitrate = isHd ? 448000 : 192000;
} }
string audioCodec = channelInfo.AudioCodec;
if (!videoBitrate.HasValue)
{
videoBitrate = isHd ? 15000000 : 2000000;
}
int? audioBitrate = isHd ? 448000 : 192000;
// normalize // normalize
if (string.Equals(videoCodec, "mpeg2", StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoCodec, "mpeg2", StringComparison.OrdinalIgnoreCase))