Refactor "withheld" parsing
This commit is contained in:
parent
2a40dd8059
commit
5e49e94bf1
|
@ -269,18 +269,18 @@ proc parseTweet(js: JsonNode): Tweet =
|
||||||
result.gif = some(parseGif(m))
|
result.gif = some(parseGif(m))
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
let withheldInCountries: seq[string] =
|
with jsWithheld, js{"withheld_in_countries"}:
|
||||||
if js{"withheld_in_countries"}.kind == JArray:
|
var withheldInCountries: seq[string]
|
||||||
js{"withheld_in_countries"}.to(seq[string])
|
|
||||||
else:
|
if jsWithheld.kind == JArray:
|
||||||
newSeq[string]()
|
withheldInCountries = jsWithheld.to(seq[string])
|
||||||
|
|
||||||
if js{"withheld_copyright"}.getBool or
|
|
||||||
# XX - Content is withheld in all countries
|
# XX - Content is withheld in all countries
|
||||||
"XX" in withheldInCountries or
|
|
||||||
# XY - Content is withheld due to a DMCA request.
|
# XY - Content is withheld due to a DMCA request.
|
||||||
|
if js{"withheld_copyright"}.getBool or
|
||||||
|
withheldInCountries.len > 0 and ("XX" in withheldInCountries or
|
||||||
"XY" in withheldInCountries or
|
"XY" in withheldInCountries or
|
||||||
(withheldInCountries.len > 0 and "withheld" in result.text):
|
"withheld" in result.text):
|
||||||
result.available = false
|
result.available = false
|
||||||
|
|
||||||
proc finalizeTweet(global: GlobalObjects; id: string): Tweet =
|
proc finalizeTweet(global: GlobalObjects; id: string): Tweet =
|
||||||
|
|
Loading…
Reference in New Issue