Пример #1
0
        public static async Task <string> GetMusicVideo(string videoId, ChromiumWebBrowser youtubePlayer)
        {
            //use video id to get the song
            VideoId = videoId;

#if OFFLINE_IMPLEMENTED
            if (!FilePaths.InCache())
            {
                Console.WriteLine("Video not in cache; video is downloading now");
                return(await GetMusic.DownloadVideo(youtubePlayer));
            }
            // Client
            var client    = new YoutubeClient();
            var videoInfo = await client.GetVideoInfoAsync(VideoId);

            // Print metadata
            // Console.WriteLine($"Id: {videoInfo.Id} | Title: {videoInfo.Title} | Author: {videoInfo.Author.Title}");
            var fullName = videoInfo.Title;
            //code for the video library api
            var saveName = FilePaths.RemoveIllegalPathCharacters(fullName.Replace("- YouTube", ""));
            saveName = saveName.Replace("_", "");
            string savePath = Path.Combine(FilePaths.SaveLocation(),
                                           (saveName));

            return(savePath);
#endif
            return(await DownloadVideo(youtubePlayer));
        }