Ejemplo n.º 1
0
        // This downloads the video and return wheather or not the video exists
        public async Task DownloadYoutubeVideoAsync()
        {
            Tuple <Video, Playlist> ReturnTuple = await GetYoutubeVideoAsync();

            if (ReturnTuple.Item1 != null)
            {
                await _YoutubeConverter.DownloadVideoAsync(_Video.Id, this.Path + _Video.Title + ".mp3");
            }
            else
            {
                await foreach (var video in _YoutubeClient.Playlists.GetVideosAsync(_Playlist.Id))
                {
                    await _YoutubeConverter.DownloadVideoAsync(video.Id, this.Path + video.Title + ".mp3");
                }
            }
        }
        public async Task DownloadVideoAsync(string videoId, string filePath, string format,
                                             IProgress <double> progress, CancellationToken cancellationToken)
        {
            // Ensure throttling and increment concurrent download count
            await EnsureThrottlingAsync(cancellationToken);

            try
            {
                // Download the video
                await _youtubeConverter.DownloadVideoAsync(videoId, filePath, format, progress, cancellationToken);
            }
            finally
            {
                // Decrement concurrent download count
                Interlocked.Decrement(ref _concurrentDownloadCount);
            }
        }
Ejemplo n.º 3
0
 public Task DownloadVideoAsync(string videoId, string filePath,
                                IProgress <double> progress, CancellationToken cancellationToken) =>
 _youtubeConverter.DownloadVideoAsync(videoId, filePath, progress, cancellationToken);
Ejemplo n.º 4
0
 /// <summary>
 /// Downloads a video to a file using specified format by selecting media streams from the given set.
 /// </summary>
 public static Task DownloadVideoAsync(this IYoutubeConverter converter,
                                       StreamManifest streamManifest, string filePath, string format,
                                       IProgress <double>?progress = null, CancellationToken cancellationToken = default) =>
 converter.DownloadVideoAsync(streamManifest, filePath, format, ConversionPreset.Medium, progress, cancellationToken);