mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update create-database.js
This commit is contained in:
parent
8adf6fd9c8
commit
465d38abb9
1 changed files with 6 additions and 6 deletions
|
@ -13,23 +13,21 @@ const options = program
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
.opts()
|
.opts()
|
||||||
|
|
||||||
const channels = []
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
logger.info('Starting...')
|
logger.info('Starting...')
|
||||||
logger.info(`Number of clusters: ${options.maxClusters}`)
|
logger.info(`Number of clusters: ${options.maxClusters}`)
|
||||||
|
|
||||||
await loadChannels()
|
await saveToDatabase(await getChannels())
|
||||||
await saveToDatabase()
|
|
||||||
|
|
||||||
logger.info('Done')
|
logger.info('Done')
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
async function loadChannels() {
|
async function getChannels() {
|
||||||
logger.info(`Loading channels...`)
|
logger.info(`Loading channels...`)
|
||||||
|
|
||||||
|
const channels = []
|
||||||
const files = await file.list(options.channels)
|
const files = await file.list(options.channels)
|
||||||
for (const filepath of files) {
|
for (const filepath of files) {
|
||||||
const dir = file.dirname(filepath)
|
const dir = file.dirname(filepath)
|
||||||
|
@ -51,9 +49,11 @@ async function loadChannels() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info(`Found ${channels.length} channels`)
|
logger.info(`Found ${channels.length} channels`)
|
||||||
|
|
||||||
|
return channels
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveToDatabase() {
|
async function saveToDatabase(channels = []) {
|
||||||
logger.info('Saving to the database...')
|
logger.info('Saving to the database...')
|
||||||
await db.channels.load()
|
await db.channels.load()
|
||||||
await db.channels.reset()
|
await db.channels.reset()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue