mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Update create.js
This commit is contained in:
parent
2585148f45
commit
9fa8740643
1 changed files with 4 additions and 4 deletions
|
@ -18,6 +18,7 @@ main()
|
||||||
async function findStreams() {
|
async function findStreams() {
|
||||||
logger.info(`loading channels...`)
|
logger.info(`loading channels...`)
|
||||||
await api.channels.load()
|
await api.channels.load()
|
||||||
|
const channels = _.keyBy(await api.channels.all(), 'id')
|
||||||
|
|
||||||
logger.info(`looking for streams...`)
|
logger.info(`looking for streams...`)
|
||||||
await db.streams.load()
|
await db.streams.load()
|
||||||
|
@ -30,7 +31,7 @@ async function findStreams() {
|
||||||
item.filepath = filepath
|
item.filepath = filepath
|
||||||
|
|
||||||
const stream = store.create()
|
const stream = store.create()
|
||||||
const channel = await api.channels.find({ id: item.tvg.id })
|
const channel = channels[item.tvg.id]
|
||||||
|
|
||||||
stream.set('channel', { channel: channel ? channel.id : null })
|
stream.set('channel', { channel: channel ? channel.id : null })
|
||||||
stream.set('title', { title: item.name })
|
stream.set('title', { title: item.name })
|
||||||
|
@ -51,7 +52,6 @@ async function saveToDatabase(streams = []) {
|
||||||
logger.info('saving to the database...')
|
logger.info('saving to the database...')
|
||||||
|
|
||||||
await db.streams.reset()
|
await db.streams.reset()
|
||||||
for (const stream of streams) {
|
const data = streams.map(stream => stream.data())
|
||||||
await db.streams.insert(stream.data())
|
await db.streams.insert(data)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue