From: Joseph Nuthalapati Date: Sun, 12 Jan 2020 07:53:05 +0000 (+0530) Subject: Make extractTitlesAndUrls a func X-Git-Tag: 0.1.0~17 X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/commitdiff_plain/4a0587e23a6e38121143768b4f61b02bb54ce6ba?hp=fe1a5856767d3a6873963b4f66f48296f0aac26b Make extractTitlesAndUrls a func with some convincing of course! Signed-off-by: Joseph Nuthalapati --- diff --git a/lib.nim b/lib.nim index fc00385..de088b4 100644 --- a/lib.nim +++ b/lib.nim @@ -31,10 +31,11 @@ proc getYoutubePage*(searchQuery: string): string = let response = get(client, &"https://www.youtube.com/results?hl=en&search_query={queryParam}") return $response.body -proc extractTitlesAndUrls*(html: string): seq[SearchResult] = - parseHtml(html).findAll("a"). - filter(a => "watch" in a.attrs["href"] and a.attrs.hasKey "title"). - map(a => (a.attrs["title"], "https://www.youtube.com" & a.attrs["href"]))[..(limit-1)] +func extractTitlesAndUrls*(html: string): seq[SearchResult] = + {.noSideEffect.}: + parseHtml(html).findAll("a"). + filter(a => "watch" in a.attrs["href"] and a.attrs.hasKey "title"). + map(a => (a.attrs["title"], "https://www.youtube.com" & a.attrs["href"]))[..(limit-1)] proc presentVideoOptions*(searchResults: seq[SearchResult]) = echo ""