The Free Software Media System - Server Backend & API
Add support for legacy HDhomerun DUAl
Bond_009ead4e1e977b0
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.csindex 4aa5832b18..b6124753f2 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs@@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun{var model = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false);- using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(model.LineupURL, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);+ using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(model.LineupURL ?? model.BaseURL + "/lineup.json", HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);var lineup = await JsonSerializer.DeserializeAsync<List<Channels>>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false) ?? new List<Channels>();diff --git a/tests/Jellyfin.Server.Implementations.Tests/LiveTv/HdHomerunHostTests.cs b/tests/Jellyfin.Server.Implementations.Tests/LiveTv/HdHomerunHostTests.csindex 8847239d90..c859d11c69 100644--- a/tests/Jellyfin.Server.Implementations.Tests/LiveTv/HdHomerunHostTests.cs+++ b/tests/Jellyfin.Server.Implementations.Tests/LiveTv/HdHomerunHostTests.cs@@ -1,6 +1,7 @@using System;using System.IO;using System.Net.Http;+using System.Text.Json;using System.Threading;using System.Threading.Tasks;using AutoFixture;@@ -15,8 +16,6 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv{public class HdHomerunHostTests{- private const string TestIp = "http://192.168.1.182";-private readonly Fixture _fixture;private readonly HdHomerunHost _hdHomerunHost;@@ -30,7 +29,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv{return Task.FromResult(new HttpResponseMessage(){- Content = new StreamContent(File.OpenRead("Test Data/LiveTv/" + m.RequestUri?.Segments[^1]))+ Content = new StreamContent(File.OpenRead(Path.Combine("Test Data/LiveTv", m.RequestUri!.Host, m.RequestUri.Segments[^1])))});});@@ -50,7 +49,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv{var host = new TunerHostInfo(){- Url = TestIp+ Url = "192.168.1.182"};var modelInfo = await _hdHomerunHost.GetModelInfo(host, true, CancellationToken.None).ConfigureAwait(false);@@ -65,6 +64,26 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTvAssert.Equal("http://192.168.1.182:80/lineup.json", modelInfo.LineupURL);}+ [Fact]+ public async Task GetModelInfo_Legacy_Success()+ {+ var host = new TunerHostInfo()+ {+ Url = "10.10.10.100"+ };++ var modelInfo = await _hdHomerunHost.GetModelInfo(host, true, CancellationToken.None).ConfigureAwait(false);+ Assert.Equal("HDHomeRun DUAL", modelInfo.FriendlyName);+ Assert.Equal("HDHR3-US", modelInfo.ModelNumber);+ Assert.Equal("hdhomerun3_atsc", modelInfo.FirmwareName);+ Assert.Equal("20200225", modelInfo.FirmwareVersion);+ Assert.Equal("10xxxxx5", modelInfo.DeviceID);+ Assert.Null(modelInfo.DeviceAuth);+ Assert.Equal(2, modelInfo.TunerCount);+ Assert.Equal("http://10.10.10.100:80", modelInfo.BaseURL);+ Assert.Null(modelInfo.LineupURL);+ }+[Fact]public async Task GetModelInfo_EmptyUrl_ArgumentException(){@@ -81,7 +100,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv{var host = new TunerHostInfo(){- Url = TestIp+ Url = "192.168.1.182"};var channels = await _hdHomerunHost.GetLineup(host, CancellationToken.None).ConfigureAwait(false);@@ -93,12 +112,24 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTvAssert.Equal("http://192.168.1.111:5004/auto/v4.1", channels[0].URL);}+ [Fact]+ public async Task GetLineup_Legacy_Success()+ {+ var host = new TunerHostInfo()+ {+ Url = "10.10.10.100"+ };++ // Placeholder json is invalid, just need to make sure we can reach it+ await Assert.ThrowsAsync<JsonException>(() => _hdHomerunHost.GetLineup(host, CancellationToken.None));+ }+[Fact]public async Task GetLineup_ImportFavoritesOnly_Success(){var host = new TunerHostInfo(){- Url = TestIp,+ Url = "192.168.1.182",ImportFavoritesOnly = true};@@ -114,9 +145,9 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv[Fact]public async Task TryGetTunerHostInfo_Valid_Success(){- var host = await _hdHomerunHost.TryGetTunerHostInfo(TestIp, CancellationToken.None).ConfigureAwait(false);+ var host = await _hdHomerunHost.TryGetTunerHostInfo("192.168.1.182", CancellationToken.None).ConfigureAwait(false);Assert.Equal(_hdHomerunHost.Type, host.Type);- Assert.Equal(TestIp, host.Url);+ Assert.Equal("192.168.1.182", host.Url);Assert.Equal("HDHomeRun PRIME", host.FriendlyName);Assert.Equal("FFFFFFFF", host.DeviceId);Assert.Equal(3, host.TunerCount);diff --git a/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/10.10.10.100/discover.json b/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/10.10.10.100/discover.jsonnew file mode 100644index 0000000000..a4ad4ed444--- /dev/null+++ b/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/10.10.10.100/discover.json@@ -0,0 +1 @@+{"FriendlyName":"HDHomeRun DUAL","ModelNumber":"HDHR3-US","Legacy":1,"FirmwareName":"hdhomerun3_atsc","FirmwareVersion":"20200225","DeviceID":"10xxxxx5","TunerCount":2,"BaseURL":"http://10.10.10.100:80"}diff --git a/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/10.10.10.100/lineup.json b/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/10.10.10.100/lineup.jsonnew file mode 100644index 0000000000..0967ef424b--- /dev/null+++ b/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/10.10.10.100/lineup.json@@ -0,0 +1 @@+{}diff --git a/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/discover.json b/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/192.168.1.182/discover.jsonsimilarity index 100%rename from tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/discover.jsonrename to tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/192.168.1.182/discover.jsondiff --git a/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/lineup.json b/tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/192.168.1.182/lineup.jsonsimilarity index 100%rename from tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/lineup.jsonrename to tests/Jellyfin.Server.Implementations.Tests/Test Data/LiveTv/192.168.1.182/lineup.json