Cleanup
This commit is contained in:
parent
9d117aa15b
commit
9dd7419ecf
|
@ -31,7 +31,7 @@ proc windows(): string =
|
||||||
trident = ["", "; Trident/5.0", "; Trident/6.0", "; Trident/7.0"]
|
trident = ["", "; Trident/5.0", "; Trident/6.0", "; Trident/7.0"]
|
||||||
"Windows " & sample(nt) & sample(enc) & sample(arch) & sample(trident)
|
"Windows " & sample(nt) & sample(enc) & sample(arch) & sample(trident)
|
||||||
|
|
||||||
let macs = toSeq(6..15).mapIt($it) & @["14_4", "10_1", "9_3"]
|
const macs = toSeq(6..15).mapIt($it) & @["14_4", "10_1", "9_3"]
|
||||||
|
|
||||||
proc mac(): string =
|
proc mac(): string =
|
||||||
"Macintosh; Intel Mac OS X 10_" & sample(macs) & sample(enc)
|
"Macintosh; Intel Mac OS X 10_" & sample(macs) & sample(enc)
|
||||||
|
|
|
@ -4,11 +4,12 @@ import redis, redpool, flatty, supersnappy
|
||||||
|
|
||||||
import types, api
|
import types, api
|
||||||
|
|
||||||
const redisNil = "\0\0"
|
const
|
||||||
|
redisNil = "\0\0"
|
||||||
|
baseCacheTime = 60 * 60
|
||||||
|
|
||||||
var
|
var
|
||||||
pool {.threadvar.}: RedisPool
|
pool {.threadvar.}: RedisPool
|
||||||
baseCacheTime = 60 * 60
|
|
||||||
rssCacheTime: int
|
rssCacheTime: int
|
||||||
listCacheTime*: int
|
listCacheTime*: int
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@ var
|
||||||
const
|
const
|
||||||
https* = "https://"
|
https* = "https://"
|
||||||
twimg* = "pbs.twimg.com/"
|
twimg* = "pbs.twimg.com/"
|
||||||
badJpgExts = @["1500x500", "jpgn", "jpg:", "jpg_", "_jpg"]
|
|
||||||
badPngExts = @["pngn", "png:", "png_", "_png"]
|
|
||||||
twitterDomains = @[
|
twitterDomains = @[
|
||||||
"twitter.com",
|
"twitter.com",
|
||||||
"pic.twitter.com",
|
"pic.twitter.com",
|
||||||
|
@ -19,6 +17,7 @@ const
|
||||||
"pbs.twimg.com",
|
"pbs.twimg.com",
|
||||||
"video.twimg.com"
|
"video.twimg.com"
|
||||||
]
|
]
|
||||||
|
nitterParams = ["name", "tab", "id", "list", "referer", "scroll"]
|
||||||
|
|
||||||
proc setHmacKey*(key: string) =
|
proc setHmacKey*(key: string) =
|
||||||
hmacKey = key
|
hmacKey = key
|
||||||
|
@ -43,18 +42,9 @@ proc getPicUrl*(link: string): string =
|
||||||
else:
|
else:
|
||||||
&"/pic/{encodeUrl(link)}"
|
&"/pic/{encodeUrl(link)}"
|
||||||
|
|
||||||
proc cleanFilename*(filename: string): string =
|
|
||||||
const reg = re"[^A-Za-z0-9._-]"
|
|
||||||
result = filename.replace(reg, "_")
|
|
||||||
if badJpgExts.anyIt(it in result):
|
|
||||||
result &= ".jpg"
|
|
||||||
elif badPngExts.anyIt(it in result):
|
|
||||||
result &= ".png"
|
|
||||||
|
|
||||||
proc filterParams*(params: Table): seq[(string, string)] =
|
proc filterParams*(params: Table): seq[(string, string)] =
|
||||||
const filter = ["name", "tab", "id", "list", "referer", "scroll"]
|
|
||||||
for p in params.pairs():
|
for p in params.pairs():
|
||||||
if p[1].len > 0 and p[0] notin filter:
|
if p[1].len > 0 and p[0] notin nitterParams:
|
||||||
result.add p
|
result.add p
|
||||||
|
|
||||||
proc isTwitterUrl*(uri: Uri): bool =
|
proc isTwitterUrl*(uri: Uri): bool =
|
||||||
|
|
Loading…
Reference in New Issue