Get channels using Api.

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha 2024-11-26 20:47:55 +07:00
parent f6d53587f3
commit e54b28ba14
No known key found for this signature in database
GPG key ID: 2D7AA6389D44DCAB
2 changed files with 11 additions and 10 deletions

File diff suppressed because one or more lines are too long

View file

@ -47,19 +47,21 @@ module.exports = {
}, },
async channels({ lang = 'id' }) { async channels({ lang = 'id' }) {
const result = [] const result = []
const fs = require('fs') const axios = require('axios')
const path = require('path') const json = await axios
const channelFile = path.join(__dirname, 'channels.json') .get(`https://www.visionplus.id/managetv/tvinfo/channels/get?language=${languages[lang]}`)
if (fs.existsSync(channelFile)) { .then(response => response.data)
const items = JSON.parse(fs.readFileSync(channelFile)) .catch(console.error)
Object.values(items).forEach(item => {
if (Array.isArray(json?.chs)) {
for (const ch of json.chs) {
result.push({ result.push({
lang, lang,
site_id: item.serviceId, site_id: ch.sid,
name: item.name name: ch.loc[0].nam
})
}) })
} }
}
return result return result
} }