LegacyHdHomerunChannelCommands.cs 1.1 KB

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