update
This commit is contained in:
parent
8e8382aa88
commit
d43ce1ee0e
1 changed files with 22 additions and 8 deletions
30
nicesong
30
nicesong
|
|
@ -1,6 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
query="$(playerctl -i firefox metadata --format '{{ artist }} - {{ title }}')"
|
query_artist="$(playerctl -i firefox metadata --format '{{ artist }}')"
|
||||||
|
query_title="$(playerctl -i firefox metadata --format '{{ title }}')"
|
||||||
|
query="$query_artist - $query_title"
|
||||||
|
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
|
||||||
echo "Searching YouTube for:"
|
echo "Searching YouTube for:"
|
||||||
echo " $query"
|
echo " $query"
|
||||||
|
|
@ -9,11 +13,8 @@ echo
|
||||||
yt-dlp "ytsearch1:$query" \
|
yt-dlp "ytsearch1:$query" \
|
||||||
--print "━━━━━━━━━━━━━━━━━━━━━━━" \
|
--print "━━━━━━━━━━━━━━━━━━━━━━━" \
|
||||||
--print "Title: %(title)s" \
|
--print "Title: %(title)s" \
|
||||||
--print "Artist: %(artist|Unknown)s" \
|
|
||||||
--print "Track: %(track|Unknown)s" \
|
|
||||||
--print "Channel: %(uploader)s" \
|
--print "Channel: %(uploader)s" \
|
||||||
--print "Duration: %(duration_string)s" \
|
--print "Duration: %(duration_string)s" \
|
||||||
--print "Views: %(view_count)s" \
|
|
||||||
--print "URL: %(webpage_url)s" \
|
--print "URL: %(webpage_url)s" \
|
||||||
--print "━━━━━━━━━━━━━━━━━━━━━━━"
|
--print "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
|
|
@ -21,9 +22,22 @@ echo
|
||||||
read -p "Download this? [y/N] " confirm
|
read -p "Download this? [y/N] " confirm
|
||||||
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||||
yt-dlp --embed-metadata -x --audio-format aac -f bestaudio \
|
yt-dlp -x --audio-format m4a -f bestaudio \
|
||||||
"ytsearch1:$query" \
|
"ytsearch1:$query" \
|
||||||
-o "~/Music/%(artist)s - %(title)s.%(ext)s"
|
--embed-metadata \
|
||||||
|
-o "$tmpdir/%(artist)s - %(albums)s - %(title)s.%(ext)s"
|
||||||
|
|
||||||
|
file="$(ls "$tmpdir"/* 2>/dev/null | head -n1)"
|
||||||
|
|
||||||
|
if [[ -n "$file" ]]; then
|
||||||
|
beet import --from-scratch -s "$file"
|
||||||
|
else
|
||||||
|
echo "Download failed. Even chaos has limits."
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$tmpdir"
|
||||||
else
|
else
|
||||||
echo "Aborted. You resisted entropy."
|
echo "Aborted."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
read -n 1 -s -r -p "Done. Press any key to close."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue