Skip to content

Commit

Permalink
Also added in similar check for title if album name is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
uriel1998 committed Feb 3, 2024
1 parent dc5669a commit e6097d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
17 changes: 14 additions & 3 deletions mpdq
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e6097d9

Please sign in to comment.