Fixed Argument Parsing in youtube_resolve.sh
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
url=$(echo -ne "${*}" | grep -Pio -m1 'https://www.youtube.com/(watch\?[^&|]+|embed/[^?/,|]+)')
|
url=$(echo -ne "${*}" | grep -Pio -m1 'https://www.youtube.com/(watch\?[^&,|]+|embed/[^?/,|]+)')
|
||||||
|
if [[ -n "${url}" ]] ; then
|
||||||
title=$(wget -q -O- "${url}" | grep -Po "(?<=title>).*(?=</title)")
|
title=$(wget -q -O- "${url}" | grep -Po "(?<=title>).*(?=</title)")
|
||||||
title_parsed=$(cat <<eof | python3
|
title_parsed=$(cat <<eof | python3
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
import html
|
from html import unescape
|
||||||
import sys
|
|
||||||
url="${title}"
|
url="${title}"
|
||||||
print(html.unescape(unquote(url)))
|
print(unescape(unquote(url)))
|
||||||
eof
|
eof
|
||||||
)
|
)
|
||||||
|
echo "${url};\"${title_parsed}\""
|
||||||
|
|
||||||
echo "${*};\"${title_parsed}\""
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user