YoutubeScraper class abstract
YouTube caption/subtitle scraper.
In order to get subtitles of a YouTube video, you first need to get caption tracks via getCaptionTracks, and pass a caption track to getSubtitles:
final captionScraper = YouTubeSubtitleScraper();
final captionTracks = await captionScraper.getCaptionTracks('example-video-url');
final subtitles = await captionScraper.getSubtitles(captionTracks.first);
for (final subtitleLine in subtitles) {
print('${subtitleLine.start} - ${subtitleLine.duration} - ${subtitleLine.text}');
}
Constructors
- YoutubeScraper.new({YouTubeScrapeHttpClient? httpClient})
-
The default implementation of YoutubeScraper.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getCaptionTracks(
String videoId) → Future< List< SubtitleTrack> > -
Gets caption tracks of the video on
videoId
. -
getSubtitles(
{required String videoId, String languageCode = 'en'}) → Future< List< SubtitleLine> > -
getSubtitlesTrack(
SubtitleTrack captionTrack) → Future< List< SubtitleLine> > -
Gets subtitles based on
captionTrack.baseUrl
. -
getVideoInfo(
{required String videoId}) → Future< VideoInfo> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited