| | | 1 | | #pragma warning disable CS1591 |
| | | 2 | | |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Text.RegularExpressions; |
| | | 5 | | |
| | | 6 | | namespace Jellyfin.LiveTv.TunerHosts.HdHomerun |
| | | 7 | | { |
| | | 8 | | public partial class LegacyHdHomerunChannelCommands : IHdHomerunChannelCommands |
| | | 9 | | { |
| | | 10 | | private string? _channel; |
| | | 11 | | private string? _program; |
| | | 12 | | |
| | | 13 | | public LegacyHdHomerunChannelCommands(string url) |
| | | 14 | | { |
| | | 15 | | // parse url for channel and program |
| | 0 | 16 | | var match = ChannelAndProgramRegex().Match(url); |
| | 0 | 17 | | if (match.Success) |
| | | 18 | | { |
| | 0 | 19 | | _channel = match.Groups[1].Value; |
| | 0 | 20 | | _program = match.Groups[2].Value; |
| | | 21 | | } |
| | 0 | 22 | | } |
| | | 23 | | |
| | | 24 | | [GeneratedRegex(@"\/ch([0-9]+)-?([0-9]*)")] |
| | | 25 | | private static partial Regex ChannelAndProgramRegex(); |
| | | 26 | | |
| | | 27 | | public IEnumerable<(string CommandName, string CommandValue)> GetCommands() |
| | | 28 | | { |
| | | 29 | | if (!string.IsNullOrEmpty(_channel)) |
| | | 30 | | { |
| | | 31 | | yield return ("channel", _channel); |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | if (!string.IsNullOrEmpty(_program)) |
| | | 35 | | { |
| | | 36 | | yield return ("program", _program); |
| | | 37 | | } |
| | | 38 | | } |
| | | 39 | | } |
| | | 40 | | } |