]> njoseph.me Git - nimcoon.git/blobdiff - lib.nim
Make extractTitlesAndUrls a func
[nimcoon.git] / lib.nim
diff --git a/lib.nim b/lib.nim
index fc00385307c1f5ac1e177a2a8a6f41a8e3410446..de088b403d679784de4b993e0a828af2917434bc 100644 (file)
--- 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 ""