Commit 3f6adeed authored by Anton's avatar Anton

Add update videos script

parent 6ff2ccf9
const
{ MongoDB } = require('mbjs-persistence'),
{ ObjectUtil } = require('mbjs-utils'),
config = require('config')
const proc = async function () {
console.log('VIDEOS\n-------------------\n\n')
const annoClient = new MongoDB(
ObjectUtil.merge({ name: 'annotations', logger: console },
config.get('resources.mongodb')),
'uuid'
)
await annoClient.connect()
const annos = await annoClient.find({ 'body.type': 'Video' })
for (let anno of annos) {
if (anno.body.source && anno.body.source.id && anno.body.source.id.indexOf(process.env.VIDEO_HOST_OLD) === 0) {
console.log('Modifying', anno.body.source.id)
const url = URL(anno.body.source.id)
anno.body.source.id = `${process.env.VIDEO_HOST_NEW}${url.pathname}`
console.log('New', anno.body.source.id)
await annoClient.update(anno.uuid, anno, {})
}
}
}
proc().then(() => process.exit(0))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment