Skip to content

Commit

Permalink
[list-songfiles] Support user defined level 1 dirs under /mnt/
Browse files Browse the repository at this point in the history
  • Loading branch information
moodeaudio committed May 27, 2023
1 parent 837eaa1 commit a9713e6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions www/util/list-songfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,27 @@
# Option to scan for "Default" or "All" audio formats
# $_SESSION['library_thmgen_scan']
#
# NOTE: Adding image file formats to the REGEX allows the thumbnail generator to create thumbs for
# NOTE: Including image file formats in the REGEX allows the thumbnail generator to create thumbs for
# parent folders of the Album folder.
#

# Set the list of audio formats for the scan
if [ -z $1 ] || [ $1 = "Default" ]; then
TYPES_REGEX="\(aac\|aif\|aiff\|dff\|dsf\|flac\|m4a\|mp3\|mp4\|ogg\|wav\|wma\|jpg\|jpeg\|png\|tif\|tiff\)"
else
TYPES_REGEX="\(3g2\|3g2\|3gp\|4xm\|8svx\|aa3\|aac\|ac3\|adx\|afc\|aif\|aifc\|aiff\|al\|alaw\|amr\|anim\|apc\|ape\|asf\|atrac\|au\|aud\|avi\|avm2\|avs\|bap\|bfi\|c93\|cak\|cin\|cmv\|cpk\|daud\|dct\|dff\|divx\|dsf\|dts\|dv\|dvd\|dxa\|eac3\|film\|flac\|flc\|fli\|fll\|flx\|flv\|g726\|gsm\|gxf\|iss\|m1v\|m2v\|m2t\|m2ts\|m4a\|m4b\|m4v\|mad\|mj2\|mjpeg\|mjpg\|mka\|mkv\|mlp\|mm\|mmf\|mov\|mp+\|mp1\|mp2\|mp3\|mp4\|mpc\|mpeg\|mpg\|mpga\|mpp\|mpu\|mve\|mvi\|mxf\|nc\|nsv\|nut\|nuv\|oga\|ogm\|ogv\|ogx\|oma\|ogg\|omg\|opus\|pcm\|psp\|pva\|qcp\|qt\|r3d\|ra\|ram\|rl2\|rm\|rmvb\|roq\|rpl\|rvc\|shn\|smk\|snd\|sol\|son\|spx\|str\|swf\|tak\|tgi\|tgq\|tgv\|thp\|ts\|tsp\|tta\|xa\|xvid\|uv\|uv2\|vb\|vid\|vob\|voc\|vp6\|vmd\|wav\|webm\|wma\|wmv\|wsaud\|wsvga\|wv\|wve\|jpg\|jpeg\|png\|tif\|tiff\)"
fi

# Search pre-defined subdirectories under /mnt
find /mnt/NAS -depth -mindepth 1 -type f -iregex ".*\.${TYPES_REGEX}" -printf "file: "NAS/"%P\n"
find /mnt/SDCARD -depth -mindepth 1 -type f -iregex ".*\.${TYPES_REGEX}" -printf "file: "SDCARD/"%P\n"
# Scan /mnt
# Exclude moode-player which is only used in dev (same as in thumb-gen.php)
RESULT=$(ls /mnt/)
readarray -t DIRS <<<"$RESULT"
for i in "${!DIRS[@]}"; do
if [ "${DIRS[$i]}" != "moode-player" ]; then
find "/mnt/${DIRS[$i]}" -depth -mindepth 1 -type f -iregex ".*\.${TYPES_REGEX}" -printf "file: ""${DIRS[$i]}/""%P\n"
fi
done

# Search all subdirectories under /media
# Have to prepend "USB/" to results to match MPD's structure
find /media -depth -mindepth 1 -type f -iregex ".*\.${TYPES_REGEX}" -printf "file: "USB/"%P\n"
# Scan /media
# Prepend "USB/" to results to match MPD's structure
find /media/ -depth -mindepth 1 -type f -iregex ".*\.${TYPES_REGEX}" -printf "file: "USB/"%P\n"

0 comments on commit a9713e6

Please sign in to comment.