Don't mix LINQ and roreach loops for readability
This commit is contained in:
parent
594b271383
commit
9993dafe54
|
@ -26,17 +26,17 @@ namespace DvdLib.Ifo
|
||||||
|
|
||||||
if (vmgPath == null)
|
if (vmgPath == null)
|
||||||
{
|
{
|
||||||
var allIfos = allFiles.Where(i => string.Equals(i.Extension, ".ifo", StringComparison.OrdinalIgnoreCase));
|
foreach (var ifo in allFiles)
|
||||||
|
|
||||||
foreach (var ifo in allIfos)
|
|
||||||
{
|
{
|
||||||
var num = ifo.Name.Split('_').ElementAtOrDefault(1);
|
if (!string.Equals(ifo.Extension, ".ifo", StringComparison.OrdinalIgnoreCase))
|
||||||
var numbersRead = new List<ushort>();
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(num) && ushort.TryParse(num, out var ifoNumber) && !numbersRead.Contains(ifoNumber))
|
var nums = ifo.Name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (nums.Length >= 2 && ushort.TryParse(nums[1], out var ifoNumber))
|
||||||
{
|
{
|
||||||
ReadVTS(ifoNumber, ifo.FullName);
|
ReadVTS(ifoNumber, ifo.FullName);
|
||||||
numbersRead.Add(ifoNumber);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace DvdLib.Ifo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadVTS(ushort vtsNum, List<FileSystemMetadata> allFiles)
|
private void ReadVTS(ushort vtsNum, IEnumerable<FileSystemMetadata> allFiles)
|
||||||
{
|
{
|
||||||
var filename = string.Format("VTS_{0:00}_0.IFO", vtsNum);
|
var filename = string.Format("VTS_{0:00}_0.IFO", vtsNum);
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
|
|
||||||
if (item.IsDisplayedAsFolder || serverItem.StubType.HasValue)
|
if (item.IsDisplayedAsFolder || serverItem.StubType.HasValue)
|
||||||
{
|
{
|
||||||
var childrenResult = (GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount));
|
var childrenResult = GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount);
|
||||||
|
|
||||||
_didlBuilder.WriteFolderElement(writer, item, serverItem.StubType, null, childrenResult.TotalRecordCount, filter, id);
|
_didlBuilder.WriteFolderElement(writer, item, serverItem.StubType, null, childrenResult.TotalRecordCount, filter, id);
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var childrenResult = (GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount));
|
var childrenResult = GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount);
|
||||||
totalCount = childrenResult.TotalRecordCount;
|
totalCount = childrenResult.TotalRecordCount;
|
||||||
|
|
||||||
provided = childrenResult.Items.Length;
|
provided = childrenResult.Items.Length;
|
||||||
|
|
|
@ -818,10 +818,9 @@ namespace Emby.Dlna.Didl
|
||||||
{
|
{
|
||||||
AddCommonFields(item, itemStubType, context, writer, filter);
|
AddCommonFields(item, itemStubType, context, writer, filter);
|
||||||
|
|
||||||
var hasArtists = item as IHasArtist;
|
|
||||||
var hasAlbumArtists = item as IHasAlbumArtist;
|
var hasAlbumArtists = item as IHasAlbumArtist;
|
||||||
|
|
||||||
if (hasArtists != null)
|
if (item is IHasArtist hasArtists)
|
||||||
{
|
{
|
||||||
foreach (var artist in hasArtists.Artists)
|
foreach (var artist in hasArtists.Artists)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -15,7 +16,6 @@ using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Reflection;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace Emby.Dlna
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
private readonly IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
private readonly IAssemblyInfo _assemblyInfo;
|
private static readonly Assembly _assembly = typeof(DlnaManager).Assembly;
|
||||||
|
|
||||||
private readonly Dictionary<string, Tuple<InternalProfileInfo, DeviceProfile>> _profiles = new Dictionary<string, Tuple<InternalProfileInfo, DeviceProfile>>(StringComparer.Ordinal);
|
private readonly Dictionary<string, Tuple<InternalProfileInfo, DeviceProfile>> _profiles = new Dictionary<string, Tuple<InternalProfileInfo, DeviceProfile>>(StringComparer.Ordinal);
|
||||||
|
|
||||||
|
@ -39,8 +39,7 @@ namespace Emby.Dlna
|
||||||
IApplicationPaths appPaths,
|
IApplicationPaths appPaths,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IJsonSerializer jsonSerializer,
|
IJsonSerializer jsonSerializer,
|
||||||
IServerApplicationHost appHost,
|
IServerApplicationHost appHost)
|
||||||
IAssemblyInfo assemblyInfo)
|
|
||||||
{
|
{
|
||||||
_xmlSerializer = xmlSerializer;
|
_xmlSerializer = xmlSerializer;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
@ -48,7 +47,6 @@ namespace Emby.Dlna
|
||||||
_logger = loggerFactory.CreateLogger("Dlna");
|
_logger = loggerFactory.CreateLogger("Dlna");
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_assemblyInfo = assemblyInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InitProfilesAsync()
|
public async Task InitProfilesAsync()
|
||||||
|
@ -368,15 +366,18 @@ namespace Emby.Dlna
|
||||||
|
|
||||||
var systemProfilesPath = SystemProfilesPath;
|
var systemProfilesPath = SystemProfilesPath;
|
||||||
|
|
||||||
foreach (var name in _assemblyInfo.GetManifestResourceNames(GetType())
|
foreach (var name in _assembly.GetManifestResourceNames())
|
||||||
.Where(i => i.StartsWith(namespaceName))
|
|
||||||
.ToList())
|
|
||||||
{
|
{
|
||||||
|
if (!name.StartsWith(namespaceName))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var filename = Path.GetFileName(name).Substring(namespaceName.Length);
|
var filename = Path.GetFileName(name).Substring(namespaceName.Length);
|
||||||
|
|
||||||
var path = Path.Combine(systemProfilesPath, filename);
|
var path = Path.Combine(systemProfilesPath, filename);
|
||||||
|
|
||||||
using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), name))
|
using (var stream = _assembly.GetManifestResourceStream(name))
|
||||||
{
|
{
|
||||||
var fileInfo = _fileSystem.GetFileInfo(path);
|
var fileInfo = _fileSystem.GetFileInfo(path);
|
||||||
|
|
||||||
|
@ -514,7 +515,7 @@ namespace Emby.Dlna
|
||||||
return new ImageStream
|
return new ImageStream
|
||||||
{
|
{
|
||||||
Format = format,
|
Format = format,
|
||||||
Stream = _assemblyInfo.GetManifestResourceStream(GetType(), resource)
|
Stream = _assembly.GetManifestResourceStream(resource)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ namespace Emby.Dlna.Main
|
||||||
|
|
||||||
private async Task RegisterServerEndpoints()
|
private async Task RegisterServerEndpoints()
|
||||||
{
|
{
|
||||||
var addresses = (await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false)).ToList();
|
var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
var udn = CreateUuid(_appHost.SystemId);
|
var udn = CreateUuid(_appHost.SystemId);
|
||||||
|
|
||||||
|
|
|
@ -107,12 +107,18 @@ namespace Emby.Dlna.PlayTo
|
||||||
foreach (var arg in action.ArgumentList)
|
foreach (var arg in action.ArgumentList)
|
||||||
{
|
{
|
||||||
if (arg.Direction == "out")
|
if (arg.Direction == "out")
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg.Name == "InstanceID")
|
if (arg.Name == "InstanceID")
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, "0");
|
stateString += BuildArgumentXml(arg, "0");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, null);
|
stateString += BuildArgumentXml(arg, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Format(CommandBase, action.Name, xmlNamespace, stateString);
|
return string.Format(CommandBase, action.Name, xmlNamespace, stateString);
|
||||||
|
@ -125,11 +131,18 @@ namespace Emby.Dlna.PlayTo
|
||||||
foreach (var arg in action.ArgumentList)
|
foreach (var arg in action.ArgumentList)
|
||||||
{
|
{
|
||||||
if (arg.Direction == "out")
|
if (arg.Direction == "out")
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg.Name == "InstanceID")
|
if (arg.Name == "InstanceID")
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, "0");
|
stateString += BuildArgumentXml(arg, "0");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, value.ToString(), commandParameter);
|
stateString += BuildArgumentXml(arg, value.ToString(), commandParameter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
|
return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
|
||||||
|
@ -142,11 +155,17 @@ namespace Emby.Dlna.PlayTo
|
||||||
foreach (var arg in action.ArgumentList)
|
foreach (var arg in action.ArgumentList)
|
||||||
{
|
{
|
||||||
if (arg.Name == "InstanceID")
|
if (arg.Name == "InstanceID")
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, "0");
|
stateString += BuildArgumentXml(arg, "0");
|
||||||
|
}
|
||||||
else if (dictionary.ContainsKey(arg.Name))
|
else if (dictionary.ContainsKey(arg.Name))
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, dictionary[arg.Name]);
|
stateString += BuildArgumentXml(arg, dictionary[arg.Name]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
stateString += BuildArgumentXml(arg, value.ToString());
|
stateString += BuildArgumentXml(arg, value.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
|
return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
|
||||||
|
|
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
|
@ -22,7 +21,9 @@ namespace Emby.Naming.TV
|
||||||
// There were no failed tests without this block, but to be safe, we can keep it until
|
// There were no failed tests without this block, but to be safe, we can keep it until
|
||||||
// the regex which require file extensions are modified so that they don't need them.
|
// the regex which require file extensions are modified so that they don't need them.
|
||||||
if (IsDirectory)
|
if (IsDirectory)
|
||||||
|
{
|
||||||
path += ".mp4";
|
path += ".mp4";
|
||||||
|
}
|
||||||
|
|
||||||
EpisodePathParserResult result = null;
|
EpisodePathParserResult result = null;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ namespace Emby.Naming.TV
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNamed.HasValue)
|
if (isNamed.HasValue)
|
||||||
{
|
{
|
||||||
if (expression.IsNamed != isNamed.Value)
|
if (expression.IsNamed != isNamed.Value)
|
||||||
|
@ -42,6 +44,7 @@ namespace Emby.Naming.TV
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOptimistic.HasValue)
|
if (isOptimistic.HasValue)
|
||||||
{
|
{
|
||||||
if (expression.IsOptimistic != isOptimistic.Value)
|
if (expression.IsOptimistic != isOptimistic.Value)
|
||||||
|
@ -191,13 +194,20 @@ namespace Emby.Naming.TV
|
||||||
|
|
||||||
private void FillAdditional(string path, EpisodePathParserResult info, IEnumerable<EpisodeExpression> expressions)
|
private void FillAdditional(string path, EpisodePathParserResult info, IEnumerable<EpisodeExpression> expressions)
|
||||||
{
|
{
|
||||||
var results = expressions
|
foreach (var i in expressions)
|
||||||
.Where(i => i.IsNamed)
|
|
||||||
.Select(i => Parse(path, i))
|
|
||||||
.Where(i => i.Success);
|
|
||||||
|
|
||||||
foreach (var result in results)
|
|
||||||
{
|
{
|
||||||
|
if (!i.IsNamed)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = Parse(path, i);
|
||||||
|
|
||||||
|
if (!result.Success)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(info.SeriesName))
|
if (string.IsNullOrEmpty(info.SeriesName))
|
||||||
{
|
{
|
||||||
info.SeriesName = result.SeriesName;
|
info.SeriesName = result.SeriesName;
|
||||||
|
@ -208,12 +218,10 @@ namespace Emby.Naming.TV
|
||||||
info.EndingEpsiodeNumber = result.EndingEpsiodeNumber;
|
info.EndingEpsiodeNumber = result.EndingEpsiodeNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.SeriesName))
|
if (!string.IsNullOrEmpty(info.SeriesName)
|
||||||
|
&& (!info.EpisodeNumber.HasValue || info.EndingEpsiodeNumber.HasValue))
|
||||||
{
|
{
|
||||||
if (!info.EpisodeNumber.HasValue || info.EndingEpsiodeNumber.HasValue)
|
break;
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,13 @@ namespace Emby.Server.Implementations.Activity
|
||||||
{
|
{
|
||||||
var result = _repo.GetActivityLogEntries(minDate, hasUserId, startIndex, limit);
|
var result = _repo.GetActivityLogEntries(minDate, hasUserId, startIndex, limit);
|
||||||
|
|
||||||
foreach (var item in result.Items.Where(i => !i.UserId.Equals(Guid.Empty)))
|
foreach (var item in result.Items)
|
||||||
{
|
{
|
||||||
|
if (item.UserId == Guid.Empty)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var user = _userManager.GetUserById(item.UserId);
|
var user = _userManager.GetUserById(item.UserId);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
|
|
|
@ -769,7 +769,7 @@ namespace Emby.Server.Implementations
|
||||||
serviceCollection.AddSingleton(SessionManager);
|
serviceCollection.AddSingleton(SessionManager);
|
||||||
|
|
||||||
serviceCollection.AddSingleton<IDlnaManager>(
|
serviceCollection.AddSingleton<IDlnaManager>(
|
||||||
new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this, assemblyInfo));
|
new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this));
|
||||||
|
|
||||||
CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory, ProviderManager);
|
CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory, ProviderManager);
|
||||||
serviceCollection.AddSingleton(CollectionManager);
|
serviceCollection.AddSingleton(CollectionManager);
|
||||||
|
|
|
@ -243,8 +243,7 @@ namespace Emby.Server.Implementations.Channels
|
||||||
{
|
{
|
||||||
foreach (var item in returnItems)
|
foreach (var item in returnItems)
|
||||||
{
|
{
|
||||||
var task = RefreshLatestChannelItems(GetChannelProvider(item), CancellationToken.None);
|
RefreshLatestChannelItems(GetChannelProvider(item), CancellationToken.None).GetAwaiter().GetResult();
|
||||||
Task.WaitAll(task);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,9 +302,7 @@ namespace Emby.Server.Implementations.Channels
|
||||||
}
|
}
|
||||||
|
|
||||||
numComplete++;
|
numComplete++;
|
||||||
double percent = numComplete;
|
double percent = (double)numComplete / allChannelsList.Count;
|
||||||
percent /= allChannelsList.Count;
|
|
||||||
|
|
||||||
progress.Report(100 * percent);
|
progress.Report(100 * percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,9 +655,7 @@ namespace Emby.Server.Implementations.Channels
|
||||||
|
|
||||||
foreach (var item in result.Items)
|
foreach (var item in result.Items)
|
||||||
{
|
{
|
||||||
var folder = item as Folder;
|
if (item is Folder folder)
|
||||||
|
|
||||||
if (folder != null)
|
|
||||||
{
|
{
|
||||||
await GetChannelItemsInternal(new InternalItemsQuery
|
await GetChannelItemsInternal(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,9 +119,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
list.Add(row[0].ReadGuidFromBlob());
|
list.Add(row[0].ReadGuidFromBlob());
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Logger.LogError(ex, "Error while getting user");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user