private R <PlayResource, LocalStr> YoutubeDlWrapped(string link) { Log.Debug("Falling back to youtube-dl!"); var result = YoutubeDlHelper.GetSingleVideo(link); if (!result.Ok) { return(result.Error); } var response = result.Value; var title = response.title ?? $"Soundcloud-{link}"; var format = YoutubeDlHelper.FilterBest(response.formats); var url = format?.url; if (string.IsNullOrEmpty(url)) { return(new LocalStr(strings.error_ytdl_empty_response)); } Log.Debug("youtube-dl succeeded!"); return(new PlayResource(url, new AudioResource(link, title, ResolverFor))); }
private async Task <PlayResource> YoutubeDlWrappedAsync(string link) { Log.Debug("Falling back to youtube-dl!"); var response = await YoutubeDlHelper.GetSingleVideo(link); var title = response.title ?? $"Soundcloud-{link}"; var format = YoutubeDlHelper.FilterBest(response.formats); var url = format?.url; if (string.IsNullOrEmpty(url)) { throw Error.LocalStr(strings.error_ytdl_empty_response); } Log.Debug("youtube-dl succeeded!"); return(new PlayResource(url, new AudioResource(link, title, ResolverFor))); }