getChannelFullInfo method
Implementation
Future<googleapis_client_scheme.YoutubeChannelFullInfo> getChannelFullInfo({
required String channel,
}) async {
googleapis_client_scheme.YoutubeSchemaText youtubeSchemaText =
GoogleApisClientUtils.parseTextToYoutube(text: channel);
if (youtubeSchemaText["@type"] == "error") {
return googleapis_client_scheme.YoutubeChannelFullInfo(
youtubeSchemaText.rawData);
}
googleapis_client_scheme.YoutubeChannel youtubeChannel =
await getChannel(channel: channel);
ChannelAbout channel_result = await () async {
if (youtubeSchemaText.type == "channel_username") {
return await youtubeExplode.channels
.getAboutPageByUsername(youtubeSchemaText.data);
} else {
return await youtubeExplode.channels
.getAboutPage(youtubeChannel.id ?? youtubeSchemaText.data);
}
}.call();
Map jsonData = {...youtubeChannel.toJson()};
jsonData["@type"] = "youtubeChannelFullInfo";
jsonData["description"] = channel_result.description;
jsonData["view_count"] = channel_result.viewCount;
jsonData["join_date"] = channel_result.joinDate;
jsonData["title"] = channel_result.title;
jsonData["country"] = channel_result.country;
jsonData["thumbnails"] = channel_result.thumbnails.map((Thumbnail e) {
Map jsonDataThumbnails = {
"@type": "youtubeChannelThumbnails",
"url": e.url.toString(),
"height": e.height,
"width": e.width,
};
return jsonDataThumbnails;
}).toList();
jsonData["channelLinks"] =
channel_result.channelLinks.map((ChannelLink channelLink) {
Map jsonDataLinks = {
"@type": "youtubeChannelLinks",
"title": channelLink.title,
"url": channelLink.url.toString(),
"icon": channelLink.icon.toString(),
};
return jsonDataLinks;
}).toList();
return googleapis_client_scheme.YoutubeChannelFullInfo(jsonData);
}