recording fixes

pull/702/head
Luke Pulverenti 9 years ago
parent cc213128e2
commit 9ec1376e5f

@ -338,8 +338,9 @@ namespace MediaBrowser.Controller.LiveTv
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="dto">The dto.</param> /// <param name="dto">The dto.</param>
/// <param name="addChannelInfo">if set to <c>true</c> [add channel information].</param>
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, User user = null); void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, bool addChannelInfo, User user = null);
/// <summary> /// <summary>
/// Saves the tuner host. /// Saves the tuner host.
/// </summary> /// </summary>

@ -35,6 +35,11 @@
/// </summary> /// </summary>
CanDownload, CanDownload,
/// <summary>
/// The channel information
/// </summary>
ChannelInfo,
/// <summary> /// <summary>
/// The chapters /// The chapters
/// </summary> /// </summary>

@ -398,7 +398,7 @@ namespace MediaBrowser.Server.Implementations.Dto
else if (item is LiveTvProgram) else if (item is LiveTvProgram)
{ {
_livetvManager().AddInfoToProgramDto(item, dto, user); _livetvManager().AddInfoToProgramDto(item, dto, fields.Contains(ItemFields.ChannelInfo), user);
} }
return dto; return dto;

@ -82,7 +82,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
// The data can be large so give it some extra time // The data can be large so give it some extra time
TimeoutMs = 60000 TimeoutMs = 60000,
LogErrorResponseBody = true
}; };
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
@ -123,7 +124,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
Url = ApiUrl + "/programs", Url = ApiUrl + "/programs",
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken CancellationToken = cancellationToken,
LogErrorResponseBody = true
}; };
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
@ -213,7 +215,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
Url = ApiUrl + "/lineups/" + info.ListingsId, Url = ApiUrl + "/lineups/" + info.ListingsId,
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken CancellationToken = cancellationToken,
LogErrorResponseBody = true
}; };
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
@ -451,7 +454,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
Url = ApiUrl + "/metadata/programs", Url = ApiUrl + "/metadata/programs",
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
RequestContent = imageIdString RequestContent = imageIdString,
LogErrorResponseBody = true
}; };
List<ScheduleDirect.ShowImages> images; List<ScheduleDirect.ShowImages> images;
using (var innerResponse2 = await _httpClient.Post(httpOptions)) using (var innerResponse2 = await _httpClient.Post(httpOptions))
@ -478,7 +482,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
Url = ApiUrl + "/headends?country=" + country + "&postalcode=" + location, Url = ApiUrl + "/headends?country=" + country + "&postalcode=" + location,
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken CancellationToken = cancellationToken,
LogErrorResponseBody = true
}; };
options.RequestHeaders["token"] = token; options.RequestHeaders["token"] = token;
@ -595,7 +600,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
Url = ApiUrl + "/token", Url = ApiUrl + "/token",
UserAgent = UserAgent, UserAgent = UserAgent,
RequestContent = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}", RequestContent = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}",
CancellationToken = cancellationToken CancellationToken = cancellationToken,
LogErrorResponseBody = true
}; };
//_logger.Info("Obtaining token from Schedules Direct from addres: " + httpOptions.Url + " with body " + //_logger.Info("Obtaining token from Schedules Direct from addres: " + httpOptions.Url + " with body " +
// httpOptions.RequestContent); // httpOptions.RequestContent);
@ -633,7 +639,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
Url = ApiUrl + "/lineups/" + info.ListingsId, Url = ApiUrl + "/lineups/" + info.ListingsId,
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken CancellationToken = cancellationToken,
LogErrorResponseBody = true
}; };
httpOptions.RequestHeaders["token"] = token; httpOptions.RequestHeaders["token"] = token;
@ -673,7 +680,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
Url = ApiUrl + "/lineups", Url = ApiUrl + "/lineups",
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken CancellationToken = cancellationToken,
LogErrorResponseBody = true
}; };
options.RequestHeaders["token"] = token; options.RequestHeaders["token"] = token;

@ -734,15 +734,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
recording.IsSports = info.IsSports; recording.IsSports = info.IsSports;
recording.SeriesTimerId = info.SeriesTimerId; recording.SeriesTimerId = info.SeriesTimerId;
recording.StartDate = info.StartDate; recording.StartDate = info.StartDate;
var statusChanged = info.Status != recording.Status;
recording.Status = info.Status; recording.Status = info.Status;
recording.ServiceName = serviceName; recording.ServiceName = serviceName;
var originalPath = item.Path; var pathChanged = false;
if (!string.IsNullOrEmpty(info.Path)) if (!string.IsNullOrEmpty(info.Path))
{ {
item.Path = info.Path; pathChanged = !string.Equals(item.Path, info.Path);
var fileInfo = _fileSystem.GetFileInfo(info.Path); var fileInfo = _fileSystem.GetFileInfo(info.Path);
recording.DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo); recording.DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo);
@ -750,16 +753,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv
} }
else if (!string.IsNullOrEmpty(info.Url)) else if (!string.IsNullOrEmpty(info.Url))
{ {
pathChanged = !string.Equals(item.Path, info.Url);
item.Path = info.Url; item.Path = info.Url;
} }
var pathChanged = !string.Equals(originalPath, item.Path);
if (isNew) if (isNew)
{ {
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
} }
else if (pathChanged || info.DateLastUpdated > recording.DateLastSaved || info.Status != recording.Status) else if (pathChanged || info.DateLastUpdated > recording.DateLastSaved || statusChanged)
{ {
await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false); await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
} }
@ -1388,25 +1390,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}; };
} }
public void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, User user = null) public void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, bool addChannelInfo, User user = null)
{ {
var program = (LiveTvProgram)item; var program = (LiveTvProgram)item;
var service = GetService(program); var service = GetService(program);
var channel = GetInternalChannel(program.ChannelId);
dto.Id = _tvDtoService.GetInternalProgramId(service.Name, program.ExternalId).ToString("N"); dto.Id = _tvDtoService.GetInternalProgramId(service.Name, program.ExternalId).ToString("N");
dto.StartDate = program.StartDate; dto.StartDate = program.StartDate;
dto.IsRepeat = program.IsRepeat;
dto.EpisodeTitle = program.EpisodeTitle; dto.EpisodeTitle = program.EpisodeTitle;
dto.ChannelType = program.ChannelType;
dto.Audio = program.Audio; dto.Audio = program.Audio;
if (program.IsHD.HasValue && program.IsHD.Value) if (program.IsHD.HasValue && program.IsHD.Value)
{ {
dto.IsHD = program.IsHD; dto.IsHD = program.IsHD;
} }
if (program.IsRepeat)
{
dto.IsRepeat = program.IsRepeat;
}
if (program.IsMovie) if (program.IsMovie)
{ {
dto.IsMovie = program.IsMovie; dto.IsMovie = program.IsMovie;
@ -1436,13 +1438,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
dto.IsPremiere = program.IsPremiere; dto.IsPremiere = program.IsPremiere;
} }
if (channel != null) if (addChannelInfo)
{ {
dto.ChannelName = channel.Name; var channel = GetInternalChannel(program.ChannelId);
if (!string.IsNullOrEmpty(channel.PrimaryImagePath)) if (channel != null)
{ {
dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel); dto.ChannelName = channel.Name;
if (!string.IsNullOrEmpty(channel.PrimaryImagePath))
{
dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel);
}
} }
} }
} }

Loading…
Cancel
Save