- if searchQuery.startswith("https:") or searchQuery.startswith("magnet:"):
- directPlay(searchQuery, player)
- quit(0)
-
- let searchResults = extractTitlesAndUrls(getYoutubePage(searchQuery))
-
- proc getUserInput(): string =
- if options["feelingLucky"]: "0"
- else:
- presentVideoOptions(searchResults[..(limit-1)])
- stdout.styledWrite(fgYellow, "Choose video number: ")
- readLine(stdin)
-
- # This is a pure function with no side effects
- func buildPlayerArgs(number: int): seq[string] =
- var args = @[searchResults[number].url]
- if options["musicOnly"]: args.add("--no-video")
- if options["fullScreen"]: args.add("--fullscreen")
- return args
-
- func buildMusicDownloadArgs(number: int): seq[string] =
- {.noSideEffect.}:
- var args = @["--ignore-errors", "-f", "bestaudio", "--extract-audio", "--audio-format", "mp3", "--audio-quality", "0", "-o"]
- let downloadLocation = &"'{expandTilde(musicDownloadDirectory)}/{searchResults[number].title}.mp3'"
- args.add(downloadLocation)
- args.add(searchResults[number].url)
- return args
-
- proc handleUserInput(number: int) =