From: Joseph Nuthalapati Date: Fri, 27 Mar 2020 07:23:35 +0000 (+0530) Subject: Add option to download video X-Git-Tag: 0.1.0~4 X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/commitdiff_plain/d2ebe4d2197106ef89a103744c93dcca9e4b0e5f?ds=sidebyside Add option to download video Signed-off-by: Joseph Nuthalapati --- diff --git a/README.md b/README.md index d5d51b6..4b4bb32 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ only the standard library. - [x] Play direct links from YouTube and PeerTube - [x] Stream video from magnet links - [x] Download music -- [ ] Download video +- [x] Download video - [ ] Configuration options ## Installation diff --git a/TODO.org b/TODO.org index 6851e8e..5488630 100644 --- a/TODO.org +++ b/TODO.org @@ -1,14 +1,14 @@ -* Task list [6/11] +* Task list [7/11] - [X] Pretty colors in terminal - [X] Get rid of temp file or make one temp file per user - [X] Preferences should go into a config file - [X] Create a proper CLI - [X] PeerTube support (only direct download, because webtorrent seeds are too slow) - [X] Find a better name. clitube is an SEO disaster +- [X] Option to download audio/video - [ ] Spawn video player and quit immediately - [ ] SoundCloud support? Search and play music - [ ] LRU cache of content so that frequently-played content doesn't use BW -- [ ] Option to download audio/video - [ ] Better CLI using curses - select with arrows and press enter - - illwill library can be used - - see nim-mod project as an example + - illwill library can be used + - see nim-mod project as an example diff --git a/src/nimcoon.nim b/src/nimcoon.nim index 2db5ece..2ddafc9 100644 --- a/src/nimcoon.nim +++ b/src/nimcoon.nim @@ -76,10 +76,20 @@ proc main() = args.add(searchResults[number].url) return args + func buildVideoDownloadArgs(number: int): seq[string] = + {.noSideEffect.}: + var args = @["-f", "best", "-o"] + let downloadLocation = &"'{expandTilde(videoDownloadDirectory)}/%(title)s.%(ext)s'" + args.add(downloadLocation) + args.add(searchResults[number].url) + return args + proc handleUserInput(number: int) = if options["download"]: if options["musicOnly"]: download(buildMusicDownloadArgs(number), searchResults[number].title) + else: + download(buildVideoDownloadArgs(number), searchResults[number].title) else: play(player, buildPlayerArgs(number), searchResults[number].title)