mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 11:37:49 +01:00
Create channel.js
This commit is contained in:
parent
23a4cbffb8
commit
ef0540327e
1 changed files with 40 additions and 0 deletions
40
sdk/src/channel.js
Normal file
40
sdk/src/channel.js
Normal file
|
@ -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
|
Loading…
Reference in a new issue