mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Get channels using Api.
Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
parent
f6d53587f3
commit
e54b28ba14
2 changed files with 11 additions and 10 deletions
File diff suppressed because one or more lines are too long
|
@ -47,18 +47,20 @@ 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue