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

@@ -400,13 +400,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
_logger.Info("Headends on account ");
var countryParam = string.Equals("ca", country, StringComparison.OrdinalIgnoreCase)
? "can"
: "USA";
var options = new HttpRequestOptions()
{
Url = ApiUrl + "/headends?country=" + countryParam + "&postalcode=" + location,
Url = ApiUrl + "/headends?country=" + country + "&postalcode=" + location,
UserAgent = UserAgent,
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");
}
}
var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false);
if (!hasLineup)
if (validateListings)
{
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
}
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
}

View File

@@ -2204,7 +2204,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_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));
@@ -2215,7 +2215,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
throw new ResourceNotFoundException();
}
await provider.Validate(info).ConfigureAwait(false);
await provider.Validate(info, validateLogin, validateListings).ConfigureAwait(false);
var config = GetConfiguration();