-function createEmptyCallback () {
- return function (err) {
- if (err) logger.error('Error in empty callback.', { error: err })
- }
+function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: T[], objectsTotal: number, formattedArg?: U) {
+ const formattedObjects = objects.map(o => o.toFormattedJSON(formattedArg))
+
+ return {
+ total: objectsTotal,
+ data: formattedObjects
+ } as ResultList<V>
+}
+
+const getServerActor = memoizee(async function () {
+ const application = await ApplicationModel.load()
+ if (!application) throw Error('Could not load Application from database.')
+
+ const actor = application.Account.Actor
+ actor.Account = application.Account
+
+ return actor
+})
+
+function generateVideoImportTmpPath (target: string | ParseTorrent) {
+ const id = typeof target === 'string' ? target : target.infoHash
+
+ const hash = sha256(id)
+ return join(CONFIG.STORAGE.TMP_DIR, hash + '-import.mp4')