aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/LiveTv/LiveTvService.cs5
-rw-r--r--MediaBrowser.Controller/LiveTv/IListingsProvider.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvManager.cs3
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs14
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs4
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs15
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs20
7 files changed, 45 insertions, 18 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index f40048ce4..d05e0951a 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -369,6 +369,9 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "Location", Description = "Location", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string Location { get; set; }
+
+ [ApiMember(Name = "Country", Description = "Country", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string Country { get; set; }
}
public class LiveTvService : BaseApiService
@@ -436,7 +439,7 @@ namespace MediaBrowser.Api.LiveTv
public async Task<object> Get(GetLineups request)
{
- var info = await _liveTvManager.GetLineups(request.Id, request.Location).ConfigureAwait(false);
+ var info = await _liveTvManager.GetLineups(request.Id, request.Country, request.Location).ConfigureAwait(false);
return ToOptimizedSerializedResultUsingCache(info);
}
diff --git a/MediaBrowser.Controller/LiveTv/IListingsProvider.cs b/MediaBrowser.Controller/LiveTv/IListingsProvider.cs
index 54977c8d3..5e43f1d27 100644
--- a/MediaBrowser.Controller/LiveTv/IListingsProvider.cs
+++ b/MediaBrowser.Controller/LiveTv/IListingsProvider.cs
@@ -14,6 +14,6 @@ namespace MediaBrowser.Controller.LiveTv
Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken);
Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken);
Task Validate(ListingsProviderInfo info);
- Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string location);
+ Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location);
}
}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index 3dbf9a9e9..a0deb34f0 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -355,8 +355,9 @@ namespace MediaBrowser.Controller.LiveTv
/// Gets the lineups.
/// </summary>
/// <param name="providerId">The provider identifier.</param>
+ /// <param name="country">The country.</param>
/// <param name="location">The location.</param>
/// <returns>Task&lt;List&lt;NameIdPair&gt;&gt;.</returns>
- Task<List<NameIdPair>> GetLineups(string providerId, string location);
+ Task<List<NameIdPair>> GetLineups(string providerId, string country, string location);
}
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index 269da5768..ed265d416 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -387,7 +387,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
return images;
}
- public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string location, CancellationToken cancellationToken)
+ public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken)
{
var token = await GetToken(info, cancellationToken);
@@ -400,9 +400,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
_logger.Info("Headends on account ");
+ var countryParam = string.Equals("ca", country, StringComparison.OrdinalIgnoreCase)
+ ? "Canada"
+ : "USA";
+
var options = new HttpRequestOptions()
{
- Url = ApiUrl + "/headends?country=USA&postalcode=" + location,
+ Url = ApiUrl + "/headends?country=" + countryParam + "&postalcode=" + location,
UserAgent = UserAgent,
CancellationToken = cancellationToken
};
@@ -839,12 +843,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
public async Task Validate(ListingsProviderInfo info)
{
- await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false);
+ //await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false);
}
- public Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string location)
+ public Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location)
{
- return GetHeadends(info, location, CancellationToken.None);
+ return GetHeadends(info, country, location, CancellationToken.None);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 52bb41ba1..5be90e6cc 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -2238,7 +2238,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return info;
}
- public Task<List<NameIdPair>> GetLineups(string providerId, string location)
+ public Task<List<NameIdPair>> GetLineups(string providerId, string country, string location)
{
var config = GetConfiguration();
@@ -2251,7 +2251,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
throw new ResourceNotFoundException();
}
- return provider.GetLineups(info, location);
+ return provider.GetLineups(info, country, location);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
index de2351434..7cb616d3f 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
@@ -1,5 +1,7 @@
-using MediaBrowser.Common.ScheduledTasks;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
@@ -10,10 +12,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
{
private readonly ILiveTvManager _liveTvManager;
+ private readonly IConfigurationManager _config;
- public RefreshChannelsScheduledTask(ILiveTvManager liveTvManager)
+ public RefreshChannelsScheduledTask(ILiveTvManager liveTvManager, IConfigurationManager config)
{
_liveTvManager = liveTvManager;
+ _config = config;
}
public string Name
@@ -50,9 +54,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
};
}
+ private LiveTvOptions GetConfiguration()
+ {
+ return _config.GetConfiguration<LiveTvOptions>("livetv");
+ }
+
public bool IsHidden
{
- get { return _liveTvManager.Services.Count == 0; }
+ get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Count == 0; }
}
public bool IsEnabled
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs
index 41652ae9f..4777003d6 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs
@@ -91,15 +91,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private bool UriEquals(string savedUri, string location)
{
- if (!savedUri.StartsWith("http", StringComparison.OrdinalIgnoreCase))
+ return string.Equals(NormalizeUrl(location), NormalizeUrl(savedUri), StringComparison.OrdinalIgnoreCase);
+ }
+
+ private string NormalizeUrl(string url)
+ {
+ if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
{
- savedUri = "http://" + savedUri;
+ url = "http://" + url;
}
- savedUri = savedUri.TrimEnd('/');
- location = location.TrimEnd('/');
+ url = url.TrimEnd('/');
+
+ // If there isn't a port, add the default port of 80
+ if (url.Split(':').Length < 3)
+ {
+ url += ":80";
+ }
- return string.Equals(location, savedUri, StringComparison.OrdinalIgnoreCase);
+ return url;
}
private LiveTvOptions GetConfiguration()