using System.Net.Http.Json; using VideoStudy.Shared; namespace VideoStudy.UI.Services; public class YouTubeService { private readonly HttpClient _httpClient; public YouTubeService(HttpClient httpClient) { _httpClient = httpClient; } public async Task GetVideoInfoAsync(string url) { var encodedUrl = Uri.EscapeDataString(url); var info = await _httpClient.GetFromJsonAsync($"api/video-info?url={encodedUrl}"); return info ?? throw new Exception("Não foi possível obter informações do vídeo."); } }