Fixed Argument Parsing in youtube_resolve.sh

This commit is contained in:
tke
2019-10-30 12:38:01 +01:00
parent 207663f006
commit ff0d64284b

View File

@@ -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