bugfix: URL expansion in Twitter (#500)
This solves an edge case where the `"url"` entity does not have an `"expanded_url"` case when expanding. The behavior for now is simply don't replace the URL as it seems the display_url is NOT what we want to keep as it's normally abbreviated --------- Co-authored-by: Eric Gustin <34000337+EricGustin@users.noreply.github.com>
This commit is contained in:
parent
0b1f513826
commit
173cc6994e
2 changed files with 5 additions and 4 deletions
|
|
@ -82,6 +82,7 @@ def expand_urls_in_tweets(
|
||||||
new_tweet = tweet_data.copy()
|
new_tweet = tweet_data.copy()
|
||||||
if "entities" in new_tweet and "urls" in new_tweet["entities"]:
|
if "entities" in new_tweet and "urls" in new_tweet["entities"]:
|
||||||
for url_entity in new_tweet["entities"]["urls"]:
|
for url_entity in new_tweet["entities"]["urls"]:
|
||||||
|
if "url" in url_entity and "expanded_url" in url_entity:
|
||||||
short_url = url_entity["url"]
|
short_url = url_entity["url"]
|
||||||
expanded_url = url_entity["expanded_url"]
|
expanded_url = url_entity["expanded_url"]
|
||||||
new_tweet["text"] = new_tweet["text"].replace(short_url, expanded_url)
|
new_tweet["text"] = new_tweet["text"].replace(short_url, expanded_url)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "arcade_x"
|
name = "arcade_x"
|
||||||
version = "0.1.15"
|
version = "0.1.16"
|
||||||
description = "Arcade.dev LLM tools for X (Twitter)"
|
description = "Arcade.dev LLM tools for X (Twitter)"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [ "arcade-tdk>=2.0.0,<3.0.0", "httpx>=0.27.2,<1.0.0",]
|
dependencies = [ "arcade-tdk>=2.0.0,<3.0.0", "httpx>=0.27.2,<1.0.0",]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue