mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-11-25 20:42:40 +00:00
Pulled in the twitter content backup functionality from curvyandtrans.com
Sadly, lost the images from one of Emmy_Zje's deleted tweets.
This commit is contained in:
@@ -12,16 +12,17 @@ const actions = {
|
||||
return readFile(input);
|
||||
},
|
||||
|
||||
async transcode ({ input, output }) {
|
||||
async transcode ({ input, output, duplicate }) {
|
||||
const result = await actions.image({
|
||||
input,
|
||||
output,
|
||||
duplicate,
|
||||
format: 'jpeg',
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
async fetch ({ input, output }) {
|
||||
async fetch ({ input, output, duplicate }) {
|
||||
const res = await fetch(input);
|
||||
if (res.status !== 200) {
|
||||
throw new Error(`File could not be fetched (${res.status}): "${input}"`);
|
||||
@@ -30,16 +31,24 @@ const actions = {
|
||||
output = resolve(output);
|
||||
await fs.ensureDir(path.dirname(output));
|
||||
await fs.writeFile(output, body);
|
||||
if (duplicate) {
|
||||
await fs.ensureDir(resolve(path.dirname(duplicate)));
|
||||
await fs.writeFile(duplicate, body);
|
||||
}
|
||||
return body;
|
||||
},
|
||||
|
||||
async write ({ output, content }) {
|
||||
async write ({ output, content, duplicate }) {
|
||||
if (!content) {
|
||||
throw new TypeError('Got an empty write?' + output);
|
||||
}
|
||||
output = resolve(output);
|
||||
await fs.ensureDir(path.dirname(output));
|
||||
await fs.writeFile(output, content);
|
||||
if (duplicate) {
|
||||
await fs.ensureDir(resolve(path.dirname(duplicate)));
|
||||
await fs.writeFile(duplicate, content);
|
||||
}
|
||||
return Buffer.from(content);
|
||||
},
|
||||
|
||||
@@ -157,6 +166,10 @@ const actions = {
|
||||
let result = await Promise.fromCallback((cb) => gmfile.toBuffer(cb));
|
||||
if (options.format === 'ico') result = await ico(result);
|
||||
await fs.writeFile(output, result);
|
||||
if (options.duplicate) {
|
||||
await fs.ensureDir(resolve(path.dirname(options.duplicate)));
|
||||
await fs.writeFile(options.duplicate, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user