iptv/scripts/commands/database/export.js

28 lines
702 B
JavaScript
Raw Normal View History

2022-02-12 23:40:38 +01:00
const { logger, db, file } = require('../../core')
const _ = require('lodash')
const PUBLIC_DIR = process.env.PUBLIC_DIR || '.gh-pages'
async function main() {
await db.streams.load()
let streams = await db.streams.find({})
streams = _.sortBy(streams, 'channel_id')
streams = streams.map(stream => {
return {
2022-02-13 03:42:39 +01:00
channel: stream.channel,
title: stream.title,
2022-02-12 23:40:38 +01:00
url: stream.url,
2022-02-13 03:42:39 +01:00
width: stream.width,
height: stream.height,
bitrate: stream.bitrate,
is_online: stream.is_online,
http_referrer: stream.http_referrer,
user_agent: stream.user_agent
2022-02-12 23:40:38 +01:00
}
})
await file.create(`${PUBLIC_DIR}/streams.json`, JSON.stringify(streams))
}
main()