You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
3 years ago
|
#pragma warning disable CS1591
|
||
|
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text.RegularExpressions;
|
||
|
|
||
5 months ago
|
namespace Jellyfin.LiveTv.TunerHosts.HdHomerun
|
||
3 years ago
|
{
|
||
1 year ago
|
public partial class LegacyHdHomerunChannelCommands : IHdHomerunChannelCommands
|
||
3 years ago
|
{
|
||
|
private string? _channel;
|
||
|
private string? _program;
|
||
|
|
||
|
public LegacyHdHomerunChannelCommands(string url)
|
||
|
{
|
||
|
// parse url for channel and program
|
||
1 year ago
|
var match = ChannelAndProgramRegex().Match(url);
|
||
3 years ago
|
if (match.Success)
|
||
|
{
|
||
|
_channel = match.Groups[1].Value;
|
||
|
_program = match.Groups[2].Value;
|
||
|
}
|
||
|
}
|
||
|
|
||
1 year ago
|
[GeneratedRegex(@"\/ch([0-9]+)-?([0-9]*)")]
|
||
|
private static partial Regex ChannelAndProgramRegex();
|
||
|
|
||
2 years ago
|
public IEnumerable<(string CommandName, string CommandValue)> GetCommands()
|
||
3 years ago
|
{
|
||
|
if (!string.IsNullOrEmpty(_channel))
|
||
|
{
|
||
|
yield return ("channel", _channel);
|
||
|
}
|
||
|
|
||
|
if (!string.IsNullOrEmpty(_program))
|
||
|
{
|
||
|
yield return ("program", _program);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|