Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion modules/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,45 @@ export function capture(response, source_platform_url, source_url) {

traverse(data);
return tweets;
}
}

// === auto-generated by 4cat map_item sync β€” BLOCK REPLACED AUTOMATICALLY ===
// (regenerated from datasources/twitter-import/search_twitter.py)
function _screen_name_from_media(legacy_obj) {

if (!legacy_obj || typeof legacy_obj !== 'object') {

return '';

}

for (const container of ['extended_entities', 'entities']) {

for (const m of legacy_obj[container]?.media || []) {

if (typeof m !== 'object') {

continue;

}

const url = m.expanded_url || '';

const match = /^https?:\/\/(?:x|twitter)\.com\/([^/]+)\/status\//.exec(url);

if (match) {

return match[1];

}

}

}

return '';

}

export function map_item(item) {
// === end auto-generated ===