You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
super-hog/resources/actions/mindenErlebenApi.js

59 lines
1.4 KiB

import got from 'got'
import url from 'url'
import path from 'path'
import dayjs from 'dayjs'
import { createWriteStream } from 'fs'
import stream from 'node:stream'
import { promisify } from 'util'
import Action from './../../src/runner/actions/action.js'
import logger from './../../src/runner/helpers/logger.js'
import EventStore from './../directus/event.js'
import { Directus } from '@directus/sdk';
/**
* Download Episodes from a RSS-Feed,
*
*
* @extends Action
*
*/
class MindenErlebenApi extends Action {
async run() {
const eventStore = new EventStore()
// adding result
let result
if (this.lastResult) {
for (let data of this.lastResult) {
if (data.mediaUrl) {
// import media to directus
const media = await eventStore.importMediaFromUrl(data.mediaUrl)
// if import successfull add to data
if (media) {
data.media = {
id: media
}
}
delete data.mediaUrl
}
result = await eventStore.create(data)
if (result && result.id) {
logger.info(data.source_host + ' / update, create ' + result.title)
}
}
}
}
}
export default MindenErlebenApi