From f4765a87cc15efb06331aaeeff3c695be4e77f07 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Aug 2017 15:10:00 -0400 Subject: update m3u tuner --- .../Library/LibraryManager.cs | 12 +- .../LiveTv/TunerHosts/M3UTunerHost.cs | 127 ++++++++++++--------- .../LiveTv/TunerHosts/M3uParser.cs | 18 +-- .../Updates/InstallationManager.cs | 8 +- 4 files changed, 87 insertions(+), 78 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index bf3afd050..1bfc93e79 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -353,7 +353,7 @@ namespace Emby.Server.Implementations.Library } else { - if (item is Photo) + if (!(item is Video)) { return; } @@ -599,18 +599,16 @@ namespace Emby.Server.Implementations.Library // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, _fileSystem, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, _fileSystem, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } // Check to see if we should resolve based on our contents @@ -656,7 +654,7 @@ namespace Emby.Server.Implementations.Library return false; } - public IEnumerable NormalizeRootPathList(IEnumerable paths) + public List NormalizeRootPathList(IEnumerable paths) { var originalList = paths.ToList(); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 2c12f4ca1..1bc334f06 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -25,12 +25,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts private readonly IHttpClient _httpClient; private readonly IServerApplicationHost _appHost; private readonly IEnvironmentInfo _environment; + private readonly INetworkManager _networkManager; - public M3UTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient, IServerApplicationHost appHost, IEnvironmentInfo environment) : base(config, logger, jsonSerializer, mediaEncoder, fileSystem) + public M3UTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient, IServerApplicationHost appHost, IEnvironmentInfo environment, INetworkManager networkManager) : base(config, logger, jsonSerializer, mediaEncoder, fileSystem) { _httpClient = httpClient; _appHost = appHost; _environment = environment; + _networkManager = networkManager; } public override string Type @@ -38,7 +40,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts get { return "m3u"; } } - public string Name + public virtual string Name { get { return "M3U Tuner"; } } @@ -99,72 +101,83 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false); - var m3uchannels = channels.Cast(); - var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); + var channel = channels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); if (channel != null) { - var path = channel.Path; - MediaProtocol protocol = MediaProtocol.File; - if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Http; - } - else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtmp; - } - else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtsp; - } - else if (path.StartsWith("udp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Udp; - } - else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtmp; - } + return new List { CreateMediaSourceInfo(info, channel) }; + } + return new List(); + } + + protected virtual MediaSourceInfo CreateMediaSourceInfo(TunerHostInfo info, ChannelInfo channel) + { + var path = channel.Path; + MediaProtocol protocol = MediaProtocol.File; + if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Http; + } + else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } + else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtsp; + } + else if (path.StartsWith("udp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Udp; + } + else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } + + Uri uri; + var isRemote = true; + if (Uri.TryCreate(path, UriKind.Absolute, out uri)) + { + isRemote = !_networkManager.IsInLocalNetwork(uri.Host); + } - var mediaSource = new MediaSourceInfo + var mediaSource = new MediaSourceInfo + { + Path = path, + Protocol = protocol, + MediaStreams = new List { - Path = channel.Path, - Protocol = protocol, - MediaStreams = new List + new MediaStream { - new MediaStream - { - Type = MediaStreamType.Video, - // Set the index to -1 because we don't know the exact index of the video stream within the container - Index = -1, - IsInterlaced = true - }, - new MediaStream - { - Type = MediaStreamType.Audio, - // Set the index to -1 because we don't know the exact index of the audio stream within the container - Index = -1 - - } + Type = MediaStreamType.Video, + // Set the index to -1 because we don't know the exact index of the video stream within the container + Index = -1, + IsInterlaced = true }, - RequiresOpening = true, - RequiresClosing = true, - RequiresLooping = info.EnableStreamLooping, + new MediaStream + { + Type = MediaStreamType.Audio, + // Set the index to -1 because we don't know the exact index of the audio stream within the container + Index = -1 - ReadAtNativeFramerate = false, + } + }, + RequiresOpening = true, + RequiresClosing = true, + RequiresLooping = info.EnableStreamLooping, - Id = channel.Path.GetMD5().ToString("N"), - IsInfiniteStream = true, - IsRemote = true, + ReadAtNativeFramerate = false, - IgnoreDts = true - }; + Id = channel.Path.GetMD5().ToString("N"), + IsInfiniteStream = true, + IsRemote = isRemote, - mediaSource.InferTotalBitrate(); + IgnoreDts = true + }; - return new List { mediaSource }; - } - return new List(); + mediaSource.InferTotalBitrate(); + + return mediaSource; } protected override Task IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 113e691b6..ca744b615 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts _appHost = appHost; } - public async Task> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken) + public async Task> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken) { // Read the file and display it line by line. using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false))) @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } - public List ParseString(string text, string channelIdPrefix, string tunerHostId) + public List ParseString(string text, string channelIdPrefix, string tunerHostId) { // Read the file and display it line by line. using (var reader = new StringReader(text)) @@ -66,9 +66,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } const string ExtInfPrefix = "#EXTINF:"; - private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId) + private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId) { - var channels = new List(); + var channels = new List(); string line; string extInf = ""; @@ -111,9 +111,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return channels; } - private M3UChannel GetChannelnfo(string extInf, string tunerHostId, string mediaUrl) + private ChannelInfo GetChannelnfo(string extInf, string tunerHostId, string mediaUrl) { - var channel = new M3UChannel(); + var channel = new ChannelInfo(); channel.TunerHostId = tunerHostId; extInf = extInf.Trim(); @@ -335,10 +335,4 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return dict; } } - - - public class M3UChannel : ChannelInfo - { - public string Path { get; set; } - } } \ No newline at end of file diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 6f9c85671..ab1255b57 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -308,9 +308,11 @@ namespace Emby.Server.Implementations.Updates .OrderByDescending(GetPackageVersion).ToArray(); } + IEnumerable packagesList = packages; + if (!string.IsNullOrWhiteSpace(packageType)) { - packages = packages.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)).ToArray(); + packagesList = packagesList.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)); } // If an app version was supplied, filter the versions for each package to only include supported versions @@ -323,7 +325,9 @@ namespace Emby.Server.Implementations.Updates } // Remove packages with no versions - return packages.Where(p => p.versions.Any()).ToArray(); + packagesList = packagesList.Where(p => p.versions.Any()); + + return packagesList.ToArray(); } /// -- cgit v1.2.3 From 2e5db767f349bcbc3ac0b7a24b670ea6c74d84ab Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Aug 2017 17:07:47 -0400 Subject: 3.2.28.2 --- .../Collections/CollectionManager.cs | 23 +++++++++++++++------- .../Updates/InstallationManager.cs | 1 + .../Collections/ICollectionManager.cs | 7 +++++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- SharedVersion.cs | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 18823fa9d..0fc8fdc48 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -149,12 +149,17 @@ namespace Emby.Server.Implementations.Collections return GetCollectionsFolder(string.Empty); } - public Task AddToCollection(Guid collectionId, string[] ids) + public Task AddToCollection(Guid collectionId, IEnumerable ids) { return AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(_fileSystem)); } - private async Task AddToCollection(Guid collectionId, string[] ids, bool fireEvent, MetadataRefreshOptions refreshOptions) + public Task AddToCollection(Guid collectionId, IEnumerable ids) + { + return AddToCollection(collectionId, ids.Select(i => i.ToString("N")), true, new MetadataRefreshOptions(_fileSystem)); + } + + private async Task AddToCollection(Guid collectionId, IEnumerable ids, bool fireEvent, MetadataRefreshOptions refreshOptions) { var collection = _libraryManager.GetItemById(collectionId) as BoxSet; @@ -167,9 +172,9 @@ namespace Emby.Server.Implementations.Collections var itemList = new List(); var currentLinkedChildrenIds = collection.GetLinkedChildren().Select(i => i.Id).ToList(); - foreach (var itemId in ids) + foreach (var id in ids) { - var guidId = new Guid(itemId); + var guidId = new Guid(id); var item = _libraryManager.GetItemById(guidId); if (string.IsNullOrWhiteSpace(item.Path)) @@ -214,7 +219,12 @@ namespace Emby.Server.Implementations.Collections } } - public async Task RemoveFromCollection(Guid collectionId, string[] itemIds) + public Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds) + { + return RemoveFromCollection(collectionId, itemIds.Select(i => new Guid(i))); + } + + public async Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds) { var collection = _libraryManager.GetItemById(collectionId) as BoxSet; @@ -226,9 +236,8 @@ namespace Emby.Server.Implementations.Collections var list = new List(); var itemList = new List(); - foreach (var itemId in itemIds) + foreach (var guidId in itemIds) { - var guidId = new Guid(itemId); var childItem = _libraryManager.GetItemById(guidId); var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == guidId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index ab1255b57..4d1e1eaac 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -290,6 +290,7 @@ namespace Emby.Server.Implementations.Updates protected PackageInfo[] FilterPackages(List packages) { + foreach (var package in packages) { package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) diff --git a/MediaBrowser.Controller/Collections/ICollectionManager.cs b/MediaBrowser.Controller/Collections/ICollectionManager.cs index 0ca7b2e3e..d89843cc0 100644 --- a/MediaBrowser.Controller/Collections/ICollectionManager.cs +++ b/MediaBrowser.Controller/Collections/ICollectionManager.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Collections /// The collection identifier. /// The item ids. /// Task. - Task AddToCollection(Guid collectionId, string[] itemIds); + Task AddToCollection(Guid collectionId, IEnumerable itemIds); /// /// Removes from collection. @@ -44,7 +44,10 @@ namespace MediaBrowser.Controller.Collections /// The collection identifier. /// The item ids. /// Task. - Task RemoveFromCollection(Guid collectionId, string[] itemIds); + Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds); + + Task AddToCollection(Guid collectionId, IEnumerable itemIds); + Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds); /// /// Collapses the items within box sets. diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index a86735bca..e4eff4888 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.735 + 3.0.736 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 3b9c0c83b..f153d3e6b 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.735 + 3.0.736 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + diff --git a/SharedVersion.cs b/SharedVersion.cs index 9e7217a6d..0f504796b 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.1")] +[assembly: AssemblyVersion("3.2.28.2")] -- cgit v1.2.3