getVideoMetadata method Null safety
Retrieves a video
Retrieves Comments if timestampComments
is set to true
Retrieves Recommendations if query parameter recommendationLanguages
is set
Arguments
videoId
ID of the videotimestampComments
If set totrue
, comments with timestamps will be returnedrecommendationLanguages
If set, videos matching the languages will be returned. Use Language.all to get all languages regardless of language
Implementation
@override
Future<VideoMetadata> getVideoMetadata(
String videoId, {
bool timestampComments = false,
List<Language>? recommendationLanguages,
}) async {
final Map<String, dynamic> params = {};
_addLanguages(recommendationLanguages, params);
_addCommentsFlag(timestampComments, params);
final response = await get(path: '${_Constants.videosPath}/$videoId', params: params);
final body = jsonDecode(response.body);
final video = VideoFull.fromMap(body);
final List? comments = body['comments'];
final List? recommendations = body['recommendations'];
return VideoMetadata(
video: video,
comments: comments?.map((comment) => Comment.fromMap(comment)).toList(),
recommendations: recommendations?.map((video) => Video.fromMap(video)).toList(),
);
}