[site]
name = "twitter"
patterns = ["(?i)(?:x|twitter)\\.com/.+/status/\\d+"]

[rewrite]
from = "(?i)https?://(?:x|twitter)\\.com/([^/?#]+)/status/(\\d+).*"
to = "https://api.fxtwitter.com/$1/status/$2"

[request]
accept = "application/json"
# FxTwitter returns {"code":404,"tweet":null} with HTTP 200 for deleted/private
# tweets.  Guard extraction on the tweet object being present and non-null so
# the provider fails fast (rather than emitting a confusing "check json paths"
# warning) and lets nab fall back to the normal HTTP fetch path.
success_path = ".tweet"

[json]
author_name = ".tweet.author.name"
author_handle = ".tweet.author.screen_name"
text = ".tweet.text"
date = ".tweet.created_at"
url = ".tweet.url"
likes = ".tweet.likes"
retweets = ".tweet.retweets"
replies = ".tweet.replies"
views = ".tweet.views"
# X Articles / Notes (long-form posts) — fxtwitter puts full content in .tweet.article
article_title = ".tweet.article.title"
article_preview = ".tweet.article.preview_text"
article_content = ".tweet.article.content.blocks[].text"

[template]
format = """
## @{author_handle} ({author_name})

# {article_title}

{article_content}

{text}

📊 {likes|number} likes · {retweets|number} reposts · {replies|number} replies
👁 {views|number} views
🕐 {date}

[View on X]({url})
"""

[metadata]
platform = "Twitter/X"
author = "{author_name} (@{author_handle})"
title_field = ""
published_field = "date"
canonical_url_field = "url"

[engagement]
likes = "likes"
reposts = "retweets"
replies = "replies"
views = "views"
