Skip to content

Instantly share code, notes, and snippets.

@rornor rornor/id.xsl Secret
Created Dec 28, 2012

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.