mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
wip
This commit is contained in:
parent
af41021b99
commit
870ac11e70
12 changed files with 159 additions and 148 deletions
|
@ -33,10 +33,16 @@ async function loadChannels() {
|
|||
const files = await file.list(options.channels)
|
||||
for (const filepath of files) {
|
||||
const dir = file.dirname(filepath)
|
||||
const filename = file.basename(filepath)
|
||||
const [_, code] = filename.match(/_(.*).channels.xml/i) || ['', '']
|
||||
const [country, __] = code.split('-') || [null, null]
|
||||
const items = await parser.parseChannels(filepath)
|
||||
for (const item of items) {
|
||||
// const countryCode = item.xmltv_id.split('.')[1]
|
||||
// item.country = countryCode ? countryCode.toUpperCase() : null
|
||||
item.channelsPath = filepath
|
||||
item.configPath = `${dir}/${item.site}.config.js`
|
||||
item.country = country.toUpperCase()
|
||||
channels.push(item)
|
||||
}
|
||||
}
|
||||
|
@ -50,9 +56,7 @@ async function saveToDatabase() {
|
|||
const chunks = split(_.shuffle(channels), options.maxClusters)
|
||||
for (const [i, chunk] of chunks.entries()) {
|
||||
for (const item of chunk) {
|
||||
const countryCode = item.xmltv_id.split('.')[1]
|
||||
item.cluster_id = i + 1
|
||||
item.country = countryCode ? countryCode.toUpperCase() : null
|
||||
await db.channels.insert(item)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue