Forráskód Böngészése

Remove conditions that are always true/false

Bond_009 6 éve
szülő
commit
722120af74

+ 1 - 7
Emby.Dlna/Didl/DidlBuilder.cs

@@ -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)
             {

+ 3 - 10
Emby.Drawing/SkiaEncoder.cs

@@ -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());
+                    // decode
+                    codec.GetPixels(bitmap.Info, bitmap.GetPixels());
 
-                        origin = codec.EncodedOrigin;
-                    }
-                    else
-                    {
-                        origin = GetSKEncodedOrigin(orientation);
-                    }
+                    origin = codec.EncodedOrigin;
 
                     return bitmap;
                 }

+ 4 - 1
Emby.Naming/AudioBook/AudioBookResolver.cs

@@ -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

+ 5 - 10
Emby.Server.Implementations/Channels/ChannelManager.cs

@@ -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;
             }

+ 6 - 3
Emby.Server.Implementations/Library/MediaSourceManager.cs

@@ -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);

+ 7 - 33
Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs

@@ -86,12 +86,7 @@ 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;
+                return FindAudio<AudioBook>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
             }
 
             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)
             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);
+                var item = (T)result.Items[0];
+                item.IsInMixedFolder = false;
+                item.Name = Path.GetFileName(item.ContainingFolderPath);
+                return item;
             }
 
             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);
                 }

+ 1 - 1
Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs

@@ -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();

+ 1 - 9
Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs

@@ -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;

+ 15 - 18
Emby.Server.Implementations/Library/UserManager.cs

@@ -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));
             }
 
-            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())
-                {
-                    throw new SecurityException("User is not allowed access at this time.");
-                }
+            if (!user.IsParentalScheduleAllowed())
+            {
+                throw new SecurityException("User is not allowed access at this time.");
             }
 
             // Update LastActivityDate and LastLoginDate, then save
@@ -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));
-                }
+                }*/
             }
         }
 

+ 4 - 4
Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -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)

+ 0 - 6
Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -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)
             {

+ 8 - 13
Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs

@@ -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))
             {
-                if (string.IsNullOrWhiteSpace(videoCodec))
-                {
-                    videoCodec = channelInfo.VideoCodec;
-                }
-                audioCodec = channelInfo.AudioCodec;
+                videoCodec = channelInfo.VideoCodec;
+            }
+            string audioCodec = channelInfo.AudioCodec;
 
-                if (!videoBitrate.HasValue)
-                {
-                    videoBitrate = isHd ? 15000000 : 2000000;
-                }
-                audioBitrate = isHd ? 448000 : 192000;
+            if (!videoBitrate.HasValue)
+            {
+                videoBitrate = isHd ? 15000000 : 2000000;
             }
+            int? audioBitrate = isHd ? 448000 : 192000;
 
             // normalize
             if (string.Equals(videoCodec, "mpeg2", StringComparison.OrdinalIgnoreCase))