mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
wip
This commit is contained in:
parent
f8981e478e
commit
043d738c95
14 changed files with 134 additions and 9 deletions
|
@ -50,7 +50,9 @@ 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,13 +28,11 @@ async function loadChannels() {
|
|||
let output = {}
|
||||
items.forEach(item => {
|
||||
if (!output[item.xmltv_id]) {
|
||||
const countryCode = item.xmltv_id.split('.')[1]
|
||||
|
||||
output[item.xmltv_id] = {
|
||||
id: item.xmltv_id,
|
||||
name: [item.name],
|
||||
logo: item.logo || null,
|
||||
country: countryCode ? countryCode.toUpperCase() : null
|
||||
country: item.country
|
||||
}
|
||||
} else {
|
||||
output[item.xmltv_id].logo = output[item.xmltv_id].logo || item.logo
|
||||
|
|
|
@ -12,6 +12,7 @@ async function main() {
|
|||
await setUp()
|
||||
|
||||
await generateMainXML()
|
||||
await generateCountries()
|
||||
}
|
||||
|
||||
main()
|
||||
|
@ -32,6 +33,32 @@ async function generateMainXML() {
|
|||
await file.create(`${GUIDES_DIR}/epg.xml`, xml.create(output))
|
||||
}
|
||||
|
||||
async function generateCountries() {
|
||||
logger.info(`Generating countries/...`)
|
||||
|
||||
const countryCodes = ['US', 'ZA']
|
||||
|
||||
for (let code of countryCodes) {
|
||||
const output = {
|
||||
channels: [],
|
||||
programs: []
|
||||
}
|
||||
|
||||
output.channels = channels
|
||||
.filter(c => c.country === code)
|
||||
.map(c => {
|
||||
c.site = sources[c.id]
|
||||
return c
|
||||
})
|
||||
|
||||
for (let channel of output.channels) {
|
||||
output.programs = output.programs.concat(programs[channel.id])
|
||||
}
|
||||
|
||||
await file.create(`${GUIDES_DIR}/countries/${code.toLowerCase()}.epg.xml`, xml.create(output))
|
||||
}
|
||||
}
|
||||
|
||||
async function setUp() {
|
||||
channels = await loadChannels()
|
||||
programs = await loadPrograms()
|
||||
|
|
|
@ -19,6 +19,8 @@ xml.create = function ({ channels, programs }) {
|
|||
}
|
||||
|
||||
for (let program of programs) {
|
||||
if (!program) continue
|
||||
|
||||
const start = program.start ? dayjs.unix(program.start).utc().format('YYYYMMDDHHmmss ZZ') : ''
|
||||
const stop = program.stop ? dayjs.unix(program.stop).utc().format('YYYYMMDDHHmmss ZZ') : ''
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue