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
2 years ago
|
const { logger, db, file } = require('../../core')
|
||
3 years ago
|
const _ = require('lodash')
|
||
|
|
||
3 years ago
|
const PUBLIC_DIR = process.env.PUBLIC_DIR || '.api'
|
||
3 years ago
|
|
||
|
async function main() {
|
||
2 years ago
|
logger.info(`loading streams...`)
|
||
3 years ago
|
await db.streams.load()
|
||
2 years ago
|
|
||
3 years ago
|
let streams = await db.streams.find({})
|
||
3 years ago
|
streams = _.sortBy(streams, 'channel')
|
||
3 years ago
|
streams = streams.map(stream => {
|
||
3 years ago
|
let data = {
|
||
3 years ago
|
channel: stream.channel,
|
||
3 years ago
|
url: stream.url,
|
||
3 years ago
|
http_referrer: stream.http_referrer,
|
||
2 years ago
|
user_agent: stream.user_agent
|
||
3 years ago
|
}
|
||
|
|
||
|
return data
|
||
3 years ago
|
})
|
||
2 years ago
|
logger.info(`found ${streams.length} streams`)
|
||
3 years ago
|
|
||
2 years ago
|
logger.info('saving to .api/streams.json...')
|
||
3 years ago
|
await file.create(`${PUBLIC_DIR}/streams.json`, JSON.stringify(streams))
|
||
|
}
|
||
|
|
||
|
main()
|