Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
- [x] Search for videos using keywords
- [x] Stream videos
- [x] Search for videos using keywords
- [x] Stream videos
- [ ] Download videos
- [ ] Configuration options
- [ ] Choice of video players
- [ ] Download videos
- [ ] Configuration options
- [ ] Choice of video players
+### Commandline arguments
+
+|----------------|---------------------------|
+| ***Arguments** | **Explanation** |
+|----------------|---------------------------|
+| -m, --music | Play Music only, no video |
+|----------------|---------------------------|
+
## Development
One-liner for compiling and running
## Development
One-liner for compiling and running
import htmlparser
import httpClient
import htmlparser
import httpClient
import osproc
import sequtils, sugar
import strformat
import osproc
import sequtils, sugar
import strformat
for index, (title, url) in searchResults:
styledEcho $index, ". ", styleBright, fgMagenta, title, "\n", resetStyle, fgCyan, url, "\n"
for index, (title, url) in searchResults:
styledEcho $index, ". ", styleBright, fgMagenta, title, "\n", resetStyle, fgCyan, url, "\n"
let player = selectMediaPlayer()
let player = selectMediaPlayer()
-if "https://www.youtube.com" in input:
- discard execProcess(&"{player} {input}")
+var searchQuery = ""
+var musicOnly = false
+
+for kind, key, value in getopt():
+ case kind
+ of cmdArgument:
+ searchQuery = key
+ of cmdShortOption, cmdLongOption:
+ case key
+ of "m", "music": musicOnly = true
+ of cmdEnd:
+ discard
+
+let noVideo = if musicOnly: "--no-video" else: ""
+
+if "https://www.youtube.com" in searchQuery:
+ discard execProcess(&"{player} {searchQuery}")
-let searchResults = extractTitlesAndUrls(getYoutubePage(input))
+
+let searchResults = extractTitlesAndUrls(getYoutubePage(searchQuery))
presentVideoOptions(searchResults)
presentVideoOptions(searchResults)
styledEcho "\n", fgGreen, "Playing ", styleBright, fgMagenta, searchResults[number].title
# Play the video using the preferred/available media player
styledEcho "\n", fgGreen, "Playing ", styleBright, fgMagenta, searchResults[number].title
# Play the video using the preferred/available media player
-discard execProcess(&"{player} {searchResults[number].url}")
+discard execProcess(&"{player} {noVideo} {searchResults[number].url}")