diff --git a/Emby.Dlna/Profiles/SamsungSmartTvProfile.cs b/Emby.Dlna/Profiles/SamsungSmartTvProfile.cs index 5acdde327..b86e6ba56 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 5b2106da5..8729a59c1 100644 --- a/Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml +++ b/Emby.Dlna/Profiles/Xml/Samsung Smart TV.xml @@ -51,7 +51,7 @@ - + diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index ec3dfeb60..ede85fb67 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/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 639621a98..d3eb35750 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; diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index e0f040281..06a7a0c2d 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 { @@ -43,6 +44,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 +71,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,18 +134,22 @@ 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; + // 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) { - if (int.TryParse(nameInExtInf.Substring(0, numberIndex), out number)) + var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); + + double number; + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) { - numberString = number.ToString(); + numberString = numberPart; } } } @@ -150,7 +166,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.Any, CultureInfo.InvariantCulture, out doubleValue)) + { + numberString = value; + } } } @@ -208,17 +228,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 - int number; + // 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) { - if (int.TryParse(nameInExtInf.Substring(0, numberIndex), out number)) + var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); + + double number; + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) { //channel.Number = number.ToString(); - nameInExtInf = nameInExtInf.Substring(numberIndex + 1); + nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' }); } } } @@ -250,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/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 9583141e0..386da73c6 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/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.cs index 2687eaefc..418d42c9a 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; diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index f9f247999..fd4d041b2 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; diff --git a/MediaBrowser.Tests/M3uParserTest.cs b/MediaBrowser.Tests/M3uParserTest.cs new file mode 100644 index 000000000..3285d0740 --- /dev/null +++ b/MediaBrowser.Tests/M3uParserTest.cs @@ -0,0 +1,68 @@ +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); + } + + [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); + } + + [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); + } + } +} diff --git a/MediaBrowser.Tests/MediaBrowser.Tests.csproj b/MediaBrowser.Tests/MediaBrowser.Tests.csproj index 4ea2cb0c0..8ba828d85 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 diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index dba6d96ac..e4037f2ef 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -964,7 +964,20 @@ namespace MediaBrowser.XbmcMetadata.Parsers } default: - reader.Skip(); + string readerName = reader.Name; + string providerIdValue; + if (_validProviderIds.TryGetValue(readerName, out providerIdValue)) + { + var id = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(id)) + { + item.SetProviderId(providerIdValue, id); + } + } + else + { + reader.Skip(); + } break; } } diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 20253367e..4bb58cd73 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 08e604150..c475a4c91 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 - +