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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user