More elegant handling of playing URLs directly

Signed-off-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <[email protected]>
parent a2f24b3b
Pipeline #108673727 passed with stages
in 1 minute and 40 seconds
......@@ -56,7 +56,8 @@ func sanitizeURL*(url: string): string =
urlLongen(stripZshEscaping(url))
proc directPlay*(searchQuery: string, player: string) =
if "watch?" in searchQuery or "videos/watch" in searchQuery or "soundcloud.com" in searchQuery:
play(player, args=[sanitizeURL(searchQuery)])
elif searchQuery.startswith("magnet:"):
play("peerflix", args=[searchQuery, &"--{player}"])
let url = sanitizeURL(searchQuery)
if searchQuery.startswith("magnet:"):
play("peerflix", args=[url, &"--{player}"])
else:
play(player, args=[url])
......@@ -5,7 +5,6 @@ import lib
suite "Playing direct links":
test "sanitize URL":
# give up and stop if this fails
let expected = "https://www.youtube.com/watch?v=QOEMv0S8AcA"
check(sanitizeURL("https://youtu.be/QOEMv0S8AcA") == expected)
check(sanitizeURL("https://www.youtube.com/watch\\?v\\=QOEMv0S8AcA") == expected)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment