Пример #1
0
        public static YoutubeSource GetYoutubeSource(string link)
        {
            string id = link.ParseVideoId();

            var client = new YoutubeClient();

            YoutubeExplode.Models.Video video = client.GetVideoAsync(id).Result;

            var youtubeSource = new YoutubeSource
            {
                ThumbnailUri = video.Thumbnails.MediumResUrl,
                Title        = video.Title,
                Id           = id
            };

            return(youtubeSource);
        }
Пример #2
0
        private void BtnCheck_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                YoutubeSource ys = YoutubeDownloader.GetYoutubeSource_Offical(tbSearchLink.Text);

                GlobalViewModel.ExternalSourceViewModel.Sources.Insert(0, ys);
                tcSelectedIndex.SelectedIndex = 0;
                templates.SelectedIndex       = 0;
            }
            catch (Exception)
            {
                MessageBox.Show("링크가 잘못되었습니다. 확인 후 다시 시도해주세요.");
            }

            tbSearchLink.Clear();
        }
Пример #3
0
        /// <summary>
        /// 공식 API를 사용한 Youtube Source 가져오기
        /// </summary>
        /// <param name="link"></param>
        /// <returns></returns>
        public static YoutubeSource GetYoutubeSource_Offical(string link)
        {
            string id = link.ParseVideoId();

            (string, string)infos = GetYoutubeInfo(id);

            string title        = infos.Item1;
            string thumbnailUrl = infos.Item2;

            var youtubeSource = new YoutubeSource
            {
                ThumbnailUri = thumbnailUrl,
                Title        = title,
                Id           = id,
            };

            return(youtubeSource);
        }