The Free Software Media System - Server Backend & API
key m3u based on tvgid
Luke Pulverentia3b9d33248c9
diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.csindex 72b9d55eb1..3fe20f6596 100644--- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs+++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs@@ -20,10 +20,13 @@ namespace Emby.Common.Implementations.IOprivate readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();private bool EnableFileSystemRequestConcat = true;- public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, bool enableFileSystemRequestConcat)+ private string _tempPath;++ public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, bool enableFileSystemRequestConcat, string tempPath){Logger = logger;_supportsAsyncFileStreams = supportsAsyncFileStreams;+ _tempPath = tempPath;EnableFileSystemRequestConcat = enableFileSystemRequestConcat;SetInvalidFileNameChars(enableManagedInvalidFileNameChars);}@@ -487,12 +490,13 @@ namespace Emby.Common.Implementations.IOthrow new ArgumentNullException("file2");}- var temp1 = Path.GetTempFileName();+ var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N"));// Copying over will fail against hidden filesSetHidden(file1, false);SetHidden(file2, false);+ Directory.CreateDirectory(_tempPath);CopyFile(file1, temp1, true);CopyFile(file2, file1, true);@@ -674,21 +678,7 @@ namespace Emby.Common.Implementations.IOprivate IEnumerable<FileSystemMetadata> ToMetadata(string parentPath, IEnumerable<FileSystemInfo> infos){- return infos.Select(i =>- {- try- {- return GetFileSystemMetadata(i);- }- catch (PathTooLongException)- {- // Can't log using the FullName because it will throw the PathTooLongExceptiona again- //Logger.Warn("Path too long: {0}", i.FullName);- Logger.Warn("File or directory path too long. Parent folder: {0}", parentPath);- return null;- }-- }).Where(i => i != null);+ return infos.Select(GetFileSystemMetadata);}public string[] ReadAllLines(string path)diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.csindex f2e48fbc0f..336469c500 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs@@ -104,7 +104,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun{Type = HdHomerunHost.DeviceType,Url = url,- DataVersion = 1,DeviceId = response.DeviceID}).ConfigureAwait(false);diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.csindex 485596050a..1c7c0828c3 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs@@ -61,10 +61,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun{var id = ChannelIdPrefix + i.GuideNumber;- if (info.DataVersion >= 1)- {- id += '_' + (i.GuideName ?? string.Empty).GetMD5().ToString("N");- }+ id += '_' + (i.GuideName ?? string.Empty).GetMD5().ToString("N");return id;}diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.csindex 352f4fe958..cfcf51d46f 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs@@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHostsprotected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken){- return await new M3uParser(Logger, _fileSystem, _httpClient, _appHost).Parse(info.Url, ChannelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);+ return await new M3uParser(Logger, _fileSystem, _httpClient, _appHost).Parse(info.Url, ChannelIdPrefix, info.Id, !info.EnableTvgId, cancellationToken).ConfigureAwait(false);}public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.csindex 06a7a0c2d7..cf36f7c6a9 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs@@ -33,14 +33,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts_appHost = appHost;}- public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken)+ public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, bool enableStreamUrlAsIdentifier, CancellationToken cancellationToken){var urlHash = url.GetMD5().ToString("N");// Read the file and display it line by line.using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false))){- return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId);+ return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId, enableStreamUrlAsIdentifier);}}@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts// Read the file and display it line by line.using (var reader = new StringReader(text)){- return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId);+ return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId, false);}}@@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts}const string ExtInfPrefix = "#EXTINF:";- private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId)+ private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId, bool enableStreamUrlAsIdentifier){var channels = new List<M3UChannel>();string line;@@ -97,7 +97,15 @@ namespace Emby.Server.Implementations.LiveTv.TunerHostselse if (!string.IsNullOrWhiteSpace(extInf) && !line.StartsWith("#", StringComparison.OrdinalIgnoreCase)){var channel = GetChannelnfo(extInf, tunerHostId, line);- channel.Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N");+ if (string.IsNullOrWhiteSpace(channel.Id) || enableStreamUrlAsIdentifier)+ {+ channel.Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N");+ }+ else+ {+ channel.Id = channelIdPrefix + channel.Id.GetMD5().ToString("N");+ }+channel.Path = line;channels.Add(channel);extInf = "";@@ -126,6 +134,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHostschannel.Name = GetChannelName(extInf, attributes);channel.Number = GetChannelNumber(extInf, attributes, mediaUrl);+ if (attributes.TryGetValue("tvg-id", out value))+ {+ channel.Id = value;+ }+return channel;}diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.csindex a27494dc51..3c2ace8964 100644--- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs+++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs@@ -57,8 +57,7 @@ namespace MediaBrowser.Model.LiveTvpublic string SourceB { get; set; }public string SourceC { get; set; }public string SourceD { get; set; }-- public int DataVersion { get; set; }+ public bool EnableTvgId { get; set; }public TunerHostInfo(){diff --git a/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs b/MediaBrowser.Server.Mono/Native/MonoFileSystem.csindex 3d6a3e35dc..a5dc691a75 100644--- a/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs+++ b/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs@@ -6,8 +6,8 @@ namespace MediaBrowser.Server.Mono.Native{public class MonoFileSystem : ManagedFileSystem{- public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars)- : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, true)+ public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, string tempPath)+ : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, true, tempPath){}diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.csindex b3aeb2027b..8100dec8d7 100644--- a/MediaBrowser.Server.Mono/Program.cs+++ b/MediaBrowser.Server.Mono/Program.cs@@ -108,7 +108,7 @@ namespace MediaBrowser.Server.Mono// Allow all https requestsServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });- var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false);+ var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false, appPaths.TempDirectory);fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));var environmentInfo = GetEnvironmentInfo();diff --git a/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs b/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpDiscovery.csindex 8ecdca46b3..fded988626 100644--- a/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs+++ b/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs@@ -113,7 +113,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIpType = SatIpHost.DeviceType,Url = deviceUrl,InfoUrl = infoUrl,- DataVersion = 1,DeviceId = info.DeviceId,FriendlyName = info.FriendlyName,Tuners = info.Tuners,diff --git a/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpHost.cs b/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpHost.csindex 5f0f28257f..ab057d4d88 100644--- a/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpHost.cs+++ b/MediaBrowser.Server.Startup.Common/LiveTv/TunerHosts/SatIp/SatIpHost.cs@@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp{if (!string.IsNullOrWhiteSpace(tuner.M3UUrl)){- return await new M3uParser(Logger, _fileSystem, _httpClient, _appHost).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);+ return await new M3uParser(Logger, _fileSystem, _httpClient, _appHost).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, false, cancellationToken).ConfigureAwait(false);}var channels = await new ChannelScan(Logger).Scan(tuner, cancellationToken).ConfigureAwait(false);diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.csindex 8dcabb9500..70b86c4a61 100644--- a/MediaBrowser.ServerApplication/MainStartup.cs+++ b/MediaBrowser.ServerApplication/MainStartup.cs@@ -324,7 +324,7 @@ namespace MediaBrowser.ServerApplication/// <param name="options">The options.</param>private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options){- var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true);+ var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true, appPaths.TempDirectory);fileSystem.AddShortcutHandler(new LnkShortcutHandler());fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));diff --git a/OpenSubtitlesHandler/Utilities.cs b/OpenSubtitlesHandler/Utilities.csindex c012da462d..f8cfa5c4fb 100644--- a/OpenSubtitlesHandler/Utilities.cs+++ b/OpenSubtitlesHandler/Utilities.cs@@ -37,8 +37,8 @@ namespace OpenSubtitlesHandlerpublic static IHttpClient HttpClient { get; set; }public static ITextEncoding EncodingHelper { get; set; }- //private static string XML_RPC_SERVER = "https://api.opensubtitles.org/xml-rpc";- private static string XML_RPC_SERVER = "https://92.240.234.122/xml-rpc";+ private static string XML_RPC_SERVER = "https://api.opensubtitles.org/xml-rpc";+ //private static string XML_RPC_SERVER = "https://92.240.234.122/xml-rpc";private static string HostHeader = "api.opensubtitles.org:443";/// <summary>