private async Task <IActionResult> ProcessJellyPhrase(JellyPhrase phrase, string controllerName) { phrase.UserId = await _jellyfinService.GetUserId(phrase.User); if (string.IsNullOrWhiteSpace(phrase.UserId)) { await _loggingService.LogWarning($"{controllerName} - no user found", $"{phrase.SearchTerm}, or the default user, returned no available user IDs.", phrase); return(BadRequest($"No user found! - {phrase.SearchTerm}, or the default user, returned no available user Ids")); } IEnumerable <QueueItem> items = await _jellyfinService.GetItems(phrase); await _loggingService.LogDebug($"{controllerName} - items found.", $"Found {items.Count()} item(s) with the search term {phrase.SearchTerm}."); await _loggingService.LogInformation($"{controllerName} - items found.", "Found the following items:", items); if (!items.Any()) { await _loggingService.LogWarning($"{controllerName} - no results", $"{phrase.SearchTerm} returned no search results.", phrase); return(NotFound($"No user found! - {phrase.SearchTerm}, or the default user, returned no available user IDs.")); } _ = Task.Run(async() => await _castService.StartJellyfinSession(phrase.Device, items)); return(Ok($"Found {items.Count()} item(s) with the search term {phrase.SearchTerm}.")); }
private async Task <IEnumerable <QueueItem> > GetItems(string searchTerm) { JellyPhrase phrase = await _languageService.ParseJellyfinSimplePhrase(searchTerm); await _loggingService.LogDebug("ReceiverHub - parsed phrase.", $"Succesfully parsed the following phrase from the search term: {searchTerm}", phrase); phrase.UserId = await _jellyfinService.GetUserId(phrase.User); if (string.IsNullOrWhiteSpace(phrase.UserId)) { await _loggingService.LogWarning($"ReceiverHub - no user found", $"{phrase.SearchTerm}, or the default user, returned no available user IDs.", phrase); return(Array.Empty <QueueItem>()); } IEnumerable <QueueItem> items = await _jellyfinService.GetItems(phrase); await _loggingService.LogDebug($"ReceiverHub - items found.", $"Found {items.Count()} item(s) with the search term {phrase.SearchTerm}."); await _loggingService.LogInformation($"ReceiverHub - items found.", "Found the following items:", items); if (!items.Any()) { await _loggingService.LogWarning($"ReceiverHub - no results", $"{phrase.SearchTerm} returned no search results.", phrase); } return(items); }
public async Task <IActionResult> PostJellySimpleHook([FromBody] SimplePhrase simplePhrase) { JellyPhrase phrase = await _languageService.ParseJellyfinSimplePhrase(simplePhrase.Content); await _loggingService.LogDebug("PostJellySimpleHook - parsed phrase.", $"Succesfully parsed the following phrase from the search term: {simplePhrase.Content}", phrase); if (string.IsNullOrWhiteSpace(phrase.SearchTerm)) { return(BadRequest("Missing search content! Please specify a search term along with any optional filters.")); } return(await ProcessJellyPhrase(phrase, nameof(PostJellySimpleHook))); }