summaryrefslogtreecommitdiff
path: root/bin/common/ytlink
blob: 48be9cfa3348bdba124cad9ee735db3669527b00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/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)"

# if link is http://127.0.0.1:9010/https://www.youtube.com/watch?v=7KpxsqwNF0o
inp="${inp#*/https://}"
# remove util scheme
inp="${inp#*//}"
inp="https://youtube.com/${inp#*/}"
printf "%s" "$inp"