From b51f1cbbd4b9bd2236768dc304655b0df0f28311 Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 25 Jun 2019 19:19:01 +0200 Subject: [PATCH] Fix username regex, add media endpoint --- src/api.nim | 5 ++++- src/formatters.nim | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api.nim b/src/api.nim index 4e4f94a..9a222cc 100644 --- a/src/api.nim +++ b/src/api.nim @@ -11,7 +11,10 @@ const base = parseUri("https://twitter.com/") apiBase = parseUri("https://api.twitter.com/1.1/") - timelineUrl = "i/profiles/show/$1/timeline/tweets?include_available_features=1&include_entities=1&include_new_items_bar=true" + timelineParams = "?include_available_features=1&include_entities=1&include_new_items_bar=false&reset_error_state=false" + showUrl = "i/profiles/show/$1" & timelineParams + timelineUrl = showUrl % "$1/timeline/tweets" + timelineMediaUrl = showUrl % "$1/media_timeline" profilePopupUrl = "i/profiles/popup" profileIntentUrl = "intent/user" tweetUrl = "i/status/" diff --git a/src/formatters.nim b/src/formatters.nim index bef2c71..25b8479 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -8,7 +8,7 @@ from unicode import Rune, `$` const urlRegex = re"((https?|ftp)://(-\.)?([^\s/?\.#]+\.?)+(/[^\s\)]*)?)" emailRegex = re"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)" - usernameRegex = re"(^|[^\S]|\.|>)@([A-z0-9_]+)" + usernameRegex = re"(^|[\s\.,>])@([A-z0-9_]+)" picRegex = re"pic.twitter.com/[^ ]+" cardRegex = re"(https?://)?cards.twitter.com/[^ ]+" ellipsisRegex = re" ?…"