From c412b3d79180c2648ac6ea98bf55cf317a56efaf Mon Sep 17 00:00:00 2001 From: Zed Date: Sun, 6 Oct 2019 16:08:39 +0200 Subject: [PATCH] Use POST for guest token Fixes #56 --- src/api/media.nim | 7 ++++--- src/query.nim | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/media.nim b/src/api/media.nim index 351029b..86fd843 100644 --- a/src/api/media.nim +++ b/src/api/media.nim @@ -51,9 +51,10 @@ proc getGuestToken(agent: string; force=false): Future[string] {.async.} = tokenUpdated = getTime() tokenUses = 0 - let - headers = genHeaders({"authorization": auth}, agent, base, lang=false) - json = await fetchJson(apiBase / tokenUrl, headers) + let headers = genHeaders({"authorization": auth}, agent, base, lang=false) + newClient() + + let json = parseJson(await client.postContent($(apiBase / tokenUrl))) if json != nil: result = json["guest_token"].to(string) diff --git a/src/query.nim b/src/query.nim index ab2d8ec..1cbff3a 100644 --- a/src/query.nim +++ b/src/query.nim @@ -110,6 +110,7 @@ proc cleanPos*(pos: string): string = pos.multiReplace((posPrefix, ""), (posSuffix, "")) proc genPos*(pos: string): string = + if pos.len == 0: return result = posPrefix & pos if "A==" notin result: result &= posSuffix