From 2de12c90a62f8eb6164908c55c4768d435a2cccd Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 13 Feb 2022 01:40:38 +0300 Subject: [PATCH] Create export.js --- scripts/commands/database/export.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/commands/database/export.js diff --git a/scripts/commands/database/export.js b/scripts/commands/database/export.js new file mode 100644 index 0000000000..e7a0036243 --- /dev/null +++ b/scripts/commands/database/export.js @@ -0,0 +1,23 @@ +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 { + channel: stream.channel_id, + display_name: stream.display_name, + url: stream.url, + http_referrer: stream.http['referrer'], + user_agent: stream.http['user-agent'] + } + }) + + await file.create(`${PUBLIC_DIR}/streams.json`, JSON.stringify(streams)) +} + +main()