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)
{
ImageDownloadInfo imageInfo = null;
// Finally, just use the image from the item
if (imageInfo == null)
{
imageInfo = GetImageInfo(item);
}
ImageDownloadInfo imageInfo = GetImageInfo(item);;
if (imageInfo == null)
{

View File

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

View File

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

View File

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

View File

@ -469,7 +469,7 @@ namespace Emby.Server.Implementations.Library
}
// TODO: Don't hardcode this
var isAudio = false;
const bool isAudio = false;
try
{
@ -480,9 +480,11 @@ namespace Emby.Server.Implementations.Library
else
{
// 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)
@ -491,6 +493,7 @@ namespace Emby.Server.Implementations.Library
AddMediaInfo(mediaSource, isAudio);
}
// TODO: @bond Fix
var json = _jsonSerializer.SerializeToString(mediaSource);
_logger.LogInformation("Live stream opened: " + json);
var clone = _jsonSerializer.DeserializeFromString<MediaSourceInfo>(json);

View File

@ -86,14 +86,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
.ToList();
if (isBooksCollectionType)
{
return FindAudio<AudioBook>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
}
return null;
}
if (LibraryManager.IsAudioFile(args.Path, libraryOptions))
{
var extension = Path.GetExtension(args.Path);
@ -145,37 +140,20 @@ 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)
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
var supportsMultiVersion = false;
const bool supportsMultiVersion = false;
var result = ResolveMultipleAudio<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ??
new MultiItemResolverResult();
if (result.Items.Count == 1)
{
var videoPath = result.Items[0].Path;
// If we were supporting this we'd be checking filesFromOtherItems
var hasOtherItems = false;
if (!hasOtherItems)
{
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;
}
@ -194,11 +172,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{
leftOver.Add(child);
}
else if (IsIgnored(child.Name))
{
}
else
else if (!IsIgnored(child.Name))
{
files.Add(child);
}

View File

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

View File

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

View File

@ -322,8 +322,6 @@ namespace Emby.Server.Implementations.Library
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))
{
throw new SecurityException("Forbidden.");
@ -333,7 +331,6 @@ namespace Emby.Server.Implementations.Library
{
throw new SecurityException("User is not allowed access at this time.");
}
}
// Update LastActivityDate and LastLoginDate, then save
if (success)
@ -463,26 +460,26 @@ namespace Emby.Server.Implementations.Library
{
user.Policy.InvalidLoginAttemptCount = newValue;
var maxCount = user.Policy.IsAdministrator ?
3 :
5;
var maxCount = user.Policy.IsAdministrator ? 3 : 5;
// TODO: Fix
/*
var fireLockout = false;
if (newValue >= maxCount)
{
//_logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue.ToString(CultureInfo.InvariantCulture));
//user.Policy.IsDisabled = true;
_logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue.ToString(CultureInfo.InvariantCulture));
user.Policy.IsDisabled = true;
//fireLockout = true;
}
fireLockout = true;
}*/
UpdateUserPolicy(user, user.Policy, false);
if (fireLockout)
/* if (fireLockout)
{
UserLockedOut?.Invoke(this, new GenericEventArgs<User>(user));
}
}*/
}
}

View File

@ -1133,8 +1133,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
IgnoreIndex = true
};
var isAudio = false;
await new LiveStreamHelper(_mediaEncoder, _logger, _jsonSerializer, _config.CommonApplicationPaths).AddMediaInfoWithProbe(stream, isAudio, false, cancellationToken).ConfigureAwait(false);
await new LiveStreamHelper(_mediaEncoder, _logger, _jsonSerializer, _config.CommonApplicationPaths)
.AddMediaInfoWithProbe(stream, false, false, cancellationToken).ConfigureAwait(false);
return new List<MediaSourceInfo>
{
@ -1149,12 +1149,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public Task RecordLiveStream(string id, CancellationToken cancellationToken)
{
return Task.FromResult(0);
return Task.CompletedTask;
}
public Task ResetTuner(string id, CancellationToken cancellationToken)
{
return Task.FromResult(0);
return Task.CompletedTask;
}
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;
string videoDecoder = null;
if (!string.IsNullOrEmpty(videoDecoder))
{
inputModifier += " " + videoDecoder;
}
if (mediaSource.ReadAtNativeFramerate)
{

View File

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