Ejemplo n.º 1
0
        public async Task <IActionResult> GetTaleSourcesAsync(Guid taleId, Guid sourceId)
        {
            try
            {
                var tale = _talesRepository.GetTale(taleId);
                if (tale == null)
                {
                    return(NotFound());
                }

                var taleSource = _talesRepository.GetTaleSource(sourceId);
                if (taleSource == null)
                {
                    return(NotFound());
                }

                if (taleSource.Url.Contains("youtube"))
                {
                    return(File(await _streamingService.GetYoutubeAudioStreamAsync(taleSource.Url), "audio/mp3", $"{tale.Title}.mp3"));
                }
                else
                {
                    return(File(_streamingService.GetAudioStream(taleSource.Url), "audio/mp3", $"{tale.Title}.mp3"));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.ToString());
                return(StatusCode(500, "Unknown Error"));
            }
        }