37 lines
985 B
Bash
Executable File
37 lines
985 B
Bash
Executable File
#!/bin/sh
|
|
checkMetadata() {
|
|
ffprobe "$1" 2>&1 | grep -e artist -e title
|
|
while true; do
|
|
read -p "correct metadata? [Y] | [n]: " yn
|
|
case "$yn" in
|
|
[Yy]* ) return 0;;
|
|
[Nn]* ) return 1;;
|
|
* ) echo "Please answer yes or no.";;
|
|
esac
|
|
done
|
|
}
|
|
cd ~/Musik/2020
|
|
file_name=`youtube-dl "ytsearch:$1 lyrics" \
|
|
--extract-audio \
|
|
--output '%(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="/tmp/idntag$(xxd -u -l 16 -p /dev/urandom)"
|
|
mkdir "$temp_dir"
|
|
temp_file="$temp_dir/$file_name"
|
|
cp "$file_name" "$temp_file"
|
|
idntag "$temp_file" > /dev/null
|
|
temp_file=$(echo "$temp_dir"/*)
|
|
if checkMetadata "$temp_file"; then
|
|
cp "$temp_file" .
|
|
rm "$file_name"
|
|
elif ! checkMetadata "$file_name"; then
|
|
echo "enter it manually"
|
|
fi
|
|
rm -rf "$temp_dir"
|