diff --git a/music_tagmove_lib b/music_tagmove_lib index e120eee..cd09924 100644 --- a/music_tagmove_lib +++ b/music_tagmove_lib @@ -113,17 +113,32 @@ function read_tag_id3 { fi } +function ffprobe_readtag { + local tag="$1" + local file="$2" + ffprobe -loglevel error -show_entries format_tags="$tag" -of default=noprint_wrappers=1:nokey=1 "$file" +} + function read_tag_fallback { local tag="$1" local file="$2" + local tag_original="$tag" - local result=$(ffprobe -loglevel error -show_entries format_tags="$tag" -of default=noprint_wrappers=1:nokey=1 "$file") + local result= + if [[ "$tag" == 'date' ]]; then + result=$(ffprobe_readtag "$tag" "$file") + if [[ -z $result ]]; then + tag='year' + fi + + fi + result=$(ffprobe_readtag "$tag" "$file") if [[ $? -ne 0 ]]; then - error "Reading tag \"$tag\" from \"$file\" failed (ffprobe failed)" + error "Reading tag \"$tag_original\" from \"$file\" failed (ffprobe failed)" return fi if [[ -z $result ]]; then - error "Reading tag \"$tag\" from \"$file\" failed (result empty)" + error "Reading tag \"$tag_original\" from \"$file\" failed (result empty)" return fi echo "$result"