Skip to content

Instantly share code, notes, and snippets.

@rornor

rornor/id.xsl Secret

Created December 28, 2012 23:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rornor/14775b660b7786977823 to your computer and use it in GitHub Desktop.
Save rornor/14775b660b7786977823 to your computer and use it in GitHub Desktop.
Get foobar2000 playback statistics ID hashes for tracks with play count greater then 0
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="param" as="xs:string" required="yes"/>
<xsl:param name="p" select="document($param)"/>
<!-- Note: delay parameter represeents time shift based on user location. For CET it turnes out as +2h. Change accordingly your timezone -->
<xsl:param name="delay" select="2 * 60 * 60"/>
<xsl:template match="/">
<Items>
<xsl:for-each select="PlaybackStatistics/Entry">
<xsl:variable name="dt" select="string(xs:dateTime('1601-01-01T00:00:00Z') + (@FirstPlayed idiv 10000000 + $delay) * xs:dayTimeDuration('PT1S'))"/>
<xsl:if test="$dt != ''">
<Item>
<xsl:attribute name="ID"><xsl:value-of select="string(@ID)"/></xsl:attribute>
<xsl:attribute name="Artist"><xsl:value-of select="$p/PlaybackStatistics/Item[FirstPlayed=$dt]/Artist"/></xsl:attribute>
<xsl:attribute name="Album"><xsl:value-of select="$p/PlaybackStatistics/Item[FirstPlayed=$dt]/Album"/></xsl:attribute>
<xsl:attribute name="Title"><xsl:value-of select="$p/PlaybackStatistics/Item[FirstPlayed=$dt]/Title"/></xsl:attribute>
</Item>
</xsl:if>
</xsl:for-each>
</Items>
</xsl:template>
</xsl:stylesheet>
@rornor
Copy link
Author

rornor commented Dec 29, 2012

Thread: link

Example see linked thread for example usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment