-func urlLongen(url: string): string = url.replace("youtu.be/", "www.youtube.com/watch?v=")
-
-
-func rewriteInvidiousToYouTube*(url: string): string =
- {.noSideEffect.}:
- if rewriteInvidiousURLs and url.replace(".", "").contains("invidious"):
- &"https://www.youtube.com/watch?v={url.split(\"=\")[1]}"
- else: url
-
-
-func stripZshEscaping(url: string): string = url.replace("\\", "")
-
-
-func sanitizeURL*(url: string): string =
- rewriteInvidiousToYouTube(urlLongen(stripZshEscaping(url)))
-
-
-proc directPlay*(url: string, player: string, options: Table[string, bool]) =
- let url =
- if find(url, PEERTUBE_REGEX) != -1 and isInstalled("webtorrent"):
- getPeerTubeMagnetLink(url)
- 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")
- else:
- # WebTorrent is so much faster!
- discard execProcess("webtorrent", args=[url, &"--{player}"], options=processOptions)
- else:
- play(player, options, url)
-
-
-proc directDownload*(url: string, musicOnly: bool) =
- let args =
- if musicOnly: buildMusicDownloadArgs(url)
- else: buildVideoDownloadArgs(url)
- if isInstalled("aria2c"):