#!/bin/bash # Paste a file here that contains the HTML code to be placed _before_ the MP3 tag list. DIRLISTHEAD="/etc/mp3dir2html/head.php" # Regular expression that is to be excluded in the final listing DIRLISTEX='^Susperia|^B.*hse.*nkelz' # CORE SCRIPT FROM HERE. DON'T FIDDLE IF YOU DON'T KNOW WHAT YOU'RE DOING. if [ "$1" == "" ]; then SDIR="*" else SDIR="$1 $2 $3 $4 $5 $6 $7 $8" fi function m3l_rm_verb { #As -q nukes away too much, we have to omit that and remove status stuff here: grep -v 'directories scanned' | grep -v 'files read' } function m3l_prep_table { #Let's create a tab separated table with empty values where we have none but need at least an empty one. # (Besides, this kind of rhymes.) sed 's/========.*/====/g' | sed 's/\t$/\t" "/g' | tr '\n' '\t' |\ sed 's/====/\n====/g;s/====\t/====/g' } exiftool -ext .mp3 -ext .MP3 -ext .wma -ext .WMA -ext .ogg -ext .OGG -lang en -Artist -Title -Album -Year -Track -t -r $SDIR |\ m3l_rm_verb |\ m3l_prep_table |\ sed 's/Artist\t//;s/Title\t//;s/Album\t//;s/\(.*\)Year\t/\1/;s/\(.*\)Track\t/\1/' |\ sed 's/\[ \t0-9\]*image files read//g' |\ uniq |\ sed 's/====//g' |\ sed 's/\ &\ /\ \&\;\ /g' |\ tr -s '\n' |\ sed 's/\t0\t/\t"0"\t/g' |\ # awk -F '\t' '{print $2"\t"$1"\t"$3"\t"$4"\t"$5}' | sort -s -t \t -k 1,2 |\ # awk -F '\t' '{print $3"\t"$1"\t"$2"\t"$4"\t"$5}' | sort -s -t \t -k 1,2 |\ # awk -F '\t' '{print $3"\t"$2"\t"$1"\t"$4"\t"$5}' | sort -s -t \t -k 1,2 |\ ### sort -s -t \t -k 3,3 | sort -s -t \t -k 2,2 | sort -s -t \t -k 4,4n | sort -s -t \t -k 1,1 |\ ### sort -s -t \t -k 4,4n | sort -u -s -t \t -k 3,3 -k 2,2 -k 4,4n | sort -s -t \t -k 1,1 |\ ### sort -u -s -t \t -k 1,1d -t \t -k 4,4n -t \t -k 2,2d |\ ### sort -u -t \t -k 1,1 -k 4,4 -k 3,3 -k 2,2 |\ # awk -F '\t' '{print $2"\t"$1"\t"$3"\t"$4"\t"$5}' | sort |\ # awk -F '\t' '{print $1"\t"$4"\t"$3"\t"$2"\t"$5}' | sort |\ ## sed 's/\(.*\)\/[0-9]\+/\1/' |\ ## sed 's/\(.*\)\t0/\t\1/' |\ ### sort -t \t -k 1,1 -k 2,2n -k 3,3 -k 4,4 |\ ## sort -t \t -k 1,1 -k 2,2n -k 3,3 -k 4,4 |\ ## sort -t \t -k 1,1 |\ sort -t \t -k 1,2 -k 2,3 -k 4,5 -k 3,4 |\ grep -vE "$DIRLISTEX"|\ awk -F '\t' '{print $1"\t"$2"\t"$3}' |\ sed 's/" "/ /g;s/"0"/0/g' > content.csv cat "$DIRLISTHEAD" > content.php sed 's/^/