mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update update-codes.js
This commit is contained in:
parent
c524ea2dd5
commit
da84f9522f
1 changed files with 7 additions and 41 deletions
|
@ -3,19 +3,17 @@ const path = require('path')
|
||||||
const convert = require('xml-js')
|
const convert = require('xml-js')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const countries = require('./countries.json')
|
const countries = require('./countries.json')
|
||||||
|
const file = require('./file.js')
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log('Starting...')
|
console.log('Starting...')
|
||||||
|
|
||||||
|
const files = await file.list('.gh-pages/guides/*.xml')
|
||||||
|
|
||||||
let codes = {}
|
let codes = {}
|
||||||
for (const filename of files) {
|
for (const filename of files) {
|
||||||
const url = `https://iptv-org.github.io/epg/guides/${filename}.guide.xml`
|
const url = filename.replace('.gh-pages', 'https://iptv-org.github.io/epg')
|
||||||
console.log(`Loading '${url}'...`)
|
const channels = parseChannels(file.read(filename))
|
||||||
const file = await axios
|
|
||||||
.get(url)
|
|
||||||
.then(r => r.data)
|
|
||||||
.catch(console.log)
|
|
||||||
const channels = parseChannels(file)
|
|
||||||
channels.forEach(channel => {
|
channels.forEach(channel => {
|
||||||
if (!codes[channel.tvg_id]) {
|
if (!codes[channel.tvg_id]) {
|
||||||
channel.guides = [url]
|
channel.guides = [url]
|
||||||
|
@ -68,8 +66,8 @@ function convertToJSON(arr) {
|
||||||
return JSON.stringify(arr)
|
return JSON.stringify(arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseChannels(file) {
|
function parseChannels(xml) {
|
||||||
const result = convert.xml2js(file)
|
const result = convert.xml2js(xml)
|
||||||
const tv = result.elements.find(el => el.name === 'tv')
|
const tv = result.elements.find(el => el.name === 'tv')
|
||||||
|
|
||||||
return tv.elements
|
return tv.elements
|
||||||
|
@ -88,36 +86,4 @@ function parseChannels(file) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = [
|
|
||||||
'andorradifusio.ad',
|
|
||||||
'astro.com.my',
|
|
||||||
'comteco.com.bo',
|
|
||||||
'cosmote.gr',
|
|
||||||
'digiturk.com.tr',
|
|
||||||
'elcinema.com',
|
|
||||||
'guidatv.sky.it',
|
|
||||||
'hd-plus.de',
|
|
||||||
'm.tv.sms.cz',
|
|
||||||
'maxtv.hrvatskitelekom.hr',
|
|
||||||
'mediaset.it',
|
|
||||||
'meo.pt',
|
|
||||||
'mi.tv',
|
|
||||||
'mncvision.id',
|
|
||||||
'ontvtonight.com',
|
|
||||||
'programacion-tv.elpais.com',
|
|
||||||
'programetv.ro',
|
|
||||||
'programme-tv.net',
|
|
||||||
'programtv.onet.pl',
|
|
||||||
'telkussa.fi',
|
|
||||||
'tv.lv',
|
|
||||||
'tv.yandex.ru',
|
|
||||||
'tvgid.ua',
|
|
||||||
'tvguide.com',
|
|
||||||
'tvprofil.com',
|
|
||||||
'tvtv.ca',
|
|
||||||
'tvtv.us',
|
|
||||||
'vidio.com',
|
|
||||||
'znbc.co.zm'
|
|
||||||
]
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue