mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 18:10:04 -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() {
|
||||
logger.info(`loading channels...`)
|
||||
await api.channels.load()
|
||||
const channels = _.keyBy(await api.channels.all(), 'id')
|
||||
|
||||
logger.info(`looking for streams...`)
|
||||
await db.streams.load()
|
||||
|
@ -30,7 +31,7 @@ async function findStreams() {
|
|||
item.filepath = filepath
|
||||
|
||||
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('title', { title: item.name })
|
||||
|
@ -51,7 +52,6 @@ async function saveToDatabase(streams = []) {
|
|||
logger.info('saving to the database...')
|
||||
|
||||
await db.streams.reset()
|
||||
for (const stream of streams) {
|
||||
await db.streams.insert(stream.data())
|
||||
}
|
||||
const data = streams.map(stream => stream.data())
|
||||
await db.streams.insert(data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue