youtube_caption_scraper 0.1.0 copy "youtube_caption_scraper: ^0.1.0" to clipboard
youtube_caption_scraper: ^0.1.0 copied to clipboard

outdated

Parse subtitles/captions from YouTube without authorization.

example/youtube_caption_scraper_example.dart

import 'package:youtube_caption_scraper/youtube_caption_scraper.dart';

Future<void> main(List<String> arguments) async {
  if (arguments.length != 1) {
    throw Exception('Incorrect usage.');
  }

  final videoUrl = arguments[0];

  final captionScraper = YouTubeCaptionScraper();
  final captionTracks = await captionScraper.getCaptionTracks(videoUrl);

  final subtitles = await captionScraper.getSubtitles(captionTracks[0]);
  for (final subtitle in subtitles) {
    print(
      '${_formatDuration(subtitle.start)} - '
      '${_formatDuration(subtitle.duration)} - '
      '${subtitle.text}',
    );
  }
}

String _formatDuration(Duration duration) {
  return '${duration.inHours}:'
      '${duration.inMinutes.remainder(60)}:'
      '${duration.inSeconds.remainder(60)}:'
      '${duration.inMilliseconds.remainder(60)}';
}
15
likes
0
pub points
66%
popularity

Publisher

verified publisherfperson.dev

Parse subtitles/captions from YouTube without authorization.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

html, http

More

Packages that depend on youtube_caption_scraper