private static void StartDownloadFromYoutubeLink() { Console.WriteLine("Youtube video url:"); var videoUrl = Console.ReadLine(); Console.WriteLine("Artist:"); var artist = Console.ReadLine(); Console.WriteLine("Track name:"); var name = Console.ReadLine(); var youtubeSearchService = new YoutubeSearchService(); var videoId = youtubeSearchService.GetYoutubeVideoId(videoUrl); if (String.IsNullOrEmpty(videoId)) { Console.WriteLine("Not valid youtube url"); return; } new YoutubeSearchService().DownloadAudio(videoId, new TrackModel() { Artist = artist, Name = name }); }
public async Task SearchExecute() { try { if (string.IsNullOrWhiteSpace(SearchQuery)) { await ClearExecute(); return; } await ExecuteBusyAction(async() => { Songs.Clear(); var songs = await YoutubeSearchService.SearchVideo($"{SearchQuery} karaoke", 1); foreach (var song in songs) { Songs.Add(song); } }); } catch (System.Exception ex) { Debug.WriteLine(ex); } }
public YoutubeSearchServiceTests() { _httpClientMock = new HttpClientMock(); _youTubeServiceWrapper = new Mock <YouTubeServiceWrapper>(null); var config = new MapperConfiguration(cfg => { cfg.AddProfile <ModelProfile>(); cfg.AddProfile <ServiceTestsProfile>(); }); _mapper = config.CreateMapper(); _youtubeSearchService = new YoutubeSearchService(() => _httpClientMock.HttpClient.Object, _youTubeServiceWrapper.Object, _mapper); }