mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
700 B
JavaScript
29 lines
700 B
JavaScript
const { logger, db, file } = require('../../core')
|
|
const _ = require('lodash')
|
|
|
|
const PUBLIC_DIR = process.env.PUBLIC_DIR || '.api'
|
|
|
|
async function main() {
|
|
logger.info(`loading streams...`)
|
|
await db.streams.load()
|
|
|
|
let streams = await db.streams.find({})
|
|
streams = _.sortBy(streams, 'channel')
|
|
streams = streams.map(stream => {
|
|
let data = {
|
|
channel: stream.channel,
|
|
url: stream.url,
|
|
http_referrer: stream.http_referrer,
|
|
user_agent: stream.user_agent
|
|
}
|
|
|
|
return data
|
|
})
|
|
logger.info(`found ${streams.length} streams`)
|
|
|
|
logger.info('saving to .api/streams.json...')
|
|
await file.create(`${PUBLIC_DIR}/streams.json`, JSON.stringify(streams))
|
|
}
|
|
|
|
main()
|