From 72720bec46a37176476c4bb6bc0cb83c0488cbed Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Tue, 18 Feb 2020 21:15:57 +0530 Subject: [PATCH] Add option to play "all" the search results Signed-off-by: Joseph Nuthalapati --- lib.nim | 2 +- nimcoon.nim | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib.nim b/lib.nim index acc4fc1..893422e 100644 --- a/lib.nim +++ b/lib.nim @@ -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 "" diff --git a/nimcoon.nim b/nimcoon.nim index ae22576..ed3a572 100644 --- a/nimcoon.nim +++ b/nimcoon.nim @@ -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 -- 2.43.0