2023-03-03 16:44:40 +00:00
|
|
|
const fetch = require('node-fetch')
|
|
|
|
|
|
|
|
async function getInstance() {
|
2023-03-10 16:09:46 +00:00
|
|
|
// const instances = await (await fetch('https://piped-instances.kavin.rocks/')).json()
|
|
|
|
// const list = instances.filter(i => !i.cdn)
|
|
|
|
// return (list[Math.floor(Math.random() * list.length)]).api_url
|
|
|
|
return 'https://pipedapi.kavin.rocks'
|
2023-03-03 16:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function getVideoMetadata(instance, id) {
|
|
|
|
const json = await (await fetch(`${instance}/streams/${id}`)).json()
|
|
|
|
return json
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getChannelVideos(instance, id) {
|
|
|
|
const json = await (await fetch(`${instance}/channel/${id}`)).json()
|
|
|
|
return json
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getPlaylistVideos(instance, id) {
|
|
|
|
const json = await (await fetch(`${instance}/playlists/${id}`)).json()
|
|
|
|
return json
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { getInstance, getVideoMetadata, getChannelVideos, getPlaylistVideos }
|