fix(template): add conditional to only insert episode-num if season and episode numbers actually exist

This commit is contained in:
Nic D 2026-02-18 14:11:55 -05:00
parent ad4e456d09
commit d502fa5585

View File

@ -24,11 +24,13 @@
<xsl:variable name="rest"
select="substring-after($raw, '.')"/>
<xsl:variable name="episode"
<xsl:variable name="episode0"
select="number(normalize-space(substring-before($rest, '.')))"/>
<xsl:variable name="season" select="$season0 + 1"/>
<xsl:variable name="episode" select="$episode0 + 1"/>
<!-- zero pad -->
<xsl:variable name="s2">
<xsl:choose>
@ -59,10 +61,12 @@
<xsl:apply-templates
select="node()[not(self::episode-num[@system='onscreen'])]" />
<!-- Add the onscreen one at the end -->
<!-- Add the onscreen one at the end if the numbers actually exist -->
<xsl:if test="$s2 &gte; 0 and $e2 &gte; 0">
<episode-num system="onscreen">
<xsl:value-of select="$onscreenValue"/>
</episode-num>
</xsl:if>
</xsl:copy>
</xsl:template>