diff --git a/README.md b/README.md index 1285666..6373c5c 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,6 @@ means that you can create different instruction files and either copy them to * Check for album artist when artist is not present or empty * Add loop back in and utilize relay mechanism to change instruction file -* Double-check time calculations, particularly for songs > 60m * Switch between loop mode and single-run mode * Add in what to do when all genres run through in logrotate timeperiod * Lighterweight way to handle log rotation, since I'm calling it frequently? diff --git a/mpdq b/mpdq index a04de44..7dbb3f7 100755 --- a/mpdq +++ b/mpdq @@ -274,18 +274,29 @@ function choose_next_song { #check selected song length length="" # The funky formatting is so that if a full path is specified, it'll still match. -#TODO: Double check time matching; the logic may be letting songs > 1hr play. case ${MUSICINFO} in *exiftool) length=$(${MUSICINFO} "${SongFile}" 2>/dev/null | ${grep_bin} "Duration" | awk -F ':' '{sum += 60*60*$1} {sum += 60*$2 } {sum += $3} END {print sum}' ) album=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "Album" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') - artist=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "Artist" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ "${album}" == "" ];then + album=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "Title" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + fi + artist=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "Album Artist" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ "${artist}" == "" ];then + artist=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "Artist" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + fi ;; *ffprobe) # Why the & at the end is needed for ffprobe ONLY is beyond me... length=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "Duration" | awk -F ':' '{sum += 60*60*$1} {sum += 60*$2 } {sum += $3} END {print sum}' & ) album=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "album" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') - artist=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "artist" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ "${album}" == "" ];then + album=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "title" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + fi + artist=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "album_artist" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ "${artist}" == "" ];then + artist=$(${MUSICINFO} "${SongFile}" 2>&1 | ${grep_bin} "artist" | head -1 | cut -d : -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + fi ;; esac if [ -z $length ];then