- styledEcho $index, ". ", styleBright, fgMagenta, title, "\n", resetStyle, fgCyan, url, "\n"
+ styledEcho $index, ". ", styleBright, fgMagenta, title, "\n", resetStyle, fgCyan, " ", url, "\n"
+
+
+func isPlaylist(url: string): bool =
+ ##[ Identifies if video is part of a playlist.
+ Only YouTube playlists are supported for now. ]##
+ "www.youtube.com" in url and "&list=" in url
+
+
+func buildPlayerArgs(url: string, options: Table[string, bool], player: string): seq[string] =
+ let url =
+ # Playlists are only supported by MPV player. VLC needs a plugin.
+ if isPlaylist(url) and player == "mpv":
+ "https://www.youtube.com/playlist?" & url.split('&')[1]
+ else: url
+ let musicOnly = if options["musicOnly"]: "--no-video" else: ""
+ let fullScreen = if options["fullScreen"]: "--fullscreen" else: ""
+ filterIt([url, musicOnly, fullScreen], it != "")
+