diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-01-14 15:06:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-14 15:06:07 -0500 |
| commit | cd469cf31c59e0c666f7d34b659eddafcc276242 (patch) | |
| tree | 6b4791b344167fa39429f6f0dad730968c1d18ec /Emby.Server.Implementations | |
| parent | 483d6044488ea5806e4c98636c56c123614183ed (diff) | |
| parent | 95ceddb7d9c817f2e9233bd5116e7cb8ee76fc49 (diff) | |
Merge pull request #2399 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations')
5 files changed, 74 insertions, 39 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/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; diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index e0f0402813..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 { @@ -43,6 +44,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } + public List<M3UChannel> 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<Stream> 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<M3UChannel> GetChannels(StreamReader reader, string urlHash, string channelIdPrefix, string tunerHostId) + private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId) { var channels = new List<M3UChannel>(); 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; + + remaining = line; + foreach (Match match in matches) { - dict[match.Groups[1].Value] = match.Groups[2].Value; - minIndex = Math.Min(minIndex, match.Index); - } + var key = match.Groups[1].Value; + var value = match.Groups[2].Value; - if (minIndex > 0 && minIndex < line.Length) - { - line = line.Substring(0, minIndex); + dict[match.Groups[1].Value] = match.Groups[2].Value; + remaining = remaining.Replace(key + "=\"" + value + "\"", string.Empty, StringComparison.OrdinalIgnoreCase); } - remaining = line; - return dict; } } 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/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; |
