Add option to play "all" the search results

Signed-off-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <[email protected]>
parent d807245d
Pipeline #118974230 passed with stages
in 1 minute and 56 seconds
......@@ -35,7 +35,7 @@ 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)]
map(a => (a.attrs["title"], "https://www.youtube.com" & a.attrs["href"]))
proc presentVideoOptions*(searchResults: seq[SearchResult]) =
echo ""
......
......@@ -3,6 +3,7 @@ import
std/[terminal],
strutils
import config
import lib
proc parseOptions(): CommandLineOptions =
......@@ -40,7 +41,7 @@ proc main() =
proc getUserInput(): string =
if feelingLucky: "0"
else:
presentVideoOptions(searchResults)
presentVideoOptions(searchResults[..(limit-1)])
stdout.styledWrite(fgYellow, "Choose video number: ")
readLine(stdin)
......@@ -53,6 +54,11 @@ proc main() =
while(true):
let userInput = getUserInput()
if userInput == "all":
for number in 0..(len(searchResults)):
play(player, buildArgs(number))
if userInput == "q":
break
......
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