INNER CODE UNIT · Python

to_api

fa0311/TwitterInternalAPIDocument · lib/graphql.py:169

def to_api(graphql_output: list, kwargs: dict) -> dict:
    variable_converter = {
        "!0": True,
        "!1": False,
        "true": True,
        "false": False,
    }
    api_output = {"graphql": {}}

    for graphql in graphql_output:
        features = {}
        exports = graphql["exports"]
        for key in exports["metadata"]["featureSwitches"]:
            switch = exports["metadata"]["featureSwitch"].get(key, None)
            if switch != None:
                features[key] = variable_converter.get(switch["value"])
            else:
                logging.warning("NotFoundKey: " + key)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…