getDownloadDetail method

Future<YoutubeVideoDownloadDetail> getDownloadDetail({
  1. required Directory directory,
  2. required String youtubeUrl,
  3. required String? output,
  4. required bool isAudioOnly,
})

Implementation

Future<YoutubeVideoDownloadDetail> getDownloadDetail({
  required Directory directory,
  required String youtubeUrl,
  required String? output,
  required bool isAudioOnly,
}) async {
  final manifest =
      await youtubeExplode.videos.streamsClient.getManifest(youtubeUrl);
  final audioTotalBytes =
      manifest.audioOnly.withHighestBitrate().size.totalBytes;
  if (isAudioOnly) {
    return YoutubeVideoDownloadDetail(
      totalSize: audioTotalBytes,
      streamManifest: manifest,
    );
  } else {
    return YoutubeVideoDownloadDetail(
      totalSize: manifest.videoOnly.withHighestBitrate().size.totalBytes +
          audioTotalBytes,
      streamManifest: manifest,
    );
  }
}