LegacyHdHomerunChannelCommands.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 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 regExp = new Regex(@"\/ch([0-9]+)-?([0-9]*)");
  14. var match = regExp.Match(url);
  15. if (match.Success)
  16. {
  17. _channel = match.Groups[1].Value;
  18. _program = match.Groups[2].Value;
  19. }
  20. }
  21. public IEnumerable<(string CommandName, string CommandValue)> GetCommands()
  22. {
  23. if (!string.IsNullOrEmpty(_channel))
  24. {
  25. yield return ("channel", _channel);
  26. }
  27. if (!string.IsNullOrEmpty(_program))
  28. {
  29. yield return ("program", _program);
  30. }
  31. }
  32. }
  33. }