2021-10-06 09:30:45 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|
|
|
{
|
2023-05-22 20:48:09 +00:00
|
|
|
public partial class LegacyHdHomerunChannelCommands : IHdHomerunChannelCommands
|
2021-10-06 09:30:45 +00:00
|
|
|
{
|
|
|
|
private string? _channel;
|
|
|
|
private string? _program;
|
|
|
|
|
|
|
|
public LegacyHdHomerunChannelCommands(string url)
|
|
|
|
{
|
|
|
|
// parse url for channel and program
|
2023-05-22 20:48:09 +00:00
|
|
|
var match = ChannelAndProgramRegex().Match(url);
|
2021-10-06 09:30:45 +00:00
|
|
|
if (match.Success)
|
|
|
|
{
|
|
|
|
_channel = match.Groups[1].Value;
|
|
|
|
_program = match.Groups[2].Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 20:48:09 +00:00
|
|
|
[GeneratedRegex(@"\/ch([0-9]+)-?([0-9]*)")]
|
|
|
|
private static partial Regex ChannelAndProgramRegex();
|
|
|
|
|
2021-12-24 21:18:24 +00:00
|
|
|
public IEnumerable<(string CommandName, string CommandValue)> GetCommands()
|
2021-10-06 09:30:45 +00:00
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(_channel))
|
|
|
|
{
|
|
|
|
yield return ("channel", _channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_program))
|
|
|
|
{
|
|
|
|
yield return ("program", _program);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|