getVideo method
Implementation
Future<googleapis_client_scheme.YoutubeVideo> getVideo({
required String video_id,
}) async {
googleapis_client_scheme.YoutubeSchemaText youtubeSchemaText =
GoogleApisClientUtils.parseTextToYoutube(text: video_id);
if (youtubeSchemaText["@type"] == "error") {
return googleapis_client_scheme.YoutubeVideo(youtubeSchemaText.rawData);
}
if (youtubeSchemaText["type"] != "video") {
return googleapis_client_scheme.YoutubeVideo(youtubeSchemaText.rawData);
}
Video video = await youtubeExplode.videos.get(youtubeSchemaText.data);
Map jsonDataVideo = {
"@type": "youtubeVideo",
"id": video.id.value,
"author": video.author,
"channel_id": video.channelId.value,
"title": video.title,
"description": video.description,
"url": video.url,
"duration": video.duration?.toString(),
"date": video.uploadDate?.millisecondsSinceEpoch,
"has_watch_page": video.hasWatchPage,
"is_live": video.isLive,
"keywords": video.keywords.toList(),
"engagement": {
"@type": "youtubeVideoEngagement",
"average_count": video.engagement.avgRating,
"dislike_count": video.engagement.dislikeCount,
"like_count": video.engagement.likeCount,
"view_count": video.engagement.viewCount,
},
"thumbnails": {
"@type": "youtubeVideoThumbnails",
"low": video.thumbnails.lowResUrl,
"medium": video.thumbnails.mediumResUrl,
"high": video.thumbnails.highResUrl,
"max": video.thumbnails.maxResUrl,
"standard": video.thumbnails.standardResUrl,
},
};
return googleapis_client_scheme.YoutubeVideo(jsonDataVideo);
}