UNPKG

kap-royalv

Version:

Share on Royal-V

46 lines (38 loc) 1.01 kB
'use strict'; const fs = require('fs'); const FormData = require('form-data'); const action = async context => { const endpoint = 'https://acp.royal-v.de/img/upload'; const filePath = await context.filePath(); context.setProgress('Uploading…'); const form = new FormData(); form.append('pid', context.config.get('playerId')); form.append('api', context.config.get('apiKey')); form.append('rv_upload_img', fs.createReadStream(filePath)); const response = await context.request(endpoint, { method: 'post', body: form }); const img_url = JSON.parse(response.body).img_url; context.copyToClipboard(img_url); context.notify('URL has been copied to the clipboard'); }; const royalv = { title: 'Share to Royal-V', formats: ['gif', 'mp4', 'webm', 'apng'], action, config: { playerId: { title: 'Spieler ID', type: 'integer', required: true }, apiKey: { title: 'API key', type: 'string', minLength: 32, required: true } } }; exports.shareServices = [royalv];