diff --git a/modules/twitter.js b/modules/twitter.js index e05c7c0..0357e55 100644 --- a/modules/twitter.js +++ b/modules/twitter.js @@ -129,4 +129,45 @@ export function capture(response, source_platform_url, source_url) { traverse(data); return tweets; -} \ No newline at end of file +} + +// === 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 ===