Prevent 403 errors from outdated videos

This commit is contained in:
Zed
2019-12-22 01:45:07 +01:00
parent 7ef3a4faba
commit be15f1b001
3 changed files with 13 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
import strutils, sequtils
import strutils, sequtils, asyncdispatch, httpclient
import ../utils, ../prefs
export utils, prefs
@@ -13,3 +13,9 @@ template refPath*(): untyped {.dirty.} =
proc getNames*(name: string): seq[string] =
name.strip(chars={'/'}).split(",").filterIt(it.len > 0)
proc safeFetch*(url: string): Future[string] {.async.} =
let client = newAsyncHttpClient()
try: result = await client.getContent(url)
except: discard
client.close()