mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-11 18:46:30 +00:00
parent
1a08d009d8
commit
3c45630062
4 changed files with 21 additions and 2 deletions
|
@ -34,6 +34,7 @@ tokenCount = 10
|
|||
theme = "Nitter"
|
||||
replaceTwitter = "nitter.net"
|
||||
replaceYouTube = "piped.kavin.rocks"
|
||||
replaceReddit = "teddit.net"
|
||||
replaceInstagram = ""
|
||||
proxyVideos = true
|
||||
hlsPlayback = false
|
||||
|
|
|
@ -4,8 +4,16 @@ import types, utils, query
|
|||
|
||||
const
|
||||
ytRegex = re"([A-z.]+\.)?youtu(be\.com|\.be)"
|
||||
twRegex = re"(?<![^\/> ])(?<![^\/]\/)(www\.|mobile\.)?twitter\.com"
|
||||
igRegex = re"(www\.)?instagram\.com"
|
||||
|
||||
rdRegex = re"(?<![.b])((www|np|new|amp|old)\.)?reddit.com"
|
||||
rdShortRegex = re"(?<![.b])redd\.it\/"
|
||||
# Videos cannot be supported uniformly between Teddit and Libreddit,
|
||||
# so v.redd.it links will not be replaced.
|
||||
# Images aren't supported due to errors from Teddit when the image
|
||||
# wasn't first displayed via a post on the Teddit instance.
|
||||
|
||||
twRegex = re"(?<![^\/> ])(?<![^\/]\/)(www\.|mobile\.)?twitter\.com"
|
||||
cards = "cards.twitter.com/cards"
|
||||
tco = "https://t.co"
|
||||
|
||||
|
@ -53,6 +61,12 @@ proc replaceUrl*(url: string; prefs: Prefs; absolute=""): string =
|
|||
result = result.replace(cards, prefs.replaceTwitter & "/cards")
|
||||
result = result.replace(twRegex, prefs.replaceTwitter)
|
||||
|
||||
if prefs.replaceReddit.len > 0 and (rdRegex in result or "redd.it" in result):
|
||||
result = result.replace(rdShortRegex, prefs.replaceReddit & "/comments/")
|
||||
result = result.replace(rdRegex, prefs.replaceReddit)
|
||||
if prefs.replaceReddit in result and "/gallery/" in result:
|
||||
result = result.replace("/gallery/", "/comments/")
|
||||
|
||||
if prefs.replaceInstagram.len > 0 and igRegex in result:
|
||||
result = result.replace(igRegex, prefs.replaceInstagram)
|
||||
|
||||
|
|
|
@ -58,6 +58,10 @@ genPrefs:
|
|||
"Replace YouTube links with Piped/Invidious (blank to disable)"
|
||||
placeholder: "Piped hostname"
|
||||
|
||||
replaceReddit(input, "teddit.net"):
|
||||
"Replace Reddit links with Teddit/Libreddit (blank to disable)"
|
||||
placeholder: "Teddit hostname"
|
||||
|
||||
replaceInstagram(input, ""):
|
||||
"Replace Instagram links with Bibliogram (blank to disable)"
|
||||
placeholder: "Bibliogram hostname"
|
||||
|
|
|
@ -42,7 +42,7 @@ link = [
|
|||
['nim_lang/status/1110499584852353024', [
|
||||
'nim-lang.org/araq/ownedrefs.…',
|
||||
'news.ycombinator.com/item?id…',
|
||||
'old.reddit.com/r/programming…'
|
||||
'teddit.net/r/programming…'
|
||||
]],
|
||||
['nim_lang/status/1125887775151140864', [
|
||||
'en.wikipedia.org/wiki/Nim_(p…'
|
||||
|
|
Loading…
Reference in a new issue