summaryrefslogtreecommitdiff
path: root/bin/common/ytlink
blob: a5e9bf0d049b77ccbd304c3079dc1398a3f0af5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

# convert to youtube.com/path url
# works for:
# - 'youtu.be/watch?v=xxxxxx'
# - 'https://piped.video/watch?v=xxxxx'

inp="$1"
[ "${inp:=$(clipo)}" ] || inp="$(cat /dev/stdin)"

# remove util scheme
inp="${inp#*//}"
inp="https://youtube.com/${inp#*/}"
printf "%s" "$inp"