From 27070bd43af2adc6180c3b86d3ef82ffed1eeca4 Mon Sep 17 00:00:00 2001 From: Darrell King Date: Fri, 13 Jan 2017 20:51:07 +0000 Subject: [PATCH 01/11] Update BaseNfoParser to handle user defined IExternalIds --- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index dba6d96ac4..9caf94da60 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -964,7 +964,19 @@ namespace MediaBrowser.XbmcMetadata.Parsers } default: - reader.Skip(); + var providerId = reader.Name; + if (_validProviderIds.ContainsKey(providerId)) + { + var id = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(id)) + { + item.SetProviderId(_validProviderIds[providerId], id); + } + } + else + { + reader.Skip(); + } break; } } From 6d344fabb9ec4a19aa7a6efe2bd9e0bf151b9bf0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 16:05:12 -0500 Subject: [PATCH 02/11] update components --- .../Security/AuthorizationContext.cs | 29 ++++++++++++------- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index ec3dfeb609..ede85fb67d 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -49,6 +49,7 @@ namespace Emby.Server.Implementations.HttpServer.Security string device = null; string client = null; string version = null; + string token = null; if (auth != null) { @@ -56,9 +57,13 @@ namespace Emby.Server.Implementations.HttpServer.Security auth.TryGetValue("Device", out device); auth.TryGetValue("Client", out client); auth.TryGetValue("Version", out version); + auth.TryGetValue("Token", out token); } - var token = httpReq.Headers["X-Emby-Token"]; + if (string.IsNullOrWhiteSpace(token)) + { + token = httpReq.Headers["X-Emby-Token"]; + } if (string.IsNullOrWhiteSpace(token)) { @@ -156,8 +161,10 @@ namespace Emby.Server.Implementations.HttpServer.Security // There should be at least to parts if (parts.Length != 2) return null; + var acceptedNames = new[] { "MediaBrowser", "Emby"}; + // It has to be a digest request - if (!string.Equals(parts[0], "MediaBrowser", StringComparison.OrdinalIgnoreCase)) + if (!acceptedNames.Contains(parts[0] ?? string.Empty, StringComparer.OrdinalIgnoreCase)) { return null; } @@ -174,7 +181,7 @@ namespace Emby.Server.Implementations.HttpServer.Security if (param.Length == 2) { - var value = NormalizeValue (param[1].Trim(new[] { '"' })); + var value = NormalizeValue(param[1].Trim(new[] { '"' })); result.Add(param[0], value); } } @@ -182,14 +189,14 @@ namespace Emby.Server.Implementations.HttpServer.Security return result; } - private string NormalizeValue(string value) - { - if (string.IsNullOrWhiteSpace (value)) - { - return value; - } + private string NormalizeValue(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return value; + } - return System.Net.WebUtility.HtmlEncode(value); - } + return System.Net.WebUtility.HtmlEncode(value); + } } } diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 20253367ec..4bb58cd73f 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.693 + 3.0.694 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 08e6041506..c475a4c912 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.693 + 3.0.694 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 - + From 4ee1426757e05ea489450c665f2b128a660736bc Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 13 Jan 2017 03:20:25 +0100 Subject: [PATCH 03/11] Graciously handle transfer status reporting for SyncJobItems --- Emby.Server.Implementations/Sync/SyncManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.cs index 2687eaefc1..418d42c9a6 100644 --- a/Emby.Server.Implementations/Sync/SyncManager.cs +++ b/Emby.Server.Implementations/Sync/SyncManager.cs @@ -560,6 +560,12 @@ namespace Emby.Server.Implementations.Sync { var jobItem = _repo.GetJobItem(id); + if (jobItem == null) + { + _logger.Debug("ReportSyncJobItemTransferred: SyncJobItem {0} doesn't exist anymore", id); + return; + } + jobItem.Status = SyncJobItemStatus.Synced; jobItem.Progress = 100; From 1cb7a1b49cd3f088ed312eb97c6c01b317177104 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 22:46:02 -0500 Subject: [PATCH 04/11] add m3u unit test --- .../LiveTv/TunerHosts/M3uParser.cs | 32 ++++++++++---- MediaBrowser.Tests/M3uParserTest.cs | 44 +++++++++++++++++++ MediaBrowser.Tests/MediaBrowser.Tests.csproj | 12 +++++ 3 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 MediaBrowser.Tests/M3uParserTest.cs diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index e0f0402813..9351922a46 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -43,6 +43,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } + public List ParseString(string text, string channelIdPrefix, string tunerHostId) + { + var urlHash = "text".GetMD5().ToString("N"); + + // Read the file and display it line by line. + using (var reader = new StringReader(text)) + { + return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId); + } + } + public Task GetListingsStream(string url, CancellationToken cancellationToken) { if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) @@ -59,7 +70,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } const string ExtInfPrefix = "#EXTINF:"; - private List GetChannels(StreamReader reader, string urlHash, string channelIdPrefix, string tunerHostId) + private List GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId) { var channels = new List(); string line; @@ -122,16 +133,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; - var numberString = nameParts[0]; + string numberString = null; //Check for channel number with the format from SatIp - int number; + // #EXTINF:0,84. VOX Schweiz if (!string.IsNullOrWhiteSpace(nameInExtInf)) { var numberIndex = nameInExtInf.IndexOf('.'); if (numberIndex > 0) { - if (int.TryParse(nameInExtInf.Substring(0, numberIndex), out number)) + double number; + if (double.TryParse(nameInExtInf.Substring(0, numberIndex), NumberStyles.AllowCurrencySymbol, CultureInfo.InvariantCulture, out number)) { numberString = number.ToString(); } @@ -150,7 +162,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts string value; if (attributes.TryGetValue("tvg-id", out value)) { - numberString = value; + double doubleValue; + if (double.TryParse(value, NumberStyles.AllowCurrencySymbol, CultureInfo.InvariantCulture, out doubleValue)) + { + numberString = value; + } } } @@ -209,16 +225,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; //Check for channel number with the format from SatIp - int number; if (!string.IsNullOrWhiteSpace(nameInExtInf)) { var numberIndex = nameInExtInf.IndexOf('.'); if (numberIndex > 0) { - if (int.TryParse(nameInExtInf.Substring(0, numberIndex), out number)) + double number; + if (double.TryParse(nameInExtInf.Substring(0, numberIndex), NumberStyles.AllowCurrencySymbol, CultureInfo.InvariantCulture, out number)) { //channel.Number = number.ToString(); - nameInExtInf = nameInExtInf.Substring(numberIndex + 1); + nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(); } } } diff --git a/MediaBrowser.Tests/M3uParserTest.cs b/MediaBrowser.Tests/M3uParserTest.cs new file mode 100644 index 0000000000..a6f4c3bd8f --- /dev/null +++ b/MediaBrowser.Tests/M3uParserTest.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Emby.Common.Implementations.Cryptography; +using Emby.Server.Implementations.LiveTv.TunerHosts; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Model.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace MediaBrowser.Tests +{ + [TestClass] + public class M3uParserTest + { + [TestMethod] + public void TestFormat1() + { + BaseExtensions.CryptographyProvider = new CryptographyProvider(); + + var result = new M3uParser(new NullLogger(), null, null, null).ParseString("#EXTINF:0,84. VOX Schweiz\nhttp://mystream", "-", "-"); + Assert.AreEqual(1, result.Count); + + Assert.AreEqual("VOX Schweiz", result[0].Name); + Assert.AreEqual("84", result[0].Number); + } + [TestMethod] + public void TestFormat2() + { + BaseExtensions.CryptographyProvider = new CryptographyProvider(); + + var input = "#EXTINF:-1 tvg-id=\"\" tvg-name=\"ABC News 04\" tvg-logo=\"\" group-title=\"ABC Group\",ABC News 04"; + input += "\n"; + input += "http://mystream"; + + var result = new M3uParser(new NullLogger(), null, null, null).ParseString(input, "-", "-"); + Assert.AreEqual(1, result.Count); + + Assert.AreEqual("ABC News 04", result[0].Name); + Assert.IsNull(result[0].Number); + } + } +} diff --git a/MediaBrowser.Tests/MediaBrowser.Tests.csproj b/MediaBrowser.Tests/MediaBrowser.Tests.csproj index 4ea2cb0c0e..8ba828d85f 100644 --- a/MediaBrowser.Tests/MediaBrowser.Tests.csproj +++ b/MediaBrowser.Tests/MediaBrowser.Tests.csproj @@ -37,6 +37,9 @@ 4 + + ..\ThirdParty\emby\Emby.Common.Implementations.dll + @@ -58,12 +61,21 @@ + + + {e383961b-9356-4d5d-8233-9a1079d03055} + Emby.Server.Implementations + + + {9142eefa-7570-41e1-bfcc-468bb571af2f} + MediaBrowser.Common + {17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2} MediaBrowser.Controller From 7a77aa42c5876c5cda6695b7f76e7a4dd6a11d9f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 22:48:25 -0500 Subject: [PATCH 05/11] update season creator --- .../TV/DummySeasonProvider.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index f9f2479998..fd4d041b2b 100644 --- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs +++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs @@ -66,29 +66,39 @@ namespace MediaBrowser.Providers.TV .Distinct() .ToList()) { - var hasSeason = series.Children.OfType() - .Any(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber); + var existingSeason = series.Children.OfType() + .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber); - if (!hasSeason) + if (existingSeason == null) { await AddSeason(series, seasonNumber, false, cancellationToken).ConfigureAwait(false); hasChanges = true; } + else if (existingSeason.IsVirtualItem) + { + existingSeason.IsVirtualItem = false; + await existingSeason.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); + } } // Unknown season - create a dummy season to put these under if (episodesInSeriesFolder.Any(i => !i.ParentIndexNumber.HasValue)) { - var hasSeason = series.Children.OfType() - .Any(i => !i.IndexNumber.HasValue); + var existingSeason = series.Children.OfType() + .FirstOrDefault(i => !i.IndexNumber.HasValue); - if (!hasSeason) + if (existingSeason == null) { await AddSeason(series, null, false, cancellationToken).ConfigureAwait(false); hasChanges = true; } + else if (existingSeason.IsVirtualItem) + { + existingSeason.IsVirtualItem = false; + await existingSeason.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); + } } return hasChanges; From 82c65f37885eb204f09b08d495c8666bbc68bdf3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 22:48:42 -0500 Subject: [PATCH 06/11] update playlist creation --- Emby.Server.Implementations/Playlists/PlaylistManager.cs | 2 +- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 9583141e0d..386da73c64 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.Playlists if (string.IsNullOrWhiteSpace(options.MediaType)) { - throw new ArgumentException("A playlist media type is required."); + options.MediaType = "Audio"; } var user = _userManager.GetUserById(options.UserId); diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 9caf94da60..e4037f2efc 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -964,13 +964,14 @@ namespace MediaBrowser.XbmcMetadata.Parsers } default: - var providerId = reader.Name; - if (_validProviderIds.ContainsKey(providerId)) + string readerName = reader.Name; + string providerIdValue; + if (_validProviderIds.TryGetValue(readerName, out providerIdValue)) { var id = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(id)) { - item.SetProviderId(_validProviderIds[providerId], id); + item.SetProviderId(providerIdValue, id); } } else From 6e9ab9bf9ca05a2810865e9b36326ac7534d36d7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 22:49:01 -0500 Subject: [PATCH 07/11] fix recording time filter --- Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 639621a98d..d3eb357507 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -2106,13 +2106,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { return true; } - - if (!seriesTimer.Days.Contains(timer.StartDate.ToLocalTime().DayOfWeek)) - { - return true; - } } + //if (!seriesTimer.Days.Contains(timer.StartDate.ToLocalTime().DayOfWeek)) + //{ + // return true; + //} + if (seriesTimer.RecordNewOnly && timer.IsRepeat) { return true; From 0f7273ec455a8e038648ed62d26db64eaa2a24b4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 23:07:19 -0500 Subject: [PATCH 08/11] add failing test --- MediaBrowser.Tests/M3uParserTest.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MediaBrowser.Tests/M3uParserTest.cs b/MediaBrowser.Tests/M3uParserTest.cs index a6f4c3bd8f..be77084573 100644 --- a/MediaBrowser.Tests/M3uParserTest.cs +++ b/MediaBrowser.Tests/M3uParserTest.cs @@ -40,5 +40,17 @@ namespace MediaBrowser.Tests Assert.AreEqual("ABC News 04", result[0].Name); Assert.IsNull(result[0].Number); } + + [TestMethod] + public void TestFormat3() + { + BaseExtensions.CryptographyProvider = new CryptographyProvider(); + + var result = new M3uParser(new NullLogger(), null, null, null).ParseString("#EXTINF:0, 3.2 - Movies!\nhttp://mystream", "-", "-"); + Assert.AreEqual(1, result.Count); + + Assert.AreEqual("Movies!", result[0].Name); + Assert.AreEqual("3.2", result[0].Number); + } } } From 4ad2f541936d8795eff0a990c2dc6ba9c61d8c4d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 23:07:34 -0500 Subject: [PATCH 09/11] samsung dlna fixes --- Emby.Dlna/Profiles/SamsungSmartTvProfile.cs | 2 +- Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Dlna/Profiles/SamsungSmartTvProfile.cs b/Emby.Dlna/Profiles/SamsungSmartTvProfile.cs index 5acdde327b..b86e6ba568 100644 --- a/Emby.Dlna/Profiles/SamsungSmartTvProfile.cs +++ b/Emby.Dlna/Profiles/SamsungSmartTvProfile.cs @@ -43,7 +43,7 @@ namespace Emby.Dlna.Profiles AudioCodec = "ac3", VideoCodec = "h264", Type = DlnaProfileType.Video, - EstimateContentLength = true + EstimateContentLength = false }, new TranscodingProfile { diff --git a/Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml b/Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml index 5b2106da54..8729a59c19 100644 --- a/Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml +++ b/Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml @@ -51,7 +51,7 @@ - + From 4a73875ef3e5f754c27e2682548f0249fc88e480 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Jan 2017 23:31:43 -0500 Subject: [PATCH 10/11] update m3u parser --- .../LiveTv/TunerHosts/M3uParser.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 9351922a46..5be94b5073 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -135,17 +135,20 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts string numberString = null; - //Check for channel number with the format from SatIp + // Check for channel number with the format from SatIp // #EXTINF:0,84. VOX Schweiz + // #EXTINF:0,84.0 - VOX Schweiz if (!string.IsNullOrWhiteSpace(nameInExtInf)) { - var numberIndex = nameInExtInf.IndexOf('.'); + var numberIndex = nameInExtInf.IndexOf(' '); if (numberIndex > 0) { + var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); + double number; - if (double.TryParse(nameInExtInf.Substring(0, numberIndex), NumberStyles.AllowCurrencySymbol, CultureInfo.InvariantCulture, out number)) + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) { - numberString = number.ToString(); + numberString = numberPart; } } } @@ -163,7 +166,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts if (attributes.TryGetValue("tvg-id", out value)) { double doubleValue; - if (double.TryParse(value, NumberStyles.AllowCurrencySymbol, CultureInfo.InvariantCulture, out doubleValue)) + if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue)) { numberString = value; } @@ -224,17 +227,21 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; - //Check for channel number with the format from SatIp + // Check for channel number with the format from SatIp + // #EXTINF:0,84. VOX Schweiz + // #EXTINF:0,84.0 - VOX Schweiz if (!string.IsNullOrWhiteSpace(nameInExtInf)) { - var numberIndex = nameInExtInf.IndexOf('.'); + var numberIndex = nameInExtInf.IndexOf(' '); if (numberIndex > 0) { + var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); + double number; - if (double.TryParse(nameInExtInf.Substring(0, numberIndex), NumberStyles.AllowCurrencySymbol, CultureInfo.InvariantCulture, out number)) + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) { //channel.Number = number.ToString(); - nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(); + nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' }); } } } From 95ceddb7d9c817f2e9233bd5116e7cb8ee76fc49 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 14 Jan 2017 14:57:08 -0500 Subject: [PATCH 11/11] update m3uparser --- .../LiveTv/TunerHosts/M3uParser.cs | 21 +++++++++---------- MediaBrowser.Tests/M3uParserTest.cs | 12 +++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 5be94b5073..06a7a0c2d7 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -14,6 +14,7 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.LiveTv.TunerHosts { @@ -273,20 +274,18 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase); var matches = reg.Matches(line); - var minIndex = int.MaxValue; - foreach (Match match in matches) - { - dict[match.Groups[1].Value] = match.Groups[2].Value; - minIndex = Math.Min(minIndex, match.Index); - } - - if (minIndex > 0 && minIndex < line.Length) - { - line = line.Substring(0, minIndex); - } remaining = line; + foreach (Match match in matches) + { + var key = match.Groups[1].Value; + var value = match.Groups[2].Value; + + dict[match.Groups[1].Value] = match.Groups[2].Value; + remaining = remaining.Replace(key + "=\"" + value + "\"", string.Empty, StringComparison.OrdinalIgnoreCase); + } + return dict; } } diff --git a/MediaBrowser.Tests/M3uParserTest.cs b/MediaBrowser.Tests/M3uParserTest.cs index be77084573..3285d07407 100644 --- a/MediaBrowser.Tests/M3uParserTest.cs +++ b/MediaBrowser.Tests/M3uParserTest.cs @@ -52,5 +52,17 @@ namespace MediaBrowser.Tests Assert.AreEqual("Movies!", result[0].Name); Assert.AreEqual("3.2", result[0].Number); } + + [TestMethod] + public void TestFormat4() + { + BaseExtensions.CryptographyProvider = new CryptographyProvider(); + + var result = new M3uParser(new NullLogger(), null, null, null).ParseString("#EXTINF:0 tvg-id=\"abckabclosangeles.path.to\" tvg-logo=\"path.to / channel_logos / abckabclosangeles.png\", ABC KABC Los Angeles\nhttp://mystream", "-", "-"); + Assert.AreEqual(1, result.Count); + + Assert.IsNull(result[0].Number); + Assert.AreEqual("ABC KABC Los Angeles", result[0].Name); + } } }