getChannel method
Implementation
Future<googleapis_client_scheme.YoutubeChannel> getChannel({
required String channel,
}) async {
googleapis_client_scheme.YoutubeSchemaText youtubeSchemaText =
GoogleApisClientUtils.parseTextToYoutube(text: channel);
if (youtubeSchemaText["@type"] == "error") {
return googleapis_client_scheme.YoutubeChannel(youtubeSchemaText.rawData);
}
Channel channel_result = await () async {
if (youtubeSchemaText.type == "channel_username") {
return await youtubeExplode.channels
.getByUsername(youtubeSchemaText.data);
} else if (youtubeSchemaText.type == "video") {
return await youtubeExplode.channels.getByVideo(youtubeSchemaText.data);
} else {
try {
return await youtubeExplode.channels.get(youtubeSchemaText.data);
} catch (e) {
return await youtubeExplode.channels
.getByUsername(youtubeSchemaText.data);
}
}
}.call();
Map jsonData = {
"@type": "youtubeChannel",
"id": channel_result.id.value,
"title": channel_result.title,
"url": channel_result.url,
"subscribers_count": channel_result.subscribersCount,
"profile_banner": channel_result.bannerUrl,
"profile_picture": channel_result.logoUrl,
};
return googleapis_client_scheme.YoutubeChannel(jsonData);
}