1
0
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:
Jocelyn Badgley (Twipped)
2021-08-25 09:45:21 -07:00
parent 3e570577b2
commit 9bfa5c4690
110 changed files with 6637 additions and 6029 deletions

View File

@@ -1,5 +1,6 @@
var twemoji = require('twemoji' );
const { deepPick, has } = require('./util');
const path = require('path');
const schema = {
id_str: true,
@@ -23,6 +24,7 @@ const schema = {
} ] },
} ] },
media: true,
in_reply_to_status_id_str: true,
};
var entityProcessors = {
@@ -94,7 +96,8 @@ module.exports = exports = function (tweets) {
tweet.user.avatar = {
input: tweet.user.profile_image_url_https,
output: 'tweets/' + tweet.user.screen_name + '.jpg',
output: `tweets/${tweet.user.screen_name}.jpg`,
cache: `twitter-avatars/${tweet.user.screen_name}.jpg`,
};
tweet.media = [
@@ -113,7 +116,22 @@ module.exports = exports = function (tweets) {
}
if (has(tweet, 'entities.media') && has(tweet, 'extended_entities.media')) {
tweet.entities.media = tweet.extended_entities.media;
tweet.entities.media = tweet.extended_entities.media.map((media) => {
media = { ...media };
if (media.media_url_https) {
const mediaItem = {
input: media.media_url_https,
output: `tweets/${tweet.id_str}/${path.basename(media.media_url_https)}`,
cache: `twitter-entities/${tweet.id_str}/${path.basename(media.media_url_https)}`,
};
if (media.type === 'photo') mediaItem.input += '?name=medium';
tweet.media.push(mediaItem);
media.media_url_https = '/' + mediaItem.output;
}
return media;
});
delete tweet.extended_entities;
}