temp dir for downloaded file

This commit is contained in:
2021-07-09 14:57:26 +02:00
parent a77efb2f8b
commit 31aede8e95

25
md
View File

@ -10,27 +10,28 @@ checkMetadata() {
esac esac
done done
} }
cd ~/Musik/2020 cd ~/Medien/Musik/2020
file_name=`youtube-dl "ytsearch:$1 lyrics" \ download_dir="$(mktemp -d)"
file_name="$(youtube-dl "ytsearch:$1 lyrics" \
--extract-audio \ --extract-audio \
--output '%(title)s.%(ext)s' \ --output "$download_dir/%(title)s.%(ext)s" \
--metadata-from-title "%(artist)s - %(title)s" \ --metadata-from-title "%(artist)s - %(title)s" \
--audio-quality 0 \ --audio-quality 0 \
--audio-format mp3 \ --audio-format mp3 \
--embed-thumbnail \ --embed-thumbnail \
--add-metadata \ --add-metadata \
|awk '$1 == "[ffmpeg]" && $2 == "Destination:" {print substr($0, index($0,$3))}'` |awk '$1 == "[ffmpeg]" && $2 == "Destination:" {print substr($0, index($0,$3))}')"
r128gain "$file_name" 2> /dev/null r128gain "$file_name" 2> /dev/null
temp_dir="/tmp/idntag$(xxd -u -l 16 -p /dev/urandom)" temp_dir="$(mktemp -d)"
mkdir "$temp_dir" temp_file="$temp_dir/0.mp3"
temp_file="$temp_dir/$file_name"
cp "$file_name" "$temp_file" cp "$file_name" "$temp_file"
idntag "$temp_file" > /dev/null idntag "$temp_file"
temp_file=$(echo "$temp_dir"/*) temp_file=$(echo "$temp_dir"/*)
if checkMetadata "$temp_file"; then if checkMetadata "$temp_file"; then
cp "$temp_file" . mv "$temp_file" .
rm "$file_name" elif checkMetadata "$file_name"; then
elif ! checkMetadata "$file_name"; then mv "$file_name" .
else
echo "enter it manually" echo "enter it manually"
fi fi
rm -rf "$temp_dir" rm -rf "$temp_dir" "$download_dir"