]> www.vanbest.org Git - tv_grab_nl_java/commitdiff
RTL: Build <desc> from alginhoud and inhoud, use tt_inhoud if both
authorJan-Pascal van Best <janpascal@vanbest.org>
Wed, 25 Apr 2012 16:19:21 +0000 (18:19 +0200)
committerJan-Pascal van Best <janpascal@vanbest.org>
Wed, 25 Apr 2012 16:19:21 +0000 (18:19 +0200)
others are empty. Fixes: #2

pom.xml
src/main/java/org/vanbest/xmltv/RTL.java

diff --git a/pom.xml b/pom.xml
index ee76e5434ba893fc57ec2932e2ddabf79cb44de0..08ef1b1259b3c61a8b2a0b164805f1a930ece336 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.vanbest.xmltv.tv_grab_nl_java</groupId>
        <artifactId>tv_grab_nl_java</artifactId>
-       <version>0.9.2</version>
+       <version>0.9.3-SNAPSHOT</version>
        <dependencies>
                <dependency>
                        <groupId>net.sf.json-lib</groupId>
index f0856ff3009449cf2a7c3c344049c4add6e29234..a1e465bf2116347cd9347d98e62eab3b217ed2c9 100644 (file)
@@ -91,6 +91,12 @@ public class RTL extends AbstractEPGSource implements EPGSource  {
                        this.prevStartTime = null;\r
                }\r
        }\r
+       \r
+       class DescStatus {\r
+               String inhoud;\r
+               String alginhoud;\r
+               String tt_inhoud;\r
+       }\r
     \r
        public RTL(int sourceId, Config config) {\r
                super(sourceId, config);\r
@@ -187,7 +193,8 @@ public class RTL extends AbstractEPGSource implements EPGSource  {
                        System.out.println("Unknown attributes for RTL detail root node");\r
                }\r
                NodeList nodes = root.getChildNodes();\r
-               for( int i=0; i<nodes.getLength(); i++) {\r
+               DescStatus descStatus = new DescStatus();\r
+               for(int i=0; i<nodes.getLength(); i++) {\r
                        Node n = nodes.item(i);\r
                        if (!n.getNodeName().equals("uitzending_data_item")) {\r
                                System.out.println("Ignoring RTL detail, tag " + n.getNodeName() +", full xml:");\r
@@ -208,7 +215,7 @@ public class RTL extends AbstractEPGSource implements EPGSource  {
                                                String value = "\"" + sub.getTextContent().replaceAll("\\s", " ") + "\"";\r
                                                result[index] = value;\r
                                        }\r
-                                       handleNode(prog, dateStatus, subnodes.item(j));\r
+                                       handleNode(prog, dateStatus, descStatus, subnodes.item(j));\r
                                } catch (RTLException e) {\r
                                        System.out.println(e.getMessage());\r
                                        Transformer t = TransformerFactory.newInstance().newTransformer();\r
@@ -225,10 +232,31 @@ public class RTL extends AbstractEPGSource implements EPGSource  {
                                debugWriter.println();\r
                        }\r
                }\r
+               StringBuilder description = new StringBuilder();\r
+               if (descStatus.alginhoud!=null) {\r
+                       description.append(descStatus.alginhoud);\r
+                       //System.out.print("A");\r
+               }\r
+               if (descStatus.inhoud!=null) {\r
+                       if (description.length()!=0) {\r
+                               description.append("<p>");\r
+                               //System.out.print("n");\r
+                               //System.out.println("Date: "+prog.startTime + "; title: "+ prog.getFirstTitle());\r
+                       }\r
+                       description.append(descStatus.inhoud);\r
+                       //System.out.print("B");\r
+               }\r
+               if (description.length()==0 && descStatus.tt_inhoud!=null) {\r
+                       description.append(descStatus.tt_inhoud);\r
+                       //System.out.print("C");\r
+                       //System.out.println("Date: "+prog.startTime + "; title: "+ prog.getFirstTitle());\r
+               }\r
+               // ignore tt_inhoud since it is almost always a summary of the above and other fields\r
+               prog.addDescription(description.toString());\r
        }\r
 \r
        \r
-       private void handleNode(Programme prog, DateStatus dateStatus, Node n) throws RTLException, DOMException, SQLException {\r
+       private void handleNode(Programme prog, DateStatus dateStatus, DescStatus descStatus, Node n) throws RTLException, DOMException, SQLException {\r
                if (n.getNodeType() != Node.ELEMENT_NODE) {\r
                        throw new RTLException("Ignoring non-element node " + n.getNodeName());\r
                }\r
@@ -265,11 +293,11 @@ public class RTL extends AbstractEPGSource implements EPGSource  {
                } else if (tag.equals("wwwadres")) {\r
                        prog.addUrl(e.getTextContent());\r
                } else if (tag.equals("alginhoud")) {\r
-                       prog.addDescription(e.getTextContent());\r
+                       descStatus.alginhoud = e.getTextContent();\r
                } else if (tag.equals("inhoud")) {\r
-                       prog.addDescription(e.getTextContent());\r
+                       descStatus.inhoud = e.getTextContent();\r
                } else if (tag.equals("tt_inhoud")) {\r
-                       prog.addDescription(e.getTextContent());\r
+                       descStatus.tt_inhoud = e.getTextContent();\r
                        // ignore, is summary of other fields\r
                } else if (tag.equals("zendernr")) {\r
                } else if (tag.equals("titel")) {\r