mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-17 12:30:03 -04:00
Update db.js
This commit is contained in:
parent
7f2c5b36c9
commit
7e811f4c33
1 changed files with 13 additions and 2 deletions
|
@ -2,15 +2,22 @@ const categories = require('../data/categories')
|
||||||
const parser = require('./parser')
|
const parser = require('./parser')
|
||||||
const utils = require('./utils')
|
const utils = require('./utils')
|
||||||
const file = require('./file')
|
const file = require('./file')
|
||||||
|
const epg = require('./epg')
|
||||||
|
|
||||||
const db = {}
|
const db = {}
|
||||||
|
|
||||||
db.load = async function () {
|
db.load = async function () {
|
||||||
let files = await file.list()
|
const files = await file.list()
|
||||||
|
const codes = await epg.codes.load()
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const playlist = await parser.parsePlaylist(file)
|
const playlist = await parser.parsePlaylist(file)
|
||||||
db.playlists.add(playlist)
|
let guides = []
|
||||||
for (const channel of playlist.channels) {
|
for (const channel of playlist.channels) {
|
||||||
|
const code = codes.find(ch => ch['tvg_id'] === channel.tvg.id)
|
||||||
|
if (code && Array.isArray(code.guides)) {
|
||||||
|
guides = [...guides, ...code.guides]
|
||||||
|
}
|
||||||
|
|
||||||
db.channels.add(channel)
|
db.channels.add(channel)
|
||||||
|
|
||||||
for (const country of channel.countries) {
|
for (const country of channel.countries) {
|
||||||
|
@ -25,6 +32,10 @@ db.load = async function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (guides.length) playlist.header.attrs['url-tvg'] = guides.join(',')
|
||||||
|
|
||||||
|
db.playlists.add(playlist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue