LiveTvService.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. using MediaBrowser.Controller.Library;
  2. using MediaBrowser.Controller.LiveTv;
  3. using MediaBrowser.Model.Entities;
  4. using MediaBrowser.Model.LiveTv;
  5. using MediaBrowser.Model.Querying;
  6. using ServiceStack;
  7. using System;
  8. using System.Globalization;
  9. using System.Linq;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. namespace MediaBrowser.Api.LiveTv
  13. {
  14. [Route("/LiveTv/Info", "GET")]
  15. [Api(Description = "Gets available live tv services.")]
  16. public class GetLiveTvInfo : IReturn<LiveTvInfo>
  17. {
  18. }
  19. [Route("/LiveTv/Channels", "GET")]
  20. [Api(Description = "Gets available live tv channels.")]
  21. public class GetChannels : IReturn<QueryResult<ChannelInfoDto>>
  22. {
  23. [ApiMember(Name = "Type", Description = "Optional filter by channel type.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  24. public ChannelType? Type { get; set; }
  25. [ApiMember(Name = "UserId", Description = "Optional filter by user and attach user data.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  26. public string UserId { get; set; }
  27. /// <summary>
  28. /// Skips over a given number of items within the results. Use for paging.
  29. /// </summary>
  30. /// <value>The start index.</value>
  31. [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  32. public int? StartIndex { get; set; }
  33. /// <summary>
  34. /// The maximum number of items to return
  35. /// </summary>
  36. /// <value>The limit.</value>
  37. [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  38. public int? Limit { get; set; }
  39. }
  40. [Route("/LiveTv/Channels/{Id}", "GET")]
  41. [Api(Description = "Gets a live tv channel")]
  42. public class GetChannel : IReturn<ChannelInfoDto>
  43. {
  44. /// <summary>
  45. /// Gets or sets the id.
  46. /// </summary>
  47. /// <value>The id.</value>
  48. [ApiMember(Name = "Id", Description = "Channel Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  49. public string Id { get; set; }
  50. [ApiMember(Name = "UserId", Description = "Optional attach user data.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  51. public string UserId { get; set; }
  52. }
  53. [Route("/LiveTv/Recordings", "GET")]
  54. [Api(Description = "Gets live tv recordings")]
  55. public class GetRecordings : IReturn<QueryResult<RecordingInfoDto>>
  56. {
  57. [ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  58. public string ChannelId { get; set; }
  59. [ApiMember(Name = "UserId", Description = "Optional filter by user and attach user data.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  60. public string UserId { get; set; }
  61. [ApiMember(Name = "GroupId", Description = "Optional filter by recording group.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  62. public string GroupId { get; set; }
  63. [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  64. public int? StartIndex { get; set; }
  65. [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  66. public int? Limit { get; set; }
  67. [ApiMember(Name = "Status", Description = "Optional filter by recording status.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  68. public RecordingStatus? Status { get; set; }
  69. [ApiMember(Name = "Status", Description = "Optional filter by recordings that are in progress, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  70. public bool? IsInProgress { get; set; }
  71. [ApiMember(Name = "SeriesTimerId", Description = "Optional filter by recordings belonging to a series timer", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  72. public string SeriesTimerId { get; set; }
  73. }
  74. [Route("/LiveTv/Recordings/Groups", "GET")]
  75. [Api(Description = "Gets live tv recording groups")]
  76. public class GetRecordingGroups : IReturn<QueryResult<RecordingGroupDto>>
  77. {
  78. [ApiMember(Name = "UserId", Description = "Optional filter by user and attach user data.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  79. public string UserId { get; set; }
  80. }
  81. [Route("/LiveTv/Recordings/{Id}", "GET")]
  82. [Api(Description = "Gets a live tv recording")]
  83. public class GetRecording : IReturn<RecordingInfoDto>
  84. {
  85. [ApiMember(Name = "Id", Description = "Recording Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  86. public string Id { get; set; }
  87. [ApiMember(Name = "UserId", Description = "Optional attach user data.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  88. public string UserId { get; set; }
  89. }
  90. [Route("/LiveTv/Tuners/{Id}/Reset", "POST")]
  91. [Api(Description = "Resets a tv tuner")]
  92. public class ResetTuner : IReturnVoid
  93. {
  94. [ApiMember(Name = "Id", Description = "Tuner Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  95. public string Id { get; set; }
  96. }
  97. [Route("/LiveTv/Timers/{Id}", "GET")]
  98. [Api(Description = "Gets a live tv timer")]
  99. public class GetTimer : IReturn<TimerInfoDto>
  100. {
  101. [ApiMember(Name = "Id", Description = "Timer Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  102. public string Id { get; set; }
  103. }
  104. [Route("/LiveTv/Timers/Defaults", "GET")]
  105. [Api(Description = "Gets default values for a new timer")]
  106. public class GetDefaultTimer : IReturn<SeriesTimerInfoDto>
  107. {
  108. [ApiMember(Name = "ProgramId", Description = "Optional, to attach default values based on a program.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  109. public string ProgramId { get; set; }
  110. }
  111. [Route("/LiveTv/Timers", "GET")]
  112. [Api(Description = "Gets live tv timers")]
  113. public class GetTimers : IReturn<QueryResult<TimerInfoDto>>
  114. {
  115. [ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  116. public string ChannelId { get; set; }
  117. [ApiMember(Name = "SeriesTimerId", Description = "Optional filter by timers belonging to a series timer", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  118. public string SeriesTimerId { get; set; }
  119. }
  120. [Route("/LiveTv/Programs", "GET,POST")]
  121. [Api(Description = "Gets available live tv epgs..")]
  122. public class GetPrograms : IReturn<QueryResult<ProgramInfoDto>>
  123. {
  124. [ApiMember(Name = "ChannelIds", Description = "The channels to return guide information for.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  125. public string ChannelIds { get; set; }
  126. [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  127. public string UserId { get; set; }
  128. [ApiMember(Name = "MinStartDate", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  129. public string MinStartDate { get; set; }
  130. [ApiMember(Name = "MaxStartDate", Description = "Optional. The maximum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  131. public string MaxStartDate { get; set; }
  132. [ApiMember(Name = "MinEndDate", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  133. public string MinEndDate { get; set; }
  134. [ApiMember(Name = "MaxEndDate", Description = "Optional. The maximum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  135. public string MaxEndDate { get; set; }
  136. }
  137. [Route("/LiveTv/Programs/Recommended", "GET")]
  138. [Api(Description = "Gets available live tv epgs..")]
  139. public class GetRecommendedPrograms : IReturn<QueryResult<ProgramInfoDto>>
  140. {
  141. [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  142. public string UserId { get; set; }
  143. [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  144. public int? Limit { get; set; }
  145. [ApiMember(Name = "IsAiring", Description = "Optional. Filter by programs that are currently airing, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  146. public bool? IsAiring { get; set; }
  147. [ApiMember(Name = "HasAired", Description = "Optional. Filter by programs that have completed airing, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  148. public bool? HasAired { get; set; }
  149. }
  150. [Route("/LiveTv/Programs/{Id}", "GET")]
  151. [Api(Description = "Gets a live tv program")]
  152. public class GetProgram : IReturn<ProgramInfoDto>
  153. {
  154. [ApiMember(Name = "Id", Description = "Program Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  155. public string Id { get; set; }
  156. [ApiMember(Name = "UserId", Description = "Optional attach user data.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  157. public string UserId { get; set; }
  158. }
  159. [Route("/LiveTv/Recordings/{Id}", "DELETE")]
  160. [Api(Description = "Deletes a live tv recording")]
  161. public class DeleteRecording : IReturnVoid
  162. {
  163. [ApiMember(Name = "Id", Description = "Recording Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  164. public string Id { get; set; }
  165. }
  166. [Route("/LiveTv/Timers/{Id}", "DELETE")]
  167. [Api(Description = "Cancels a live tv timer")]
  168. public class CancelTimer : IReturnVoid
  169. {
  170. [ApiMember(Name = "Id", Description = "Timer Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  171. public string Id { get; set; }
  172. }
  173. [Route("/LiveTv/Timers/{Id}", "POST")]
  174. [Api(Description = "Updates a live tv timer")]
  175. public class UpdateTimer : TimerInfoDto, IReturnVoid
  176. {
  177. }
  178. [Route("/LiveTv/Timers", "POST")]
  179. [Api(Description = "Creates a live tv timer")]
  180. public class CreateTimer : TimerInfoDto, IReturnVoid
  181. {
  182. }
  183. [Route("/LiveTv/SeriesTimers/{Id}", "GET")]
  184. [Api(Description = "Gets a live tv series timer")]
  185. public class GetSeriesTimer : IReturn<TimerInfoDto>
  186. {
  187. [ApiMember(Name = "Id", Description = "Timer Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  188. public string Id { get; set; }
  189. }
  190. [Route("/LiveTv/SeriesTimers", "GET")]
  191. [Api(Description = "Gets live tv series timers")]
  192. public class GetSeriesTimers : IReturn<QueryResult<SeriesTimerInfoDto>>
  193. {
  194. [ApiMember(Name = "SortBy", Description = "Optional. Sort by SortName or Priority", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  195. public string SortBy { get; set; }
  196. [ApiMember(Name = "SortOrder", Description = "Optional. Sort in Ascending or Descending order", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
  197. public SortOrder SortOrder { get; set; }
  198. }
  199. [Route("/LiveTv/SeriesTimers/{Id}", "DELETE")]
  200. [Api(Description = "Cancels a live tv series timer")]
  201. public class CancelSeriesTimer : IReturnVoid
  202. {
  203. [ApiMember(Name = "Id", Description = "Timer Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  204. public string Id { get; set; }
  205. }
  206. [Route("/LiveTv/SeriesTimers/{Id}", "POST")]
  207. [Api(Description = "Updates a live tv series timer")]
  208. public class UpdateSeriesTimer : SeriesTimerInfoDto, IReturnVoid
  209. {
  210. }
  211. [Route("/LiveTv/SeriesTimers", "POST")]
  212. [Api(Description = "Creates a live tv series timer")]
  213. public class CreateSeriesTimer : SeriesTimerInfoDto, IReturnVoid
  214. {
  215. }
  216. [Route("/LiveTv/Recordings/Groups/{Id}", "GET")]
  217. [Api(Description = "Gets a recording group")]
  218. public class GetRecordingGroup : IReturn<RecordingGroupDto>
  219. {
  220. [ApiMember(Name = "Id", Description = "Recording group Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  221. public string Id { get; set; }
  222. }
  223. [Route("/LiveTv/GuideInfo", "GET")]
  224. [Api(Description = "Gets guide info")]
  225. public class GetGuideInfo : IReturn<GuideInfo>
  226. {
  227. }
  228. public class LiveTvService : BaseApiService
  229. {
  230. private readonly ILiveTvManager _liveTvManager;
  231. private readonly IUserManager _userManager;
  232. public LiveTvService(ILiveTvManager liveTvManager, IUserManager userManager)
  233. {
  234. _liveTvManager = liveTvManager;
  235. _userManager = userManager;
  236. }
  237. private void AssertUserCanManageLiveTv()
  238. {
  239. var user = AuthorizationRequestFilterAttribute.GetCurrentUser(Request, _userManager);
  240. if (user == null)
  241. {
  242. throw new UnauthorizedAccessException("Anonymous live tv management is not allowed.");
  243. }
  244. if (!user.Configuration.EnableLiveTvManagement)
  245. {
  246. throw new UnauthorizedAccessException("The current user does not have permission to manage live tv.");
  247. }
  248. }
  249. public object Get(GetLiveTvInfo request)
  250. {
  251. var info = _liveTvManager.GetLiveTvInfo(CancellationToken.None).Result;
  252. return ToOptimizedResult(info);
  253. }
  254. public object Get(GetChannels request)
  255. {
  256. var result = _liveTvManager.GetChannels(new ChannelQuery
  257. {
  258. ChannelType = request.Type,
  259. UserId = request.UserId,
  260. StartIndex = request.StartIndex,
  261. Limit = request.Limit
  262. }, CancellationToken.None).Result;
  263. return ToOptimizedResult(result);
  264. }
  265. public object Get(GetChannel request)
  266. {
  267. var user = string.IsNullOrEmpty(request.UserId) ? null : _userManager.GetUserById(new Guid(request.UserId));
  268. var result = _liveTvManager.GetChannel(request.Id, CancellationToken.None, user).Result;
  269. return ToOptimizedResult(result);
  270. }
  271. public object Get(GetPrograms request)
  272. {
  273. var query = new ProgramQuery
  274. {
  275. ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray(),
  276. UserId = request.UserId
  277. };
  278. if (!string.IsNullOrEmpty(request.MinStartDate))
  279. {
  280. query.MinStartDate = DateTime.Parse(request.MinStartDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime();
  281. }
  282. if (!string.IsNullOrEmpty(request.MinEndDate))
  283. {
  284. query.MinEndDate = DateTime.Parse(request.MinEndDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime();
  285. }
  286. if (!string.IsNullOrEmpty(request.MaxStartDate))
  287. {
  288. query.MaxStartDate = DateTime.Parse(request.MaxStartDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime();
  289. }
  290. if (!string.IsNullOrEmpty(request.MaxEndDate))
  291. {
  292. query.MaxEndDate = DateTime.Parse(request.MaxEndDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime();
  293. }
  294. var result = _liveTvManager.GetPrograms(query, CancellationToken.None).Result;
  295. return ToOptimizedResult(result);
  296. }
  297. public object Get(GetRecommendedPrograms request)
  298. {
  299. var query = new RecommendedProgramQuery
  300. {
  301. UserId = request.UserId,
  302. IsAiring = request.IsAiring,
  303. Limit = request.Limit,
  304. HasAired = request.HasAired
  305. };
  306. var result = _liveTvManager.GetRecommendedPrograms(query, CancellationToken.None).Result;
  307. return ToOptimizedResult(result);
  308. }
  309. public object Post(GetPrograms request)
  310. {
  311. return Get(request);
  312. }
  313. public object Get(GetRecordings request)
  314. {
  315. var result = _liveTvManager.GetRecordings(new RecordingQuery
  316. {
  317. ChannelId = request.ChannelId,
  318. UserId = request.UserId,
  319. GroupId = request.GroupId,
  320. StartIndex = request.StartIndex,
  321. Limit = request.Limit,
  322. Status = request.Status,
  323. SeriesTimerId = request.SeriesTimerId,
  324. IsInProgress = request.IsInProgress
  325. }, CancellationToken.None).Result;
  326. return ToOptimizedResult(result);
  327. }
  328. public object Get(GetRecording request)
  329. {
  330. var user = string.IsNullOrEmpty(request.UserId) ? null : _userManager.GetUserById(new Guid(request.UserId));
  331. var result = _liveTvManager.GetRecording(request.Id, CancellationToken.None, user).Result;
  332. return ToOptimizedResult(result);
  333. }
  334. public object Get(GetTimer request)
  335. {
  336. var result = _liveTvManager.GetTimer(request.Id, CancellationToken.None).Result;
  337. return ToOptimizedResult(result);
  338. }
  339. public object Get(GetTimers request)
  340. {
  341. var result = _liveTvManager.GetTimers(new TimerQuery
  342. {
  343. ChannelId = request.ChannelId,
  344. SeriesTimerId = request.SeriesTimerId
  345. }, CancellationToken.None).Result;
  346. return ToOptimizedResult(result);
  347. }
  348. public void Delete(DeleteRecording request)
  349. {
  350. AssertUserCanManageLiveTv();
  351. var task = _liveTvManager.DeleteRecording(request.Id);
  352. Task.WaitAll(task);
  353. }
  354. public void Delete(CancelTimer request)
  355. {
  356. AssertUserCanManageLiveTv();
  357. var task = _liveTvManager.CancelTimer(request.Id);
  358. Task.WaitAll(task);
  359. }
  360. public void Post(UpdateTimer request)
  361. {
  362. AssertUserCanManageLiveTv();
  363. var task = _liveTvManager.UpdateTimer(request, CancellationToken.None);
  364. Task.WaitAll(task);
  365. }
  366. public object Get(GetSeriesTimers request)
  367. {
  368. var result = _liveTvManager.GetSeriesTimers(new SeriesTimerQuery
  369. {
  370. SortOrder = request.SortOrder,
  371. SortBy = request.SortBy
  372. }, CancellationToken.None).Result;
  373. return ToOptimizedResult(result);
  374. }
  375. public object Get(GetSeriesTimer request)
  376. {
  377. var result = _liveTvManager.GetSeriesTimer(request.Id, CancellationToken.None).Result;
  378. return ToOptimizedResult(result);
  379. }
  380. public void Delete(CancelSeriesTimer request)
  381. {
  382. AssertUserCanManageLiveTv();
  383. var task = _liveTvManager.CancelSeriesTimer(request.Id);
  384. Task.WaitAll(task);
  385. }
  386. public void Post(UpdateSeriesTimer request)
  387. {
  388. AssertUserCanManageLiveTv();
  389. var task = _liveTvManager.UpdateSeriesTimer(request, CancellationToken.None);
  390. Task.WaitAll(task);
  391. }
  392. public object Get(GetDefaultTimer request)
  393. {
  394. if (string.IsNullOrEmpty(request.ProgramId))
  395. {
  396. var result = _liveTvManager.GetNewTimerDefaults(CancellationToken.None).Result;
  397. return ToOptimizedResult(result);
  398. }
  399. else
  400. {
  401. var result = _liveTvManager.GetNewTimerDefaults(request.ProgramId, CancellationToken.None).Result;
  402. return ToOptimizedResult(result);
  403. }
  404. }
  405. public object Get(GetProgram request)
  406. {
  407. var user = string.IsNullOrEmpty(request.UserId) ? null : _userManager.GetUserById(new Guid(request.UserId));
  408. var result = _liveTvManager.GetProgram(request.Id, CancellationToken.None, user).Result;
  409. return ToOptimizedResult(result);
  410. }
  411. public void Post(CreateSeriesTimer request)
  412. {
  413. AssertUserCanManageLiveTv();
  414. var task = _liveTvManager.CreateSeriesTimer(request, CancellationToken.None);
  415. Task.WaitAll(task);
  416. }
  417. public void Post(CreateTimer request)
  418. {
  419. AssertUserCanManageLiveTv();
  420. var task = _liveTvManager.CreateTimer(request, CancellationToken.None);
  421. Task.WaitAll(task);
  422. }
  423. public object Get(GetRecordingGroups request)
  424. {
  425. var result = _liveTvManager.GetRecordingGroups(new RecordingGroupQuery
  426. {
  427. UserId = request.UserId
  428. }, CancellationToken.None).Result;
  429. return ToOptimizedResult(result);
  430. }
  431. public object Get(GetRecordingGroup request)
  432. {
  433. var result = _liveTvManager.GetRecordingGroups(new RecordingGroupQuery
  434. {
  435. }, CancellationToken.None).Result;
  436. var group = result.Items.FirstOrDefault(i => string.Equals(i.Id, request.Id, StringComparison.OrdinalIgnoreCase));
  437. return ToOptimizedResult(group);
  438. }
  439. public object Get(GetGuideInfo request)
  440. {
  441. return ToOptimizedResult(_liveTvManager.GetGuideInfo());
  442. }
  443. public void Post(ResetTuner request)
  444. {
  445. AssertUserCanManageLiveTv();
  446. var task = _liveTvManager.ResetTuner(request.Id, CancellationToken.None);
  447. Task.WaitAll(task);
  448. }
  449. }
  450. }