]> njoseph.me Git - nimcoon.git/blame_incremental - README.md
Add interactive arguments to override global ones
[nimcoon.git] / README.md
... / ...
CommitLineData
1# NimCoon
2
3Play videos from YouTube and PeerTube from the command line using your preferred desktop media player.
4
5Similar apps for other platforms:
6
7- [NewPipe](https://newpipe.schabi.org) is a light-weight YouTube frontend for Android
8- [FreeTube](https://freetubeapp.io) is a GUI client for desktop platforms (uses electron)
9
10This is a minimal application implemented in [Nim language](https://nim-lang.org) using only the standard library.
11
12![nimcoon screenshot with search term 'baby yoda'](screenshot.png)
13
14## Logo
15
16A Maine Coon cat wearing a golden crown.
17Logo contributions/suggestions welcome.
18
19Maybe I would've just called this project Maine Coon had I written it in Python, but I wanted to use this opportunity to make Nim popular.
20
21## Motivation
22
23### No similar existing tool
24
25I 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.
26
27### Digital Minimalism
28
29YouTube'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.
30
31NimCoon has a spartan design. It doesn't even show images of the search results. It doesn't let you browse YouTube. You have to explicitly search for something.
32
33I have had better success with managing my YouTube consumption after shifting to this tool. Settings inspired by Pinafore's wellness settings.
34
35### Why no issues or merge requests?
36
37I 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.
38
39## Features
40
41- [x] Search for videos using keywords
42- [x] Stream videos and music from YouTube
43- [x] Play direct links from YouTube and PeerTube
44- [x] Stream video and music from magnet links and hyperlinks to torrent files
45- [x] Download music
46- [x] Download video
47- [x] Play YouTube playlists (MPV only)
48- [ ] Download YouTube playlists
49- [x] Stream video from torrent file URLs
50- [x] BitTorrent is preferred for PeerTube video links
51- [ ] Search PeerTube (3.0 or later)
52- [ ] YouTube Autoplay (music only)
53- [ ] Configuration options
54
55| | YouTube | PeerTube (HTTP) | PeerTube (WebTorrent) |
56| -------- | -------- | -------- | -------- |
57| Music Streaming | ✅ | ✅ | ✅ |
58| Video Streaming | ✅ | ✅ | ✅ |
59| Music Download | ✅ | ✅ | |
60| Video Download | ✅ | ✅ | |
61| Stream Music from URL | ✅ | ✅ | |
62| Stream Video from URL | ✅ | ✅ | ✅ |
63| Download Music from URL | ✅ | ✅ | |
64| Download Video from URL | ✅ | ✅ | |
65| Stream Music Playlist | ✅ | | |
66| Stream Video Playlist | ✅ | | |
67| Download Music Playlist | | | |
68| Download Video Playlist | | | |
69
70## Installation
71
72Nim Coon depends on the following:
73- youtube-dl
74- mpv (recommended) or vlc
75- peerflix and webtorrent (for magnet links)
76
77Install MPV or VLC using your distribution's package manager.
78
79Install YouTube-dl
80``` sh
81pip3 install --user youtube-dl
82```
83
84Install PeerFlix and WebTorrent
85```sh
86npm install --global peerflix webtorrent-cli
87```
88
89(Optional) If you want your YouTube downloads to be faster, install `aria2` download manager.
90
91### Installing using Nimble
92
93NimCoon can be installed from Nimble repositories:
94
95``` sh
96nimble install nimcoon
97```
98
99You can also install from source by running the following command:
100
101```sh
102nimble install
103```
104
105### Installing binary
106
107Download the latest build from GitlabCI (amd64 GNU/Linux only).
108
109```sh
110wget https://gitlab.com/njoseph/nimcoon/-/jobs/artifacts/master/download?job=compile -O artifacts.zip
111unzip artifacts.zip
112```
113
114Copy the binary to somewhere on your path like /usr/local/bin
115
116## Usage
117
118```sh
119nimcoon "emacs"
120
121# If your search query has multiple words, use quotes
122nimcoon "nim lang"
123
124# Play audio of the first search result
125nimcoon -m -l "counting stars"
126
127# Download audio of the first search result
128nimcoon -mld "counting stars"
129
130# Play direct video link
131nimcoon https://www.youtube.com/watch?v=QOEMv0S8AcA
132
133# Add -d to download or -m to select only audio or both
134nimcoon -md https://www.youtube.com/watch?v=hT_nvWreIhg
135```
136
137After the search results are displayed, you can enter a number to play one
138result, "all" to play all the results or "q" to quit the program.
139
140If a number is entered, after the selected search result is played, the results
141are redisplayed, so that you can play the other results without having to search
142again.
143
144### Command line arguments
145
146NimCoon provides both interactive and non-interactive arguments with significant
147overlap. But some arguments might only be present in one mode.
148
149Non-interactive arguments are specified to the nimcoon program and apply
150globally to all search results in that session. These can be overriden on a
151case-by-case basis using the interactive arguments.
152
153| **Non-interactive Arguments** | **Explanation** |
154|-------------------------------|--------------------------------------------|
155| -m, --music | Play Music only, no video |
156| -l, --lucky | Try your luck with the first search result |
157| -f, --full-screen | Play video in full screen |
158| -d, --download | Download video or music |
159
160Feel free to use these options in any combination. NimCoon will show a helpful
161error message if you pick incompatible options.
162
163Interactive arguments are provided during selection of a search result. These
164options allow you to change your mind after performing the search. For example,
165you might have searched for a music video, watched it and want to download the
166music only. In this case, you can specify the search result followed by the
167options as single characters. i.e
168
169"1" plays the video
170"1 md" downloads the music of the video
171
172| **Interactive Arguments** | **Explanation** |
173|---------------------------|---------------------------|
174| -m, --music | Play Music only, no video |
175| -f, --full-screen | Play video in full screen |
176| -d, --download | Download video or music |
177
178## Development
179
180One-liner for compiling and running
181
182```sh
183nim c -d:ssl -r src/nimcoon.nim 'nim lang'
184```
185
186## Privacy
187
188To avoid storing your nimcoon searches in `zsh` history, run this command
189
190```sh
191setopt histignorespace
192```
193
194Then, add a space before typing nimcoon in the shell, like " nimcoon"
195
196```sh
197 nimcoon "this is private"
198```
199
200The same can be achieved in `bash` by setting an environment variable
201```sh
202export HISTCONTROL=ignoreboth
203```
204