[site]
name = "reddit"
patterns = [
"(?i)(?:www\\.)?reddit\\.com/r/[^/]+/comments/",
"(?i)old\\.reddit\\.com/r/[^/]+/comments/",
]
[rewrite]
from = "(?i)(https?://(?:(?:www\\.|old\\.)?reddit\\.com/r/[^/]+/comments/[^/?#]+(?:/[^/?#]+)?))[?#]?.*"
to = "$1.json"
[request]
client = "standard"
headers = { "User-Agent" = "nab/1.0 (by /u/nab-cli)" }
accept = "application/json"
[json]
title = "[0].data.children[0].data.title"
author = "[0].data.children[0].data.author"
score = "[0].data.children[0].data.score"
comments = "[0].data.children[0].data.num_comments"
selftext = "[0].data.children[0].data.selftext"
url = "[0].data.children[0].data.url"
subreddit = "[0].data.children[0].data.subreddit"
permalink = "[0].data.children[0].data.permalink"
c0_author = "[1].data.children[0].data.author"
c0_body = "[1].data.children[0].data.body"
c0_score = "[1].data.children[0].data.score"
c1_author = "[1].data.children[1].data.author"
c1_body = "[1].data.children[1].data.body"
c1_score = "[1].data.children[1].data.score"
c2_author = "[1].data.children[2].data.author"
c2_body = "[1].data.children[2].data.body"
c2_score = "[1].data.children[2].data.score"
[template]
format = """
## {title}
r/{subreddit} · by u/{author} · {score|number} points · {comments|number} comments
{selftext}
### Top Comments
**u/{c0_author}** · {c0_score|number} points
{c0_body}
---
**u/{c1_author}** · {c1_score|number} points
{c1_body}
---
**u/{c2_author}** · {c2_score|number} points
{c2_body}
---
[View on Reddit](https://www.reddit.com{permalink})
"""
[metadata]
platform = "Reddit"
author = "u/{author}"
title_field = "title"
canonical_url_field = "url"
[engagement]
likes = "score"
replies = "comments"
[[fallback]]
rewrite_from = "(?i)https?://(?:(?:www\\.)?reddit\\.com|old\\.reddit\\.com)(/r/[^/]+/comments/[^/?#]+(?:/[^/?#]+)?)[?#]?.*"
rewrite_to = "https://old.reddit.com$1"
type = "html"
[fallback.css]
title = ".title a.title"
author = ".tagline .author"
score = ".score .number"
selftext = ".usertext-body .md"
subreddit = ".redditname a"