Nim Coon depends on the following:
- yt-dlp
- mpv (recommended) or vlc
-- peerflix and webtorrent (for magnet links)
+- webtorrent (for magnet links)
Install MPV or VLC using your distribution's package manager.
pip3 install --user yt-dlp
```
-Install PeerFlix and WebTorrent
+Install WebTorrent
```sh
-npm install --global peerflix webtorrent-cli
+npm install --global webtorrent-cli
```
(Optional) If you want your YouTube downloads to be faster, install `aria2` download manager.
proc directPlay*(url: string, player: string, options: Table[string, bool]) =
let url =
if find(url, PEERTUBE_REGEX) != -1 and "webtorrent".isInstalled:
- getPeerTubeMagnetLink(url)
+ getPeerTubeMagnetLink(url, options["musicOnly"])
else: url
if url.startswith("magnet:") or url.endswith(".torrent"):
if options["musicOnly"]:
- # TODO Replace with WebTorrent once it supports media player options
- discard execShellCmd(&"peerflix '{url}' -a --{player} -- --no-video")
+ discard execShellCmd(&"webtorrent '{url}' --{player} --player-args='--no-video'")
else:
- # WebTorrent is so much faster!
discard execProcess("webtorrent", args=[url, &"--{player}"], options=processOptions)
else:
play(player, options, url)
let PEERTUBE_REGEX = re"w\/[0-9a-zA-z]{22}"
-proc getPeerTubeMagnetLink*(url: string): string =
+proc getPeerTubeMagnetLink*(url: string, musicOnly: bool): string =
## Gets the magnet link of the best possible resolution from PeerTube
let uuid = url.substr(find(url, PEERTUBE_REGEX) + "w/".len)
let domainName = url.substr(8, find(url, '/', start=8) - 1)
let client = newHttpClient()
let response = get(client, apiURL)
let jsonNode = parseJson($response.body)
- jsonNode["files"][0]["magnetUri"].getStr()
+ var files = jsonNode["files"]
+ if len(jsonNode["files"]) == 0:
+ files = jsonNode["streamingPlaylists"][0]["files"]
+ if musicOnly:
+ files[len(files)-1]["magnetUri"].getStr()
+ else:
+ files[0]["magnetUri"].getStr()