codecov
Pub version

一个 Dart 包,用于解析来自 YouTube 的歌词。无需身份验证。

用法

// Instantiate the scraper.
final captionScraper = YouTubeCaptionScraper(); 

// Fetch caption tracks – these are objects containing info like
// base url for the caption track and language code.
final captionTracks = await captionScraper.getCaptionTracks('video-url');

// Fetch the subtitles by providing it with a `CaptionTrack`
// from `getCaptionTracks`.
final subtitles = await captionScraper.getSubtitles(captionTracks[0]);

// Use the subtitles however you want.
for (final subtitle in subtitles) {
  print('${subtitle.start} - ${subtitle.duration} - ${subtitle.text}');
}

欲了解更多信息,请参阅
示例
或查看
API 参考.

鸣谢

该软件包的灵感主要来自
algolia/youtube-captions-scraper.

GitHub

查看 Github