From e3c260a92203c6b10d57d8af0be3df932dda60f6 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Tue, 12 Aug 2014 14:10:07 +0200 Subject: *README.md (installation), +Makefile, %rename script file --- Makefile | 33 +++++++++++++++++++++++++++ README.md | 7 ++++++ bin/mp3dir2html | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/mp3dirlist | 70 --------------------------------------------------------- 4 files changed, 110 insertions(+), 70 deletions(-) create mode 100644 Makefile create mode 100755 bin/mp3dir2html delete mode 100755 bin/mp3dirlist diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..67d4bd1 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +VERSION = 3.81 + +install: all + +all: bin man + +bin: + @cp -v bin/mp3dir2html /usr/local/bin + +man: gzip-exists + @cp -v man1/mp3dir2html.1 /usr/local/share/man/man1 + @gzip -vf /usr/local/share/man/man1/mp3dir2html.1 + +gzip-exists: + @command -v gzip > /dev/null + +uninstall: + @rm -v /usr/local/share/man/man1/mp3dir2html.1.gz /usr/local/bin/mp3dir2html + +.PHONY: help + +help: + @echo + @echo "Syntax : MAKE [target]" + @echo + @echo "Targets : help\t\t- Displays this help." + @echo " all\t\t- Installs script and compressed manpage." + @echo " bin\t\t- Installs only the script." + @echo " man\t\t- Only installs the compressed manpage." + @echo " uninstall\t- Deletes all files from your system." + @echo + @echo "Make sure you have all necessary privileges before doing something :)" + @echo diff --git a/README.md b/README.md index 12aaa4d..a9a7439 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,10 @@ The auxiliaries: * [Bash](http://www.gnu.org/software/bash/) (Bourne Again Shell) * [GNU coreutils](http://www.gnu.org/software/coreutils/), [sed](http://www.gnu.org/software/sed/) and [(g)awk](http://www.gnu.org/software/gawk/) -- most likely already installed on your system + +Installation +------------ + +Just type "make help". + +The alternative: Copy bin/mp3dir2html to a PATH directory of your choice, and copy man/mp3dir2html to a system manpage directory of your choice (with or without compression, whatever preferred). diff --git a/bin/mp3dir2html b/bin/mp3dir2html new file mode 100755 index 0000000..fcb5494 --- /dev/null +++ b/bin/mp3dir2html @@ -0,0 +1,70 @@ +#!/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. + +function m3l_help { + echo "Usage: $(basename $0) [options]";echo + echo "Options:" + echo -e " -h\t\tPrint this help text and exit" + echo -e " -d DIRECTORY\tSpecify a directory to be scanned" + echo -e " \t\tWithout supplying DIRECTORY, the current directory will be used." +} +while getopts "ht:r:p:v" params; do + case $params in + "h") + m3l_help + exit 0 + ;; + "d") + SDIR="$OPTARG" + ;; + esac +done + +if [ "$SDIR" == "" ]; then + SDIR="*" +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.) + # Additionally: ampersand handling + sed 's/========.*/====/g' | sed 's/\t$/\t" "/g' | tr '\n' '\t' |\ + sed 's/====/\n====/g;s/====\t/====/g' |\ + sed 's/Artist\t//;s/Title\t//;s/Album\t//;s/\(.*\)Year\t/\1/;s/\(.*\)Track\t/\1/' |\ + uniq | sed 's/====//g;s/\ &\ /\ \&\;\ /g' | tr -s '\n' |\ + sed 's/\t0\t/\t"0"\t/g' +} + +function m3l_fin_table { + #Sort stuff, grep away lame artists and finally: put everything in order and remove the quotation marks + # from the entries again (leaving a whitespace char on an empty entry actually). + 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' +} + +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 |\ + m3l_fin_table > content.csv + +cat "$DIRLISTHEAD" > content.php +sed 's/^//g;s/\t/<\/td>/g;s/$/<\/td><\/tr>/g' content.csv >> content.php +rm content.csv +echo -e '\n\n\n\n\n\n' >> content.php + +echo diff --git a/bin/mp3dirlist b/bin/mp3dirlist deleted file mode 100755 index fcb5494..0000000 --- a/bin/mp3dirlist +++ /dev/null @@ -1,70 +0,0 @@ -#!/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. - -function m3l_help { - echo "Usage: $(basename $0) [options]";echo - echo "Options:" - echo -e " -h\t\tPrint this help text and exit" - echo -e " -d DIRECTORY\tSpecify a directory to be scanned" - echo -e " \t\tWithout supplying DIRECTORY, the current directory will be used." -} -while getopts "ht:r:p:v" params; do - case $params in - "h") - m3l_help - exit 0 - ;; - "d") - SDIR="$OPTARG" - ;; - esac -done - -if [ "$SDIR" == "" ]; then - SDIR="*" -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.) - # Additionally: ampersand handling - sed 's/========.*/====/g' | sed 's/\t$/\t" "/g' | tr '\n' '\t' |\ - sed 's/====/\n====/g;s/====\t/====/g' |\ - sed 's/Artist\t//;s/Title\t//;s/Album\t//;s/\(.*\)Year\t/\1/;s/\(.*\)Track\t/\1/' |\ - uniq | sed 's/====//g;s/\ &\ /\ \&\;\ /g' | tr -s '\n' |\ - sed 's/\t0\t/\t"0"\t/g' -} - -function m3l_fin_table { - #Sort stuff, grep away lame artists and finally: put everything in order and remove the quotation marks - # from the entries again (leaving a whitespace char on an empty entry actually). - 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' -} - -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 |\ - m3l_fin_table > content.csv - -cat "$DIRLISTHEAD" > content.php -sed 's/^//g;s/\t/<\/td>/g;s/$/<\/td><\/tr>/g' content.csv >> content.php -rm content.csv -echo -e '\n\n\n\n\n\n' >> content.php - -echo -- cgit v1.2.3