backend/utils/metadata.js

25 lines
835 B
JavaScript
Raw Normal View History

2023-03-03 16:44:40 +00:00
const fetch = require('node-fetch')
async function getInstance() {
// 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 }