From ef0540327e6ec6720210cdaab2c4ba3d4db8487b Mon Sep 17 00:00:00 2001 From: Ashley Date: Fri, 25 Mar 2022 19:42:57 +0300 Subject: [PATCH] Create channel.js --- sdk/src/channel.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sdk/src/channel.js diff --git a/sdk/src/channel.js b/sdk/src/channel.js new file mode 100644 index 00000000..6265cb4f --- /dev/null +++ b/sdk/src/channel.js @@ -0,0 +1,40 @@ +const fetch = require("node-fetch"); +const xmltojson = require("xml2json") +const url = require("../config.json") + +class PoketubeChannelManager{ + static async GetBasicChannelInfo(CHANNEL_ID){ + const channel = await fetch(url.poketube_api + `/channel?id=${CHANNEL_ID}`) + var text = await channel.text();var json = xmltojson.toJson(text);let Channel = JSON.parse(json); + const channelObjectString = { + channelId:Channel.Channel.id, + name:Channel.Channel.Metadata.name, + subCount:Channel.Channel.Metadata.Subscribers + } + return channelObjectString + } + static async GetChannelBanner(CHANNEL_ID){ + const channel = await fetch(url.poketube_api + `/channel?id=${CHANNEL_ID}`) + var text = await channel.text();var json = xmltojson.toJson(text);let Channel = JSON.parse(json); + const ChannelBannerString = { + Banners:Channel.Channel.Metadata.Banners.Thumbnail[1].$t + } + return ChannelBannerString + } + static async GetChannelAvatar(CHANNEL_ID){ + const channel = await fetch(url.poketube_api + `/channel?id=${CHANNEL_ID}`) + var text = await channel.text();var json = xmltojson.toJson(text);let Channel = JSON.parse(json); + const ChannelAvatarString = { + Avatar:Channel.Channel.Metadata.Avatars.Thumbnail.$t + } + return ChannelAvatarString + } + static async GetChannelUploads(CHANNEL_ID){ + const channel = await fetch(url.poketube_api + `/channel?id=${CHANNEL_ID}`) + var text = await channel.text();var json = xmltojson.toJson(text);let Channel = JSON.parse(json); + const ChannelUploadString = { + Avatar:Channel.Channel.Contents.ItemSection.toString() + } + } +} +module.exports = PoketubeChannelManager