Merge pull request #5999 from Bond-009/legacyhdhomerun
Add support for legacy HDhomerun DUAl
This commit is contained in:
commit
5acb4e9491
|
@ -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>();
|
||||
|
|
|
@ -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.LiveTv
|
|||
Assert.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.LiveTv
|
|||
Assert.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);
|
||||
|
|
|
@ -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"}
|
|
@ -0,0 +1 @@
|
|||
{}
|
Loading…
Reference in New Issue
Block a user