id author title date pages extension mime words sentences flesch summary cache txt github-com-7851 twarc/expansions.py at main · DocNow/twarc · GitHub .html text/html 850 162 55 twarc/expansions.py at main · DocNow/twarc · GitHub Open source guides → Code definitions This module contains a list of the known Twitter V2+ API expansions and fields for each expansion, and a function for "flattening" a result set, including all "country_code", def extract_includes(response, expansion, _id="id"): # Users extracted both by id and by username for expanding mentions includes_users = defaultdict( **extract_includes(response, "users", "id"), **extract_includes(response, "users", "username"), includes_media = extract_includes(response, "media", "media_key") includes_places = extract_includes(response, "places") # Tweets in includes will themselves be expanded includes_tweets = extract_includes(response, "tweets") if "in_reply_to_user_id" in payload: if "media_keys" in payload: payload["media"] = list( poll_id = payload["poll_ids"][-1] # only ever 1 poll per tweet. payload["poll"] = includes_polls[poll_id] payload["mentions"] = list( for referenced_user in payload["mentions"] if "referenced_tweets" in payload: payload["referenced_tweets"] = list( if "pinned_tweet_id" in payload: includes_tweets[included_id] = expand_payload(included_tweet) for tweet in response["data"]: tweet["__twarc"] = response["__twarc"] Copy lines You can't perform that action at this time. ./cache/github-com-7851.html ./txt/github-com-7851.txt