Play selected video using media player

Signed-off-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <[email protected]>
parent c760b5d9
Pipeline #99312834 passed with stage
in 53 seconds
......@@ -44,11 +44,19 @@ proc extractTitlesAndUrls(htmlFile: string): seq[SearchResult] =
map(a => (a.attrs["title"], "https://www.youtube.com" & a.attrs["href"]))[..(limit-1)]
proc presentVideoOptions(searchResults: seq[SearchResult]) =
echo "\n"
echo ""
for index, (title, url) in searchResults:
echo index, ". ", title.bold.fgMagenta, "\n", url.fgCyan, "\n"
presentVideoOptions(
extractTitlesAndUrls(
getYoutubePage(
paramStr(1))))
let searchResults = extractTitlesAndUrls(getYoutubePage(paramStr(1)))
presentVideoOptions(searchResults)
stdout.write "Choose video number: "
var number: int = parseInt(readLine(stdin))
var player = selectMediaPlayer()
echo "\n", "Playing ", searchResults[number].title.bold.fgMagenta
# Play the video in the media player
discard execProcess(player & " " & searchResults[number].url)
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