iptv/scripts/commands/database/export.js

27 lines
661 B
JavaScript
Raw Normal View History

2022-02-12 23:40:38 +01:00
const { logger, db, file } = require('../../core')
const _ = require('lodash')
2022-02-13 09:50:57 +01:00
const PUBLIC_DIR = process.env.PUBLIC_DIR || '.api'
2022-02-12 23:40:38 +01:00
async function main() {
await db.streams.load()
let streams = await db.streams.find({})
2022-02-13 08:29:11 +01:00
streams = _.sortBy(streams, 'channel')
2022-02-12 23:40:38 +01:00
streams = streams.map(stream => {
return {
2022-02-13 03:42:39 +01:00
channel: stream.channel,
2022-02-12 23:40:38 +01:00
url: stream.url,
2022-02-13 05:16:59 +01:00
http_referrer: stream.http_referrer,
user_agent: stream.user_agent,
2022-02-13 08:29:11 +01:00
status: stream.status,
2022-02-13 03:42:39 +01:00
width: stream.width,
height: stream.height,
2022-02-13 05:16:59 +01:00
bitrate: stream.bitrate
2022-02-12 23:40:38 +01:00
}
})
await file.create(`${PUBLIC_DIR}/streams.json`, JSON.stringify(streams))
}
main()