aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/LiveTv/Listings
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-09-01 15:18:25 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-09-01 15:18:25 -0400
commit3d8287bc6e3ee5b2b7377a2ddc73ef364f84fef2 (patch)
tree94dfb311afd2efaa898662b76ed5ff04f77cb2f4 /MediaBrowser.Server.Implementations/LiveTv/Listings
parentd8c8e57a0ba2b3fe6981c577164f6cf0ecef3722 (diff)
fix metadata manager layout
Diffstat (limited to 'MediaBrowser.Server.Implementations/LiveTv/Listings')
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs22
1 files changed, 20 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index cb5a374010..3d02ac02ec 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -64,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{
List<ProgramInfo> programsInfo = new List<ProgramInfo>();
- var token = await GetToken(info, cancellationToken);
+ var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(token))
{
@@ -482,7 +482,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
}
private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
-
+ private DateTime _lastErrorResponse;
private async Task<string> GetToken(ListingsProviderInfo info, CancellationToken cancellationToken)
{
var username = info.Username;
@@ -499,6 +499,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
return null;
}
+ // Avoid hammering SD
+ if ((DateTime.UtcNow - _lastErrorResponse).TotalMinutes < 1)
+ {
+ return null;
+ }
+
NameValuePair savedToken = null;
if (!_tokens.TryGetValue(username, out savedToken))
{
@@ -527,6 +533,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
savedToken.Value = DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture);
return result;
}
+ catch (HttpException ex)
+ {
+ if (ex.StatusCode.HasValue)
+ {
+ if ((int)ex.StatusCode.Value == 400)
+ {
+ _tokens.Clear();
+ _lastErrorResponse = DateTime.UtcNow;
+ }
+ }
+ throw;
+ }
finally
{
_tokenSemaphore.Release();