mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-23 04:35:32 +00:00
Skip search requests when query is empty
This commit is contained in:
parent
1e1e034237
commit
aa2fed19d7
15
src/api.nim
15
src/api.nim
|
@ -67,11 +67,16 @@ proc getSearch*[T](query: Query; after=""): Future[Result[T]] {.async.} =
|
|||
searchMode = ("tweet_search_mode", "live")
|
||||
parse = parseTimeline
|
||||
|
||||
let
|
||||
q = genQueryParam(query)
|
||||
url = search ? genParams(searchParams & @[("q", q), searchMode], after)
|
||||
result = parse(await fetch(url), after)
|
||||
result.query = query
|
||||
let q = genQueryParam(query)
|
||||
if q.len == 0 or q == emptyQuery:
|
||||
return Result[T](beginning: true, query: query)
|
||||
|
||||
let url = search ? genParams(searchParams & @[("q", q), searchMode], after)
|
||||
try:
|
||||
result = parse(await fetch(url), after)
|
||||
result.query = query
|
||||
except InternalError:
|
||||
return Result[T](beginning: true, query: query)
|
||||
|
||||
proc getTweetImpl(id: string; after=""): Future[Conversation] {.async.} =
|
||||
let url = tweet / (id & ".json") ? genParams(cursor=after)
|
||||
|
|
|
@ -12,6 +12,8 @@ const
|
|||
"verified", "safe"
|
||||
]
|
||||
|
||||
emptyQuery* = "include:nativeretweets"
|
||||
|
||||
template `@`(param: string): untyped =
|
||||
if param in pms: pms[param]
|
||||
else: ""
|
||||
|
|
Loading…
Reference in a new issue