Ffmpeg: Add checks for ffmpeg_music_meta.
This commit is contained in:
parent
c65a5ae8c6
commit
ecefedf7cd
|
@ -65,16 +65,38 @@ function ffmpeg_music_meta() {
|
|||
year="${year%%_*}"
|
||||
# local total=$(ls *.${format} | wc -l)
|
||||
|
||||
# Check.
|
||||
if [[ ${album} == "" ]]; then
|
||||
_error "Failed to get the album name!"
|
||||
return 1
|
||||
fi
|
||||
if [[ ${artist} == "" ]]; then
|
||||
_error "Failed to get the artist name!"
|
||||
return 1
|
||||
fi
|
||||
if [[ ${year} == "" ]]; then
|
||||
_error "Failed to get the year!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir out
|
||||
|
||||
for file in *.${format}; do
|
||||
local track="${file%%_*}"
|
||||
track=$((10#${track}))
|
||||
[[ ${track} == "" ]] && track=0
|
||||
local title="${file#*_}"
|
||||
title="${title%.*}"
|
||||
title="${title//_/ }"
|
||||
|
||||
if [[ ${track} == "" ]]; then
|
||||
_error "Failed to get the track number!"
|
||||
return 1
|
||||
fi
|
||||
if [[ ${title} == "" ]]; then
|
||||
_error "Failed to get the title name!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# echo "${artist}; ${album}; ${year}; ${track}; ${title}"
|
||||
# TODO: make it format-specific.
|
||||
ffmpeg -i "${file}" -map 0 -c copy -metadata "artists=" -metadata "artist=${artist}" -metadata "album_artist=${artist}" -metadata "album=${album}" -metadata "date=${year}" -metadata "year=${year}" -metadata "date_released=${year}" -metadata "track=${track}" -metadata "part_number=${track}" -metadata "title=${title}" ./out/"${file}" || return 1
|
||||
|
|
Loading…
Reference in a new issue