X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/blobdiff_plain/fe1a5856767d3a6873963b4f66f48296f0aac26b..d807245d4d9041d9098ea7bb273debfb0224d0ff:/lib.nim diff --git a/lib.nim b/lib.nim index fc00385..acc4fc1 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 "" @@ -44,7 +45,6 @@ proc presentVideoOptions*(searchResults: seq[SearchResult]) = proc play*(player: string, args: openArray[string]) = # poEchoCmd can be added to options for debugging discard execProcess(player, args=args, options={poStdErrToStdOut, poUsePath}) - quit(0) func urlLongen(url: string): string = url.replace("youtu.be/", "www.youtube.com/watch?v=")