Make extractTitlesAndUrls a func

with some convincing of course!
Signed-off-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <[email protected]>
parent fe1a5856
......@@ -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 ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment