update schedules direct

This commit is contained in:
Luke Pulverenti 2015-07-25 13:21:10 -04:00
parent 6a6145294a
commit 14f97d6176
12 changed files with 78 additions and 48 deletions

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.LiveTv;
@ -10,6 +9,7 @@ using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using ServiceStack; using ServiceStack;
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -350,6 +350,8 @@ namespace MediaBrowser.Api.LiveTv
[Authenticated] [Authenticated]
public class AddListingProvider : ListingsProviderInfo, IReturn<ListingsProviderInfo> public class AddListingProvider : ListingsProviderInfo, IReturn<ListingsProviderInfo>
{ {
public bool ValidateLogin { get; set; }
public bool ValidateListings { get; set; }
} }
[Route("/LiveTv/ListingProviders", "DELETE", Summary = "Deletes a listing provider")] [Route("/LiveTv/ListingProviders", "DELETE", Summary = "Deletes a listing provider")]
@ -402,9 +404,9 @@ namespace MediaBrowser.Api.LiveTv
} }
} }
public object Post(AddListingProvider request) public async Task<object> Post(AddListingProvider request)
{ {
var result = _liveTvManager.SaveListingProvider(request).Result; var result = await _liveTvManager.SaveListingProvider(request, request.ValidateLogin, request.ValidateListings).ConfigureAwait(false);
return ToOptimizedResult(result); return ToOptimizedResult(result);
} }

View File

@ -819,11 +819,11 @@ namespace MediaBrowser.Api.Playback
/// <summary> /// <summary>
/// Gets the audio encoder. /// Gets the audio encoder.
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="state">The state.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
protected string GetAudioEncoder(StreamRequest request) protected string GetAudioEncoder(StreamState state)
{ {
var codec = request.AudioCodec; var codec = state.OutputAudioCodec;
if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase))
{ {
@ -848,11 +848,11 @@ namespace MediaBrowser.Api.Playback
/// <summary> /// <summary>
/// Gets the name of the output video codec /// Gets the name of the output video codec
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="state">The state.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
protected string GetVideoEncoder(VideoStreamRequest request) protected string GetVideoEncoder(StreamState state)
{ {
var codec = request.VideoCodec; var codec = state.OutputVideoCodec;
if (!string.IsNullOrEmpty(codec)) if (!string.IsNullOrEmpty(codec))
{ {

View File

@ -378,7 +378,7 @@ namespace MediaBrowser.Api.Playback.Dash
protected override string GetAudioArguments(StreamState state) protected override string GetAudioArguments(StreamState state)
{ {
var codec = GetAudioEncoder(state.Request); var codec = GetAudioEncoder(state);
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{ {
@ -408,7 +408,7 @@ namespace MediaBrowser.Api.Playback.Dash
protected override string GetVideoArguments(StreamState state) protected override string GetVideoArguments(StreamState state)
{ {
var codec = GetVideoEncoder(state.VideoRequest); var codec = GetVideoEncoder(state);
var args = "-codec:v:0 " + codec; var args = "-codec:v:0 " + codec;

View File

@ -791,7 +791,7 @@ namespace MediaBrowser.Api.Playback.Hls
protected override string GetAudioArguments(StreamState state) protected override string GetAudioArguments(StreamState state)
{ {
var codec = GetAudioEncoder(state.Request); var codec = GetAudioEncoder(state);
if (!state.IsOutputVideo) if (!state.IsOutputVideo)
{ {
@ -856,7 +856,7 @@ namespace MediaBrowser.Api.Playback.Hls
return string.Empty; return string.Empty;
} }
var codec = GetVideoEncoder(state.VideoRequest); var codec = GetVideoEncoder(state);
var args = "-codec:v:0 " + codec; var args = "-codec:v:0 " + codec;

View File

@ -48,7 +48,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
protected override string GetAudioArguments(StreamState state) protected override string GetAudioArguments(StreamState state)
{ {
var codec = GetAudioEncoder(state.Request); var codec = GetAudioEncoder(state);
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{ {
@ -83,7 +83,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
protected override string GetVideoArguments(StreamState state) protected override string GetVideoArguments(StreamState state)
{ {
var codec = GetVideoEncoder(state.VideoRequest); var codec = GetVideoEncoder(state);
var args = "-codec:v:0 " + codec; var args = "-codec:v:0 " + codec;

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Api.Playback.Progressive
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
{ {
// Get the output codec name // Get the output codec name
var videoCodec = GetVideoEncoder(state.VideoRequest); var videoCodec = GetVideoEncoder(state);
var format = string.Empty; var format = string.Empty;
var keyFrame = string.Empty; var keyFrame = string.Empty;
@ -183,7 +183,7 @@ namespace MediaBrowser.Api.Playback.Progressive
} }
// Get the output codec name // Get the output codec name
var codec = GetAudioEncoder(state.Request); var codec = GetAudioEncoder(state);
var args = "-codec:a:0 " + codec; var args = "-codec:a:0 " + codec;

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.LiveTv
string Type { get; } string Type { get; }
Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken); Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken);
Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken); Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken);
Task Validate(ListingsProviderInfo info); Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings);
Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location); Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location);
} }
} }

View File

@ -349,8 +349,10 @@ namespace MediaBrowser.Controller.LiveTv
/// Saves the listing provider. /// Saves the listing provider.
/// </summary> /// </summary>
/// <param name="info">The information.</param> /// <param name="info">The information.</param>
/// <param name="validateLogin">if set to <c>true</c> [validate login].</param>
/// <param name="validateListings">if set to <c>true</c> [validate listings].</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info); Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings);
/// <summary> /// <summary>
/// Gets the lineups. /// Gets the lineups.
/// </summary> /// </summary>

View File

@ -120,7 +120,7 @@ namespace MediaBrowser.Dlna.Didl
} }
} }
AddCover(item, null, element); AddCover(item, context, null, element);
return element; return element;
} }
@ -481,7 +481,7 @@ namespace MediaBrowser.Dlna.Didl
AddCommonFields(folder, stubType, null, container, filter); AddCommonFields(folder, stubType, null, container, filter);
AddCover(folder, stubType, container); AddCover(folder, context, stubType, container);
return container; return container;
} }
@ -764,7 +764,7 @@ namespace MediaBrowser.Dlna.Didl
} }
} }
private void AddCover(BaseItem item, StubType? stubType, XmlElement element) private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlElement element)
{ {
if (stubType.HasValue && stubType.Value == StubType.People) if (stubType.HasValue && stubType.Value == StubType.People)
{ {
@ -772,7 +772,26 @@ namespace MediaBrowser.Dlna.Didl
return; return;
} }
var imageInfo = GetImageInfo(item); ImageDownloadInfo imageInfo = null;
if (context is UserView)
{
var episode = item as Episode;
if (episode != null)
{
var parent = (BaseItem)episode.Series ?? episode.Season;
if (parent != null)
{
imageInfo = GetImageInfo(parent);
}
}
}
// Finally, just use the image from the item
if (imageInfo == null)
{
imageInfo = GetImageInfo(item);
}
if (imageInfo == null) if (imageInfo == null)
{ {
@ -850,7 +869,7 @@ namespace MediaBrowser.Dlna.Didl
private void AddEmbeddedImageAsCover(string name, XmlElement element) private void AddEmbeddedImageAsCover(string name, XmlElement element)
{ {
var result = element.OwnerDocument; var result = element.OwnerDocument;
var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP); var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP);
var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA); var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA);
profile.InnerText = _profile.AlbumArtPn; profile.InnerText = _profile.AlbumArtPn;
@ -925,14 +944,11 @@ namespace MediaBrowser.Dlna.Didl
} }
} }
if (item is Audio || item is Episode) item = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Primary));
{
item = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Primary));
if (item != null) if (item != null)
{ {
return GetImageInfo(item, ImageType.Primary); return GetImageInfo(item, ImageType.Primary);
}
} }
return null; return null;

View File

@ -400,13 +400,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
_logger.Info("Headends on account "); _logger.Info("Headends on account ");
var countryParam = string.Equals("ca", country, StringComparison.OrdinalIgnoreCase)
? "can"
: "USA";
var options = new HttpRequestOptions() var options = new HttpRequestOptions()
{ {
Url = ApiUrl + "/headends?country=" + countryParam + "&postalcode=" + location, Url = ApiUrl + "/headends?country=" + country + "&postalcode=" + location,
UserAgent = UserAgent, UserAgent = UserAgent,
CancellationToken = cancellationToken CancellationToken = cancellationToken
}; };
@ -595,18 +591,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
} }
} }
public async Task Validate(ListingsProviderInfo info) public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
{ {
if (string.IsNullOrWhiteSpace(info.ListingsId)) if (validateLogin)
{ {
throw new ArgumentException("Listings Id required"); if (string.IsNullOrWhiteSpace(info.Username))
{
throw new ArgumentException("Username is required");
}
if (string.IsNullOrWhiteSpace(info.Password))
{
throw new ArgumentException("Password is required");
}
} }
if (validateListings)
var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false);
if (!hasLineup)
{ {
await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(info.ListingsId))
{
throw new ArgumentException("Listings Id required");
}
var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false);
if (!hasLineup)
{
await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false);
}
} }
} }

View File

@ -30,7 +30,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
// Might not be needed // Might not be needed
} }
public Task Validate(ListingsProviderInfo info) public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
{ {
// Check that the path or url is valid. If not, throw a file not found exception // Check that the path or url is valid. If not, throw a file not found exception
} }

View File

@ -2204,7 +2204,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>(); _taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
} }
public async Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info) public async Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings)
{ {
info = (ListingsProviderInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(ListingsProviderInfo)); info = (ListingsProviderInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(ListingsProviderInfo));
@ -2215,7 +2215,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
throw new ResourceNotFoundException(); throw new ResourceNotFoundException();
} }
await provider.Validate(info).ConfigureAwait(false); await provider.Validate(info, validateLogin, validateListings).ConfigureAwait(false);
var config = GetConfiguration(); var config = GetConfiguration();