better format
This commit is contained in:
58
md
58
md
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
checkMetadata() {
|
||||
ffprobe "$1" 2>&1 | grep -e artist -e title
|
||||
ffprobe "$1" 2>&1 | grep -ie artist -e title
|
||||
while true; do
|
||||
printf "correct metadata? [Y] | [n]: "
|
||||
read -r yn < /dev/tty
|
||||
@ -11,28 +11,40 @@ checkMetadata() {
|
||||
esac
|
||||
done
|
||||
}
|
||||
cd ~/Medien/Musik/2020 || exit
|
||||
download_dir="$(mktemp -d)"
|
||||
file_name="$(youtube-dl "ytsearch:$1 lyrics" \
|
||||
--extract-audio \
|
||||
--output "$download_dir/%(title)s.%(ext)s" \
|
||||
--metadata-from-title "%(artist)s - %(title)s" \
|
||||
--audio-quality 0 \
|
||||
--audio-format mp3 \
|
||||
--embed-thumbnail \
|
||||
--add-metadata \
|
||||
|awk '$1 == "[ffmpeg]" && $2 == "Destination:" {print substr($0, index($0,$3))}')"
|
||||
r128gain "$file_name" 2> /dev/null
|
||||
temp_dir="$(mktemp -d)"
|
||||
temp_file="$temp_dir/0.mp3"
|
||||
cp "$file_name" "$temp_file"
|
||||
idntag "$temp_file" > /dev/null
|
||||
temp_file=$(echo "$temp_dir"/*)
|
||||
if checkMetadata "$temp_file"; then
|
||||
mv "$temp_file" .
|
||||
elif checkMetadata "$file_name"; then
|
||||
mv "$file_name" .
|
||||
else
|
||||
echo "enter it manually"
|
||||
fi
|
||||
for song in "$@"; do
|
||||
file_name="$(youtube-dl "ytsearch:$song lyrics" \
|
||||
-f bestaudio/best \
|
||||
--output "$download_dir/%(title)s.%(ext)s" \
|
||||
--metadata-from-title "%(artist)s - %(title)s" \
|
||||
--add-metadata \
|
||||
|awk '$1 == "[download]" && $2 == "Destination:" {print substr($0, index($0,$3))}')"
|
||||
case "$(echo "$file_name" | awk -F . '{print $NF}')" in
|
||||
"webm")
|
||||
new_filename="${file_name%.*}".opus
|
||||
mkvextract tracks "$file_name" "0:$new_filename" > /dev/null
|
||||
file_name="$new_filename"
|
||||
;;
|
||||
"m4a")
|
||||
;;
|
||||
*)
|
||||
echo "unsupported file type"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
r128gain "$file_name" 2> /dev/null
|
||||
temp_file="$temp_dir/$(basename "$file_name")"
|
||||
cp "$file_name" "$temp_file"
|
||||
idntag "$temp_file"
|
||||
temp_file=$(echo "$temp_dir"/*)
|
||||
if checkMetadata "$temp_file"; then
|
||||
mv "$temp_file" .
|
||||
elif checkMetadata "$file_name"; then
|
||||
mv "$file_name" .
|
||||
else
|
||||
echo "enter it manually"
|
||||
fi
|
||||
done
|
||||
rm -rf "$temp_dir" "$download_dir"
|
||||
mpc update > /dev/null
|
||||
|
||||
Reference in New Issue
Block a user