update series timers

This commit is contained in:
Luke Pulverenti 2015-09-17 21:51:22 -04:00
parent 8a4f86aefe
commit 2acd1665c9
4 changed files with 67 additions and 8 deletions

View File

@ -57,7 +57,7 @@ namespace MediaBrowser.Api.Playback
Size = 102400;
}
}
[Authenticated]
public class MediaInfoService : BaseApiService
{
@ -289,7 +289,7 @@ namespace MediaBrowser.Api.Playback
if (mediaSource.SupportsDirectStream)
{
options.MaxBitrate = GetMaxBitrate(maxBitrate);
// The MediaSource supports direct stream, now test to see if the client supports it
var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ?
streamBuilder.BuildAudioItem(options) :
@ -309,7 +309,7 @@ namespace MediaBrowser.Api.Playback
if (mediaSource.SupportsTranscoding)
{
options.MaxBitrate = GetMaxBitrate(maxBitrate);
// The MediaSource supports direct stream, now test to see if the client supports it
var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ?
streamBuilder.BuildAudioItem(options) :
@ -336,9 +336,15 @@ namespace MediaBrowser.Api.Playback
var maxBitrate = clientMaxBitrate;
var remoteClientMaxBitrate = _config.Configuration.RemoteClientBitrateLimit;
if (remoteClientMaxBitrate > 0 && !_networkManager.IsInLocalNetwork(Request.RemoteIp))
if (remoteClientMaxBitrate > 0)
{
maxBitrate = Math.Min(maxBitrate ?? remoteClientMaxBitrate, remoteClientMaxBitrate);
var isInLocalNetwork = _networkManager.IsInLocalNetwork(Request.RemoteIp);
Logger.Info("RemoteClientBitrateLimit: {0}, RemoteIp: {1}, IsInLocalNetwork: {2}", remoteClientMaxBitrate, Request.RemoteIp, isInLocalNetwork);
if (!isInLocalNetwork)
{
maxBitrate = Math.Min(maxBitrate ?? remoteClientMaxBitrate, remoteClientMaxBitrate);
}
}
return maxBitrate;

View File

@ -130,6 +130,33 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
return status;
}
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
{
var timers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
List<ChannelInfo> channels = null;
foreach (var timer in timers)
{
List<ProgramInfo> epgData;
if (timer.RecordAnyChannel)
{
if (channels == null)
{
channels = (await GetChannelsAsync(true, CancellationToken.None).ConfigureAwait(false)).ToList();
}
var channelIds = channels.Select(i => i.Id).ToList();
epgData = GetEpgDataForChannels(channelIds);
}
else
{
epgData = GetEpgDataForChannel(timer.ChannelId);
}
await UpdateTimersForSeriesTimer(epgData, timer).ConfigureAwait(false);
}
}
private List<ChannelInfo> _channelCache = null;
private async Task<IEnumerable<ChannelInfo>> GetChannelsAsync(bool enableCache, CancellationToken cancellationToken)
{

View File

@ -237,8 +237,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
ScheduleDirect.ProgramDetails details)
{
//_logger.Debug("Show type is: " + (details.showType ?? "No ShowType"));
DateTime startAt = DateTime.ParseExact(programInfo.airDateTime, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'",
CultureInfo.InvariantCulture);
DateTime startAt = GetDate(programInfo.airDateTime);
DateTime endAt = startAt.AddSeconds(programInfo.duration);
ProgramAudio audioType = ProgramAudio.Stereo;
@ -361,6 +360,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
return info;
}
private DateTime GetDate(string value)
{
var date = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture);
if (date.Kind != DateTimeKind.Utc)
{
date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
}
return date;
}
private string GetProgramLogo(string apiUrl, ScheduleDirect.ShowImages images)
{
string url = "";
@ -400,7 +410,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{
imageIdString += "\"" + i.Substring(0, 10) + "\",";
}
;
});
imageIdString = imageIdString.TrimEnd(',') + "]";

View File

@ -1082,6 +1082,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
await CleanDatabaseInternal(newChannelIdList, new[] { typeof(LiveTvChannel).Name }, progress, cancellationToken).ConfigureAwait(false);
await CleanDatabaseInternal(newProgramIdList, new[] { typeof(LiveTvProgram).Name }, progress, cancellationToken).ConfigureAwait(false);
var coreService = _services.OfType<EmbyTV.EmbyTV>().FirstOrDefault();
if (coreService != null)
{
await coreService.RefreshSeriesTimers(cancellationToken, new Progress<double>()).ConfigureAwait(false);
}
// Load these now which will prefetch metadata
var dtoOptions = new DtoOptions();
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
@ -1155,7 +1162,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv
foreach (var program in channelPrograms)
{
if (program.StartDate.Kind != DateTimeKind.Utc)
{
_logger.Error("{0} returned StartDate.DateTimeKind.{1} instead of UTC for program {2}", service.Name, program.StartDate.Kind.ToString(), program.Name);
}
else if (program.EndDate.Kind != DateTimeKind.Utc)
{
_logger.Error("{0} returned EndDate.DateTimeKind.{1} instead of UTC for program {2}", service.Name, program.EndDate.Kind.ToString(), program.Name);
}
var programItem = await GetProgram(program, channelId, currentChannel.ChannelType, service.Name, cancellationToken).ConfigureAwait(false);
programs.Add(programItem.Id);
}
}