mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Strip https://pbs.twimg.com from image urls
This commit is contained in:
parent
ea7222bc86
commit
47c87f7068
5 changed files with 31 additions and 18 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import strutils, times, macros, htmlgen, uri, unicode, options
|
||||
import strutils, times, macros, htmlgen, unicode, options
|
||||
import regex, packedjson
|
||||
import types, utils, formatters
|
||||
|
||||
|
|
@ -58,8 +58,13 @@ proc getId*(js: JsonNode): int64 {.inline.} =
|
|||
template getStrVal*(js: JsonNode; default=""): string =
|
||||
js{"string_value"}.getStr(default)
|
||||
|
||||
template getImageVal*(js: JsonNode; default=""): string =
|
||||
js{"image_value", "url"}.getStr(default)
|
||||
proc getImageStr*(js: JsonNode): string =
|
||||
result = js.getStr
|
||||
result.removePrefix(https)
|
||||
result.removePrefix(twimg)
|
||||
|
||||
template getImageVal*(js: JsonNode): string =
|
||||
js{"image_value", "url"}.getImageStr
|
||||
|
||||
proc getCardUrl*(js: JsonNode; kind: CardKind): string =
|
||||
result = js{"website_url"}.getStrVal
|
||||
|
|
@ -81,7 +86,7 @@ proc getCardTitle*(js: JsonNode; kind: CardKind): string =
|
|||
result = js{"event_category"}.getStrVal
|
||||
|
||||
proc getBanner*(js: JsonNode): string =
|
||||
let url = js{"profile_banner_url"}.getStr
|
||||
let url = js{"profile_banner_url"}.getImageStr
|
||||
if url.len > 0:
|
||||
return url & "/1500x500"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue