Commit 38eb73d0 authored by Dave Morriss's avatar Dave Morriss

Added 'report_albumsku'

report_albumsku - script to report track details and text relating to an album
indexed by its 'sku' value in the XML catalogue
parse_album_tracks.xsl - XSLT file for the above
parent 7024a0c9
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Report selected data from the Magnatune catalogue as text.
Invoke as:
xsltproc - -stringparam code "xxx" parse_album_tracks.xsl ../Magnatune_Data/album_info_xml
-->
<xsl:strip-space elements="*"/>
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<!-- Define a default for the album code -->
<xsl:param name="code">abaroque-mozart</xsl:param>
<xsl:template match="/">
<xsl:for-each select="AllAlbums/Album">
<xsl:if test="albumsku = $code">
<xsl:value-of select="concat('Artist: ',artist,'&#xA;')"/>
<xsl:value-of select="concat('Album: ',albumname,'&#xA;')"/>
<xsl:value-of select="concat('Genres: ',magnatunegenres,'&#xA;')"/>
<xsl:value-of select="concat('Code: ',albumsku,'&#xA;')"/>
<xsl:value-of select="concat('URL: ','http://magnatune.com/artists/albums/',
albumsku,'&#xA;')"/>
<xsl:text>Tracks:&#xA;</xsl:text>
<xsl:for-each select="Track">
<xsl:value-of select="concat(' ',format-number(tracknum,'00'),
': ',trackname,'&#xA;')"/>
</xsl:for-each>
<xsl:value-of select="concat('Notes: ',album_notes,'&#xA;')"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
#!/bin/bash -
#===============================================================================
#
# FILE: report_albumsku
#
# USAGE: ./report_albumsku
#
# DESCRIPTION: Report album details from the Magnatune catalogue by album
# code (which Magnatune calls the 'sku')
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# LICENSE: Copyright (c) year 2012, Dave Morriss
# CREATED: 24/10/2012 21:15:54
# REVISION: 25/11/2012 17:30:41
#
#===============================================================================
set -o nounset # Treat unset variables as an error
SCRIPT=${0##*/}
#-------------------------------------------------------------------------------
# Directories:
# $BASEDIR--+
# +--Magnatune_Data Data files here
# +--Magnatune_Downloads Music downloads go here
# +--magnatune-downloader Scripts
# +--logs Download logs etc (unmanaged)
#-------------------------------------------------------------------------------
#
# Define the place where the scripts and data files are to be stored
#
BASEDIR="$HOME/MusicDownloads"
# Data files go here
DATADIR="$BASEDIR/Magnatune_Data"
# Scripts live here
SCRIPTDIR="$BASEDIR/magnatune-downloader"
#
# Files
#
XSLT="$SCRIPTDIR/parse_album_tracks.xsl"
ALBUMINFO="$DATADIR/album_info_xml"
SUMMARY="$DATADIR/all_albums"
#
# Sanity checks
#
[ -e $BASEDIR ] || { echo "$BASEDIR not found"; exit; }
[ -e $DATADIR ] || { echo "$DATADIR not found"; exit; }
[ -e $SCRIPTDIR ] || { echo "$SCRIPTDIR not found"; exit; }
[ -e $XSLT ] || { echo "$XSLT not found"; exit; }
[ -e $ALBUMINFO ] || { echo "$ALBUMINFO not found"; exit; }
[ -e $SUMMARY ] || { echo "$SUMMARY not found"; exit; }
#
# Check argument count
#
if [[ $# -ne 1 ]]; then
echo "Usage: $SCRIPT albumcode"
exit
fi
#
# Downcase argument and remove illegal characters
#
CODE="${1,,}"
CODE=${CODE/[^a-z0-9-]/}
#
# Check the summary file for the code
#
if [[ $(egrep "^Code: *$CODE$" $SUMMARY) ]]; then
xsltproc --stringparam code "$CODE" $XSLT $ALBUMINFO
else
echo "Unable to find album code '$CODE'"
fi
exit
# vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment