]> njoseph.me Git - nimcoon.git/blob - README.md
README: Add section on Motivation
[nimcoon.git] / README.md
1 # NimCoon
2
3 Play videos from YouTube and PeerTube from the
4 command line using your preferred desktop media player.
5
6 NewPipe app for Android offers similar features.
7
8 This application is implemented in [Nim language](https://nim-lang.org) using
9 only the standard library.
10
11 ![nimcoon screenshot with search term 'baby yoda'](screenshot.png)
12
13 ## Motivation
14
15 ### No similar existing tool
16
17 I tried all kinds of alternative YouTube players for the desktop. Most are either electron apps or slow web proxies. There was one cool bash script that did most of what I wanted called `ytview` but it had no way of copying the URL. I added this feature to the bash script but was still unsatisfied. There were CLI players written in Python but are usually a pain to install. They depend on a hard-coded YouTube API token and suffer from rate-limiting. I use youtube-dl with mpv usually (mostly because I like MPV over the YouTube JavaScript player). These tools have hundreds of options and I can't remember them. I needed a wrapper for them that does what I want, is easy to install(portable) and has a simple interface. I am not a big fan of Golang and its fat binaries. I discovered Nim around the same time I had this problem and decided to write this tool using just the standard library.
18
19 ### Digital Minimalism
20
21 YouTube's business incentive is to make you watch as many videos as possible. If you open the YouTube website and are logged into it, you will just get distracted by recommendations and forget why you opened it in the first place. You might have wanted to watch a conference talk but end up going down a rabbit hole of other "interesting" videos customized for you.
22
23 NimCoon has a spartan design. It doesn't even show images of the search results. I have had better success with managing my YouTube consumption after shifting to this tool. Pinafore's wellness settings are an inspiration for this.
24
25 ### Why no issues or merge requests?
26
27 I made this just for myself. The development is completely based on my needs and wants. I am not going to put a lot of work into this project. But feel free to use it if it works for you.
28
29 ## Features
30
31 - [x] Search for videos using keywords
32 - [x] Stream videos and music from YouTube
33 - [x] Play direct links from YouTube and PeerTube
34 - [x] Stream video and music from magnet links and hyperlinks to torrent files
35 - [x] Download music
36 - [x] Download video
37 - [x] Play YouTube playlists (MPV only)
38 - [ ] Download YouTube playlists
39 - [x] Stream video from torrent file URLs
40 - [x] BitTorrent is preferred for PeerTube video links
41 - [ ] Search PeerTube (3.0 or later)
42 - [ ] YouTube Autoplay (music only)
43 - [ ] Configuration options
44
45 | | YouTube | PeerTube (HTTP) | PeerTube (WebTorrent) |
46 | -------- | -------- | -------- | -------- |
47 | Music Streaming | ✅ | ✅ | ✅ |
48 | Video Streaming | ✅ | ✅ | ✅ |
49 | Music Download | ✅ | ✅ | |
50 | Video Download | ✅ | ✅ | |
51 | Stream Music from URL | ✅ | ✅ | |
52 | Stream Video from URL | ✅ | ✅ | ✅ |
53 | Download Music from URL | ✅ | ✅ | |
54 | Download Video from URL | ✅ | ✅ | |
55 | Stream Music Playlist | ✅ | | |
56 | Stream Video Playlist | ✅ | | |
57 | Download Music Playlist | | | |
58 | Download Video Playlist | | | |
59
60 ## Installation
61
62 Nim Coon depends on the following:
63 - youtube-dl
64 - mpv (recommended) or vlc
65 - peerflix and webtorrent (for magnet links)
66
67 Install MPV or VLC using your distribution's package manager.
68
69 Install YouTube-dl
70 ``` sh
71 pip3 install --user youtube-dl
72 ```
73
74 Install PeerFlix and WebTorrent
75 ```sh
76 npm install --global peerflix webtorrent-cli
77 ```
78
79 (Optional) If you want your YouTube downloads to be faster, install `aria2` download manager.
80
81 ### Installing using Nimble
82
83 NimCoon can be installed from Nimble repositories:
84
85 ``` sh
86 nimble install nimcoon
87 ```
88
89 You can also install from source by running the following command:
90
91 ```sh
92 nimble install
93 ```
94
95 ### Installing binary
96
97 Download the latest build from GitlabCI (amd64 GNU/Linux only).
98
99 ```sh
100 wget https://gitlab.com/njoseph/nimcoon/-/jobs/artifacts/master/download?job=compile -O artifacts.zip
101 unzip artifacts.zip
102 ```
103
104 Copy the binary to somewhere on your path like /usr/local/bin
105
106 ## Usage
107
108 ```sh
109 nimcoon "emacs"
110
111 # If your search query has multiple words, use quotes
112 nimcoon "nim lang"
113
114 # Play audio of the first search result
115 nimcoon -m -l "counting stars"
116
117 # Download audio of the first search result
118 nimcoon -mld "counting stars"
119
120 # Play direct video link
121 nimcoon https://www.youtube.com/watch?v=QOEMv0S8AcA
122
123 # Add -d to download or -m to select only audio or both
124 nimcoon -md https://www.youtube.com/watch?v=hT_nvWreIhg
125 ```
126
127 After the search results are displayed, you can enter a number to play one
128 result, "all" to play all the results or "q" to quit the program.
129
130 If a number is entered, after the selected search result is played, the results
131 are redisplayed, so that you can play the other results without having to search
132 again.
133
134 ### Command line arguments
135
136 | **Arguments** | **Explanation** |
137 |-------------------|--------------------------------------------|
138 | -m, --music | Play Music only, no video |
139 | -l, --lucky | Try your luck with the first search result |
140 | -f, --full-screen | Play video in full screen |
141 | -d, --download | Download video or music |
142
143 Feel free to use these options in any combination. NimCoon will show a helpful
144 error message if you pick incompatible options.
145
146 ## Development
147
148 One-liner for compiling and running
149
150 ```sh
151 nim c -d:ssl -r src/nimcoon.nim 'nim lang'
152 ```
153
154 ## Privacy
155
156 To avoid storing your nimcoon searches in `zsh` history, run this command
157
158 ```sh
159 setopt histignorespace
160 ```
161
162 Then, add a space before typing nimcoon in the shell, like " nimcoon"
163
164 ```sh
165 nimcoon "this is private"
166 ```
167
168 The same can be achieved in `bash` by setting an environment variable
169 ```sh
170 export HISTCONTROL=ignoreboth
171 ```
172