diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 2ff48cd85b..f913d03614 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -26,6 +26,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Common.Extensions; namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { @@ -673,14 +674,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV recordPath = Path.Combine(recordPath, recordingFileName); _fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath)); - var recording = _recordingProvider.GetAll().FirstOrDefault(x => string.Equals(x.ProgramId, info.Id, StringComparison.OrdinalIgnoreCase)); + var recordingId = info.Id.GetMD5().ToString("N"); + var recording = _recordingProvider.GetAll().FirstOrDefault(x => string.Equals(x.Id, recordingId, StringComparison.OrdinalIgnoreCase)); if (recording == null) { recording = new RecordingInfo { ChannelId = info.ChannelId, - Id = Guid.NewGuid().ToString("N"), + Id = recordingId, StartDate = info.StartDate, EndDate = info.EndDate, Genres = info.Genres, diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 161bcbf481..227d4ca18c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -200,7 +200,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings _logger.Info("Mapping Stations to Channel"); foreach (ScheduleDirect.Map map in root.map) { - var channel = (map.channel ?? (map.atscMajor + "." + map.atscMinor)).TrimStart('0'); + var channel = map.logicalChannelNumber; + + if (string.IsNullOrWhiteSpace(channel)) + { + channel = map.channel; + } + if (string.IsNullOrWhiteSpace(channel)) + { + channel = (map.atscMajor + "." + map.atscMinor); + } + channel = channel.TrimStart('0'); + _logger.Debug("Found channel: " + channel + " in Schedules Direct"); var schChannel = root.stations.FirstOrDefault(item => item.stationID == map.stationID); @@ -741,6 +752,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings { public string stationID { get; set; } public string channel { get; set; } + public string logicalChannelNumber { get; set; } public int uhfVhf { get; set; } public int atscMajor { get; set; } public int atscMinor { get; set; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs index 5afe8f54ac..d0881fb51b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs @@ -49,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts var list = result.ToList(); Logger.Debug("Channels from {0}: {1}", tuner.Url, JsonSerializer.SerializeToString(list)); - if (!string.IsNullOrWhiteSpace(key)) + if (!string.IsNullOrWhiteSpace(key) && list.Count > 0) { cache = cache ?? new ChannelCache(); cache.Date = DateTime.UtcNow; diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 9cd706b53d..e8ba12635a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -86,7 +86,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun Url = string.Format("{0}/", GetApiUrl(info, false)), CancellationToken = cancellationToken, CacheLength = TimeSpan.FromDays(1), - CacheMode = CacheMode.Unconditional + CacheMode = CacheMode.Unconditional, + TimeoutMs = Convert.ToInt32(TimeSpan.FromSeconds(5).TotalMilliseconds) })) { using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8)) @@ -101,7 +102,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun } } - return null; + return model; } public async Task> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken) @@ -111,7 +112,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun using (var stream = await _httpClient.Get(new HttpRequestOptions() { Url = string.Format("{0}/tuners.html", GetApiUrl(info, false)), - CancellationToken = cancellationToken + CancellationToken = cancellationToken, + TimeoutMs = Convert.ToInt32(TimeSpan.FromSeconds(5).TotalMilliseconds) })) { var tuners = new List();