fix mapping multiple tuner channels to same epg channel

This commit is contained in:
Luke Pulverenti
2017-02-18 22:46:09 -05:00
parent 00760f7d24
commit 0ee1a0d7bd
27 changed files with 170 additions and 446 deletions

View File

@@ -2872,7 +2872,8 @@ namespace Emby.Server.Implementations.Data
}
if (string.Equals(name, ItemSortBy.IsFavoriteOrLiked, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("IsFavorite", true);
// (Select Case When Abs(COALESCE(ProductionYear, 0) - @ItemProductionYear) < 10 Then 2 Else 0 End )
return new Tuple<string, bool>("(Select Case When IsFavorite is null Then 0 Else IsFavorite End )", true);
}
if (string.Equals(name, ItemSortBy.IsFolder, StringComparison.OrdinalIgnoreCase))
{

View File

@@ -492,7 +492,7 @@ namespace Emby.Server.Implementations.Dto
}
}
//if (!(item is LiveTvProgram))
if (!(item is LiveTvProgram))
{
dto.PlayAccess = item.GetPlayAccess(user);
}
@@ -1420,7 +1420,7 @@ namespace Emby.Server.Implementations.Dto
{
dto.AirDays = series.AirDays;
dto.AirTime = series.AirTime;
dto.SeriesStatus = series.Status;
dto.Status = series.Status.HasValue ? series.Status.Value.ToString() : null;
}
// Add SeasonInfo

View File

@@ -986,6 +986,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
foreach (var program in programs)
{
program.ChannelId = channelId;
if (provider.Item2.EnableNewProgramIds)
{
program.Id += "_" + channelId;
}
}
if (programs.Count > 0)

View File

@@ -81,12 +81,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return programsInfo;
}
if (string.IsNullOrWhiteSpace(info.ListingsId))
{
_logger.Warn("ListingsId is null, returning empty program list");
return programsInfo;
}
var dates = GetScheduleRequestDates(startDateUtc, endDateUtc);
string stationID = channelId;
@@ -156,7 +150,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID)
.ToList();
var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken);
var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken).ConfigureAwait(false);
var schedules = dailySchedules.SelectMany(d => d.programs);
foreach (ScheduleDirect.Program schedule in schedules)

View File

@@ -168,7 +168,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
EpisodeNumber = p.Episode == null ? null : p.Episode.Episode,
EpisodeTitle = episodeTitle,
Genres = p.Categories,
Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate), // Construct an id from the channel and start date,
StartDate = GetDate(p.StartDate),
Name = p.Title,
Overview = p.Description,
@@ -208,6 +207,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings
programInfo.ShowId = uniqueString.GetMD5().ToString("N");
}
// Construct an id from the channel and start date
programInfo.Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate);
if (programInfo.IsMovie)
{
programInfo.IsSeries = false;

View File

@@ -598,10 +598,6 @@ namespace Emby.Server.Implementations.LiveTv
item.ParentId = channel.Id;
//item.ChannelType = channelType;
if (!string.Equals(item.ServiceName, serviceName, StringComparison.Ordinal))
{
forceUpdate = true;
}
item.ServiceName = serviceName;
item.Audio = info.Audio;
@@ -1311,7 +1307,7 @@ namespace Emby.Server.Implementations.LiveTv
var isKids = false;
var iSSeries = false;
var channelPrograms = await service.GetProgramsAsync(GetItemExternalId(currentChannel), start, end, cancellationToken).ConfigureAwait(false);
var channelPrograms = (await service.GetProgramsAsync(GetItemExternalId(currentChannel), start, end, cancellationToken).ConfigureAwait(false)).ToList();
var existingPrograms = _libraryManager.GetItemList(new InternalItemsQuery
{
@@ -1409,7 +1405,7 @@ namespace Emby.Server.Implementations.LiveTv
double percent = numComplete;
percent /= allChannelsList.Count;
progress.Report(80 * percent + 10);
progress.Report(85 * percent + 15);
}
progress.Report(100);
@@ -1884,7 +1880,7 @@ namespace Emby.Server.Implementations.LiveTv
: _tvDtoService.GetInternalTimerId(service.Name, info.TimerId).ToString("N");
dto.StartDate = info.StartDate;
dto.RecordingStatus = info.Status;
dto.Status = info.Status.ToString();
dto.IsRepeat = info.IsRepeat;
dto.EpisodeTitle = info.EpisodeTitle;
dto.IsMovie = info.IsMovie;
@@ -2865,6 +2861,7 @@ namespace Emby.Server.Implementations.LiveTv
{
info.Id = Guid.NewGuid().ToString("N");
config.ListingProviders.Add(info);
info.EnableNewProgramIds = true;
}
else
{

View File

@@ -9,17 +9,14 @@ using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Net;
@@ -66,7 +63,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return id;
}
private async Task<IEnumerable<Channels>> GetLineup(TunerHostInfo info, CancellationToken cancellationToken)
private async Task<List<Channels>> GetLineup(TunerHostInfo info, CancellationToken cancellationToken)
{
var options = new HttpRequestOptions
{
@@ -74,7 +71,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
CancellationToken = cancellationToken,
BufferContent = false
};
using (var stream = await _httpClient.Get(options))
using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
{
var lineup = JsonSerializer.DeserializeFromStream<List<Channels>>(stream) ?? new List<Channels>();
@@ -127,7 +124,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
CacheMode = CacheMode.Unconditional,
TimeoutMs = Convert.ToInt32(TimeSpan.FromSeconds(5).TotalMilliseconds),
BufferContent = false
}))
}).ConfigureAwait(false))
{
var response = JsonSerializer.DeserializeFromStream<DiscoverResponse>(stream);
@@ -169,7 +167,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
CancellationToken = cancellationToken,
TimeoutMs = Convert.ToInt32(TimeSpan.FromSeconds(5).TotalMilliseconds),
BufferContent = false
}))
}).ConfigureAwait(false))
{
var tuners = new List<LiveTvTunerInfo>();
using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8))
@@ -536,7 +535,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
Url = string.Format("{0}/discover.json", GetApiUrl(info, false)),
CancellationToken = CancellationToken.None,
BufferContent = false
}))
}).ConfigureAwait(false))
{
var response = JsonSerializer.DeserializeFromStream<DiscoverResponse>(stream);

View File

@@ -74,10 +74,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
OnFinished = OnFinished
};
var initial = _sharedBuffer.ToList();
var list = new List<byte>();
foreach (var bytes in initial)
foreach (var bytes in _sharedBuffer)
{
list.AddRange(bytes);
}