Example #1
0
        public async Task downloadVideo(attributeVideo attr)
        {
            var streams = await yt.Videos.Streams.GetManifestAsync(link);

            //           var streams = await yt.Videos.Streams.GetManifestAsync(videoId);

            var streamInfo = streams.GetMuxed().WithHighestVideoQuality();

            //var streamInfo = video.GetMuxed().WithHighestVideoQuality();
            if (streamInfo == null)
            {
                Console.Error.WriteLine("This videos has no streams");
            }

            // Compose file name, based on metadata
            string fileName = attr.namaFile;
            string folder   = Path.Combine(rootDirectory, attr.Chanel);
            string lokasi   = Path.Combine(folder, fileName);

            cekDirectory(folder);

            Console.WriteLine(lokasi);

            Console.Write("sedang mengunduh - ");

            using (var progress = new ProgressBar())
                await yt.Videos.Streams.DownloadAsync(streamInfo, lokasi, progress);


            Console.WriteLine($"video disimipan di '{lokasi}'");
        }
Example #2
0
        public async Task downloadBaru(IStreamInfo streamInfo, attributeVideo attr)
        {
            if (streamInfo == null)
            {
                Console.Error.WriteLine("This videos has no streams");
            }

            // Compose file name, based on metadata
            string fileName = attr.namaFile;
            string folder   = Path.Combine(rootDirectory, attr.Chanel);

            Console.WriteLine("nama filenya " + folder + " dan " + fileName);
            string lokasi = Path.Combine(folder, fileName);

            cekDirectory(folder);

            Console.WriteLine(lokasi);

            Console.Write("sedang mengunduh - ");

            using (var progress = new ProgressBar())
                await yt.Videos.Streams.DownloadAsync(streamInfo, lokasi, progress);


            Console.WriteLine($"video disimipan di '{lokasi}'");
        }
Example #3
0
        public async Task <attributeVideo> getInfo()
        {
            yt = new YoutubeClient();
            var video = await yt.Videos.GetAsync(link);

            attributeVideo attr = new attributeVideo();

            attr.Title      = video.Title;
            attr.Chanel     = video.Author;
            attr.Duration   = Math.Round((video.Duration.TotalMinutes), 1).ToString();
            attr.Rating     = video.Engagement.AverageRating.ToString();
            attr.Dislike    = video.Engagement.DislikeCount.ToString();
            attr.Like       = video.Engagement.LikeCount.ToString();
            attr.View       = video.Engagement.ViewCount.ToString();
            attr.Thumbnail  = video.Thumbnails.HighResUrl.ToString();
            attr.DateUpload = video.UploadDate.DateTime.ToString("dddd, dd MMMM yyyy");
//            attr.namaFile = convertFilename(video.Title);
//            attr.namaFile = "sate.mp4";
            return(attr);
        }