blob: 215c1648eebd8e5bd99d678c4caf0c911d42c91e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/sh
# convert to youtube.com/path url
# works for:
# - 'youtu.be/xxxxxx'
# - 'https://piped.video/watch?v=xxxxx'
# - https://youtube.com/watch?v=xxxx
# get from $1 or clipboard if empty
vid="${1:-$(clipo)}"
# The following subsitutions will try to grab the video id
# if link is http://127.0.0.1:9010/https://www.youtube.com/watch?v=7KpxsqwNF0o
vid="${vid#*/https://}"
# remove util scheme
vid="${vid#*//}"
# remove domain
vid="${vid#*/}"
# remove query string
vid="${vid#watch?v=}"
printf "https://youtube.com/watch?v=%s\n" "$vid"
|