Ejemplo n.º 1
0
        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
            });
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
        }