NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 56 57 58 59 60 … 93 Next »
XSL Transformations on xmltv files for gbpvr

 
  • 0 Vote(s) - 0 Average
XSL Transformations on xmltv files for gbpvr
alibert
Offline

Posting Freak

Posts: 974
Threads: 83
Joined: Apr 2005
#1
2005-11-12, 09:01 AM
Hi,

maybe someone is also interested in this.

Since gbpvr is only using the 'title', 'sub-title' and 'desc' tags of xmltv files for generating epg data, but xmltv files can contain much more information, i've written a small xsl-file as a workaround to put those other information into the 'desc'-tag.

Currently the nodes 'episode-num', 'category', 'country', 'date', 'credits' and 'rating' are used.

I'm german so it is targetted to a german gbpvr and contains some german words like 'Buch' or 'Moderation', but it should be easy to translate it in any other language you want.

Here it is:

Code:
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="/tv/programme">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="title" />
<xsl:apply-templates select="sub-title" />
<desc>
<xsl:apply-templates select="episode-num" />
<xsl:apply-templates select="category" />
<xsl:apply-templates select="country" />
<xsl:apply-templates select="date" />
<xsl:apply-templates select="desc" />
<xsl:apply-templates select="credits" />
<xsl:apply-templates select="rating" />
</desc>  
</xsl:copy>
</xsl:template>

<xsl:template match="/tv/programme/title">
<xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
</xsl:template>

<xsl:template match="/tv/programme/sub-title">
<xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
</xsl:template>

<xsl:template match="/tv/programme/episode-num">
<xsl:text>Folge </xsl:text><xsl:value-of select="." />
<xsl:choose>
<xsl:when test="not(../category) and not(../country) and not(../date)"><xsl:text>
</xsl:text></xsl:when>
<xsl:otherwise><xsl:text> | </xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="/tv/programme/category">
<xsl:value-of select="." />
<xsl:choose>
<xsl:when test="not(../country) and not(../date)"><xsl:text>
</xsl:text></xsl:when>
<xsl:otherwise><xsl:text> | </xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="/tv/programme/country">
<xsl:value-of select="." />
<xsl:choose>
<xsl:when test="not(../date)"><xsl:text>
</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="/tv/programme/date">
<xsl:value-of select="." /><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="/tv/programme/desc">
<xsl:value-of select="." /><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="/tv/programme/credits">
<xsl:apply-templates select="presenter" />
<xsl:apply-templates select="guest" />
<xsl:apply-templates select="producer" />
<xsl:apply-templates select="director" />
<xsl:apply-templates select="actor" />
<xsl:apply-templates select="writer" />
</xsl:template>

<xsl:template match="/tv/programme/credits/presenter">
<xsl:if test="position()=1">Moderation: </xsl:if>
<xsl:value-of select="." />
<xsl:call-template name="comma"/>
<xsl:call-template name="newline"/>
</xsl:template>
<xsl:template match="/tv/programme/credits/guest">
<xsl:if test="position()=1">Zu Gast: </xsl:if>
<xsl:value-of select="." />
<xsl:call-template name="comma"/>
<xsl:call-template name="newline"/>
</xsl:template>
<xsl:template match="/tv/programme/credits/producer">
<xsl:if test="position()=1">Von: </xsl:if>
<xsl:value-of select="." />
<xsl:call-template name="comma"/>
<xsl:call-template name="newline"/>
</xsl:template>
<xsl:template match="/tv/programme/credits/director">
<xsl:if test="position()=1">Regie: </xsl:if>
<xsl:value-of select="." />
<xsl:call-template name="comma"/>
<xsl:call-template name="newline"/>
</xsl:template>
<xsl:template match="/tv/programme/credits/actor">
<xsl:if test="position()=1">Mit: </xsl:if>
<xsl:value-of select="." />
<xsl:call-template name="comma"/>
<xsl:call-template name="newline"/>
</xsl:template>
<xsl:template match="/tv/programme/credits/writer">
<xsl:if test="position()=1">Buch: </xsl:if>
<xsl:value-of select="." />
<xsl:call-template name="comma"/>
<xsl:call-template name="newline"/>
</xsl:template>

<xsl:template match="/tv/programme/rating">
<xsl:if test="@system='FSK'">FSK: <xsl:value-of select="value/." /></xsl:if>
</xsl:template>

<xsl:template name="comma"><xsl:if test="not(position()=last())">, </xsl:if></xsl:template>
<xsl:template name="newline">
<xsl:if test="position()=last()">
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

For example, the output of this programme:

Code:
<programme start="20051111051000 +0100" stop="20051111055000 +0100" showview="98-25-430" channel="rtl2.de">
    <title lang="de">Hallo Holly</title>
    <sub-title lang="de">Die coole ältere Schwester / Ein alter Papagei</sub-title>
    <desc lang="de">Valerie beschließt die Zügel bei Holly etwas lockerer zu lassen, da sie sich durch die ständigen Gebote wie eine strenge Mutter vorkommt. Holly nutzt das natürlich sofort aus. Dabei setzt sie ihre neu erworbene Freiheit gleich wieder aufs Spiel...</desc>
    <credits>
      <director>Shelley Jensen</director>
      <actor>Amanda Bynes</actor>
      <actor>Jennie Garth</actor>
    </credits>
    <date>2002</date>
    <category lang="de">Comedy-Serie</category>
    <country lang="de">USA</country>
    <video>
      <present>yes</present>
      <colour>yes</colour>
    </video>
    <audio>
      <present>yes</present>
      <stereo>mono</stereo>
    </audio>
  </programme>

looks like this:

Code:
<programme start="20051110170000 +0100" stop="20051110180000 +0100" showview="731-294" channel="rtl2.de" clumpidx="0/1">
      <title>Hallo Holly</title>
      <sub-title lang="de">Die coole ältere Schwester / Ein alter Papagei</sub-title>
      <desc>Comedy-Serie | USA, 2002
Valerie beschließt die Zügel bei Holly etwas lockerer zu lassen, da sie sich durch die ständigen Gebote wie eine strenge Mutter vorkommt. Holly nutzt das natürlich sofort aus. Dabei setzt sie ihre neu erworbene Freiheit gleich wieder aufs Spiel...
Regie: Shelley Jensen
Mit: Amanda Bynes, Jennie Garth
</desc>
   </programme>

I'm using saxon as xml processor, but it should also work with any other.

-alibert
erik
Offline

Posting Freak

Posts: 1,138
Threads: 123
Joined: Apr 2005
#2
2005-11-23, 09:01 PM
I feel very stupid but when I run your exact examples nothing happens, there are no changes to the xml file.
Did you test the example you posted :o
P4 3GHz 1GB, 250GB, nVidia dualTV, GBPVR 1.3.11, XP
Support Comskip, visit the forum and donate at http://www.comskip.org/
alibert
Offline

Posting Freak

Posts: 974
Threads: 83
Joined: Apr 2005
#3
2005-11-25, 08:52 AM
Hi erik,

erik Wrote:I feel very stupid but when I run your exact examples nothing happens, there are no changes to the xml file.
Did you test the example you posted :o

Of course I tested the example above. Which xslt processor are you using? You could also upload your xmltv file to your server and i'll have at what's going wrong.

-alibert
erik
Offline

Posting Freak

Posts: 1,138
Threads: 123
Joined: Apr 2005
#4
2005-11-25, 02:54 PM
I use Saxon 6.5.2 (the command line version)

The input file (x.xml) and the transfer description (t.xsl) are in the attached zip file
They should be identical to the example you posted.

I use the following command and get this results

c:\>saxon x.xml t.xsl
Error at byte 188 of file:/C:/Program Files/Saxon/x.xml:
Error reported by XML parser: bad continuation of multi-byte UTF-8 sequence (code: 0x6c)
Transformation failed: Run-time errors were reported
P4 3GHz 1GB, 250GB, nVidia dualTV, GBPVR 1.3.11, XP
Support Comskip, visit the forum and donate at http://www.comskip.org/
alibert
Offline

Posting Freak

Posts: 974
Threads: 83
Joined: Apr 2005
#5
2005-11-25, 03:21 PM
Hi,

erik Wrote:I use Saxon 6.5.2 (the command line version)

Me too (revision 6.5.4).

erik Wrote:c:\>saxon x.xml t.xsl

Maybe you should consider to pass an argument for the output file, the command I use is this (if your classpath is set, the "-cp" argument can be ignored):
Code:
java -cp D:\saxon6-5-4\saxon.jar;D:\saxon6-5-4\saxon-xml-apis.jar com.icl.saxon.StyleSheet -o outputfile.xml inputfile.xml stylesheet.xsl

erik Wrote:Error at byte 188 of file:/C:/Program Files/Saxon/x.xml:
Error reported by XML parser: bad continuation of multi-byte UTF-8 sequence (code: 0x6c)
Transformation failed: Run-time errors were reported

This error seems to occur because there is no valid encoding in your xml file "x.xml" (and it contains some german 'umlauts' like "ä,ö,ü". Try adding "<?xml version="1.0" encoding="iso-8859-1"?>" as the first row to the file.

Then saxon should finish without errors.

But the result would still be a copy of the source file, because the xslt processor searches for an element "programme" as child node of the element "tv" to apply the templates ("<xsl:template match="/tv/programme">...").
So, a root element with name "tv" must be present in the xml file to get the results.

-alibert
erik
Offline

Posting Freak

Posts: 1,138
Threads: 123
Joined: Apr 2005
#6
2005-11-25, 04:21 PM
Thanks, that confirms my findings.
P4 3GHz 1GB, 250GB, nVidia dualTV, GBPVR 1.3.11, XP
Support Comskip, visit the forum and donate at http://www.comskip.org/
cginzel
Offline

Member

Posts: 192
Threads: 22
Joined: Dec 2004
#7
2006-05-08, 03:09 PM (This post was last modified: 2006-05-08, 03:13 PM by cginzel.)
Curious, can anyone tell me why GBPVR doesn't import the <episode-num> tag? I see that using the XMLTV North American Direct Data format from Zap2it inculdes an entry like:

<episode-num system="dd_progid">EP754478.0013</episode-num>

Is this not the same data GBPVR would recieve when it goes directly against Zap2It? alternatively, I also see many of the entries include an "onscreen" system attribute value:

<episode-num system="onscreen">1711</episode-num>
[SIZE="1"]NextPVR v2.3.4 on XP Home SP2
Rig: Dual Core P4 2.8GHz, 3GB Ram + 230GB HD
Media: WinTV PVR-150/MCE (2) + Media MVP 1000 (1) vD3A
Tools/Plug-ins: Weather, ComSkip, NEWA[/SIZE]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Loading Local Video Files Syler 25 7,030 2021-03-07, 09:20 PM
Last Post: Syler
  How to extract M3U8 and get matching XMLTV guide data from NPVR almightyj 0 3,559 2018-10-23, 07:24 AM
Last Post: almightyj
  XMLTV Channel Number Option gdogg371 12 7,081 2018-07-18, 04:32 PM
Last Post: sub
  TitanTv Remote Schedule For GBPVR UncleJohnsBand 51 34,470 2015-08-20, 05:11 PM
Last Post: sub
  Merge xmltv data with xslt Graham 4 3,599 2014-01-02, 12:45 PM
Last Post: Graham
  sabnzbd plugin to show processed files Wakalaka 1 2,029 2013-03-12, 06:48 AM
Last Post: psycik
  Building a list of files in media folders (npvr Music and Videos) bgowland 2 1,954 2012-02-05, 10:29 AM
Last Post: bgowland
  Extracting data from XML files ACTCMS 4 2,447 2012-01-24, 12:16 AM
Last Post: sub
  Roku & GBPVR pvruser 16 11,661 2011-10-16, 08:31 PM
Last Post: pvruser
  (Yet Another) Rename Helper script for GBPVR & NPVR pvruser 2 2,793 2011-07-22, 01:27 AM
Last Post: pvruser

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode