update tv guide

This commit is contained in:
Luke Pulverenti
2015-07-23 10:58:27 -04:00
parent 3fda8ec5c2
commit 23bab40308
5 changed files with 10 additions and 50 deletions

View File

@@ -257,18 +257,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
{
var allChannels = await GetChannelsAsync(cancellationToken).ConfigureAwait(false);
var channelInfo = allChannels.FirstOrDefault(i => string.Equals(channelId, i.Id, StringComparison.OrdinalIgnoreCase));
if (channelInfo == null)
{
_logger.Debug("Returning empty program list because channel was not found.");
return new List<ProgramInfo>();
}
foreach (var provider in GetListingProviders())
{
var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channelInfo, startDateUtc, endDateUtc, cancellationToken)
var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channelId, startDateUtc, endDateUtc, cancellationToken)
.ConfigureAwait(false);
var list = programs.ToList();

View File

@@ -35,10 +35,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
_httpClient = httpClient;
}
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, ChannelInfo channel, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
{
var channelNumber = channel.Number;
List<ProgramInfo> programsInfo = new List<ProgramInfo>();
var token = await GetToken(info, cancellationToken);
@@ -74,7 +72,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
ScheduleDirect.Station station = null;
if (!_channelPair.TryGetValue("", out station))
if (!_channelPair.TryGetValue(channelNumber, out station))
{
return programsInfo;
}
@@ -217,39 +215,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
}
}
private async Task<ScheduleDirect.Channel> GetLineup(string listingsId, string token, CancellationToken cancellationToken)
{
var httpOptions = new HttpRequestOptions()
{
Url = ApiUrl + "/lineups/" + listingsId,
UserAgent = UserAgent,
CancellationToken = cancellationToken
};
httpOptions.RequestHeaders["token"] = token;
using (var response = await _httpClient.Get(httpOptions))
{
var root = _jsonSerializer.DeserializeFromStream<ScheduleDirect.Channel>(response);
_logger.Info("Found " + root.map.Count() + " channels on the lineup on ScheduleDirect");
_logger.Info("Mapping Stations to Channel");
foreach (ScheduleDirect.Map map in root.map)
{
var channel = (map.channel ?? (map.atscMajor + "." + map.atscMinor)).TrimStart('0');
_logger.Debug("Found channel: " + channel + " in Schedules Direct");
var schChannel = root.stations.FirstOrDefault(item => item.stationID == map.stationID);
if (!_channelPair.ContainsKey(channel) && channel != "0.0" && schChannel != null)
{
_channelPair.TryAdd(channel, schChannel);
}
}
return root;
}
}
private ProgramInfo GetProgram(string channel, ScheduleDirect.Program programInfo,
ScheduleDirect.ProgramDetails details)
{