mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 19:16:28 +00:00
Merge branch 'original-image-urls'
This commit is contained in:
commit
90135d44e1
3 changed files with 23 additions and 3 deletions
|
@ -88,6 +88,20 @@ proc createMediaRouter*(cfg: Config) =
|
|||
get "/pic/?":
|
||||
resp Http404
|
||||
|
||||
get re"^\/pic\/orig\/(enc)?\/?(.+)":
|
||||
var url = decoded(request, 1)
|
||||
if "twimg.com" notin url:
|
||||
url.insert(twimg)
|
||||
if not url.startsWith(https):
|
||||
url.insert(https)
|
||||
url.add("?name=orig")
|
||||
|
||||
let uri = parseUri(url)
|
||||
cond isTwitterUrl(uri) == true
|
||||
|
||||
let code = await proxyMedia(request, url)
|
||||
check code
|
||||
|
||||
get re"^\/pic\/(enc)?\/?(.+)":
|
||||
var url = decoded(request, 1)
|
||||
if "twimg.com" notin url:
|
||||
|
|
|
@ -42,6 +42,12 @@ proc getPicUrl*(link: string): string =
|
|||
else:
|
||||
&"/pic/{encodeUrl(link)}"
|
||||
|
||||
proc getOrigPicUrl*(link: string): string =
|
||||
if base64Media:
|
||||
&"/pic/orig/enc/{encode(link, safe=true)}"
|
||||
else:
|
||||
&"/pic/orig/{encodeUrl(link)}"
|
||||
|
||||
proc filterParams*(params: Table): seq[(string, string)] =
|
||||
for p in params.pairs():
|
||||
if p[1].len > 0 and p[0] notin nitterParams:
|
||||
|
|
|
@ -10,7 +10,7 @@ import general
|
|||
proc getSmallPic(url: string): string =
|
||||
result = url
|
||||
if "?" notin url and not url.endsWith("placeholder.png"):
|
||||
result &= ":small"
|
||||
result &= "?name=small"
|
||||
result = getPicUrl(result)
|
||||
|
||||
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
|
||||
|
@ -57,9 +57,9 @@ proc renderAlbum(tweet: Tweet): VNode =
|
|||
tdiv(class="attachment image"):
|
||||
let
|
||||
named = "name=" in photo
|
||||
orig = if named: photo else: photo & "?name=orig"
|
||||
orig = photo
|
||||
small = if named: photo else: photo & "?name=small"
|
||||
a(href=getPicUrl(orig), class="still-image", target="_blank"):
|
||||
a(href=getOrigPicUrl(orig), class="still-image", target="_blank"):
|
||||
genImg(small)
|
||||
|
||||
proc isPlaybackEnabled(prefs: Prefs; video: Video): bool =
|
||||
|
|
Loading…
Reference in a new issue