]> www.vanbest.org Git - tv_grab_nl_java/commitdiff
Fix Horizon for fetching other days than tomorrow; updated copyright, 1.2.0
authorJan-Pascal van Best <janpascal@vanbest.org>
Tue, 5 Mar 2013 12:43:37 +0000 (13:43 +0100)
committerJan-Pascal van Best <janpascal@vanbest.org>
Tue, 5 Mar 2013 12:43:37 +0000 (13:43 +0100)
README and Changelog

Changelog
README
pom.xml
src/main/java/org/vanbest/xmltv/AbstractEPGSource.java
src/main/java/org/vanbest/xmltv/Horizon.java
src/main/java/org/vanbest/xmltv/ProgrammeCache.java
src/main/java/org/vanbest/xmltv/TvGids.java

index f7094b6d1d7eb10e2285d040f6ac28130f4907c2..32bfff4f5b82b6aa718ce7cc8911153444b509f1 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,9 @@
 Changelog for tv_grab_nl_java
 =============================
 
+tv_grab_nl_java-1.2.0 (2013-03-05)
+- UPC (www.horizon.tv) module toegevoegd
+
 tv_grab_nl_java-1.1.0 (2013-01-03)
 - Meer stabiliteit in RTL module doordat er nu vijf keer geprobeerd wordt een
   URL op te halen
diff --git a/README b/README
index 1c8dce050807f8b6854eafa674e1e04c35db85c5..5050962bd469650d7912c7870dbdbc2beed05f26 100644 (file)
--- a/README
+++ b/README
@@ -4,12 +4,12 @@ README for tv_grab_nl_java
 English Summary
 ---------------
 tv_grab_nl_java is an XMLTV-compatible grabber for Dutch television that uses
-TVGids.nl and rtl.nl as sources.
+TVGids.nl, rtl.nl and/or horizon.nl (UPC) as sources.
 
 Algemeen
 --------
 tv_grab_nl_java is een XMLTV-compatibele grabber voor Nederlandse televisie 
-die TVGids.nl en rtl.nl als bron kan gebruiken. tv_grab_nl_java is geschreven 
+die TVGids.nl, rtl.nl en horizon.nl (UPC) als bron kan gebruiken. tv_grab_nl_java is geschreven 
 in Java en gebruikt o.a. de JSON-interface van TVGids.nl.
 
 Kenmerken van tv_grab_nl_java:
@@ -20,7 +20,6 @@ Kenmerken van tv_grab_nl_java:
   als default
 - geeft informatie over acteurs, presentatie, regisseur weer in xmltv
 - geschikt voor mythtv
-- rtl.nl als bron is nog vrij nieuw en kan nog onverwachte resultaten opleveren
 
 Geschiedenis
 ------------
@@ -143,7 +142,7 @@ Het adres van de git repository is git://github.com/janpascal/tv_grab_nl_java.gi
 
 License
 -------
-Copyright (c) 2012 Jan-Pascal van Best <janpascal@vanbest.org>
+Copyright (c) 2012-2013 Jan-Pascal van Best <janpascal@vanbest.org>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
diff --git a/pom.xml b/pom.xml
index 71934698a612f9c876a8b467cf9ebd68a76c6dd7..8b4af3b5b37491035f6d55db09c9aa7045603c92 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.vanbest.xmltv.tv_grab_nl_java</groupId>
        <artifactId>tv_grab_nl_java</artifactId>
-       <version>1.1.1-SNAPSHOT</version>
+       <version>1.2.0</version>
        <scm>
                <connection>scm:git:git://github.com/janpascal/tv_grab_nl_java.git</connection>
                <developerConnection>scm:git:https://janpascal@github.com/janpascal/tv_grab_nl_java.git</developerConnection>
index 3ac496be064d1ae1a0f96cefc96cede5ef14d935..b410282497afe757b572868f8f39ee59fae36841 100644 (file)
@@ -1,5 +1,21 @@
 package org.vanbest.xmltv;
 
+/*
+Copyright (c) 2012-2013 Jan-Pascal van Best <janpascal@vanbest.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+The full license text can be found in the LICENSE file.
+*/
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
index 01c50fe9236b93f2ae7805d063e4f78d0a05360c..6d012e34fe929ab089a88e59e6496a323b62db8e 100644 (file)
@@ -49,8 +49,6 @@ public class Horizon extends AbstractEPGSource implements EPGSource {
        static String listings_url = "https://www.horizon.tv/oesp/api/NL/nld/web/listings";
        //  ?byStationId=28070126&sort=startTime&range=1-100&byStartTime=1362000000000~1362100000000";
 
-       private static final int MAX_DAYS_AHEAD_SUPPORTED_BY_HORIZON = 3;
-
        public static String NAME = "horizon.tv";
 
        static Logger logger = Logger.getLogger(Horizon.class);
@@ -74,7 +72,7 @@ public class Horizon extends AbstractEPGSource implements EPGSource {
                startTime.set(Calendar.MINUTE, 0);
                startTime.set(Calendar.SECOND, 0);
                startTime.set(Calendar.MILLISECOND, 0);
-               startTime.add(Calendar.DAY_OF_MONTH,  1);
+               startTime.add(Calendar.DAY_OF_MONTH,  day);
                Calendar endTime = (Calendar) startTime.clone();
                endTime.add(Calendar.DAY_OF_MONTH,  1);
                s.append("&byStartTime=");
@@ -154,10 +152,6 @@ public class Horizon extends AbstractEPGSource implements EPGSource {
        public List<Programme> getProgrammes(List<Channel> channels, int day)
                        throws Exception {
                List<Programme> result = new ArrayList<Programme>();
-               if (day > MAX_DAYS_AHEAD_SUPPORTED_BY_HORIZON) {
-                       return result; // empty list
-               }
-
                for (Channel c : channels) {
                        URL url = programmeUrl(c, day);
                        logger.debug("Programme url:" + url);
@@ -216,71 +210,76 @@ public class Horizon extends AbstractEPGSource implements EPGSource {
                String id = json.getString("id");
                Programme result = cache.get(getId(), id);
                boolean cached = (result != null);
+               boolean doNotCache = false;
                if (result == null) {
                        stats.cacheMisses++;
                        result = new Programme();
                        result.startTime = new Date(json.getLong("startTime"));
                        result.endTime = new Date(json.getLong("endTime"));
                        JSONObject prog = json.getJSONObject("program");
-                       if (prog.containsKey("secondaryTitle")){
-                               result.addTitle(prog.getString("secondaryTitle"));
-                       } else {
-                               result.addTitle(prog.getString("title"));
+                       String title = null;
+                       if (prog.has("secondaryTitle")){
+                               title = prog.getString("secondaryTitle");
+                               if (title.contains("Zal snel bekend")) title = null;
+                       } 
+                       if ((title==null || title.isEmpty()) && prog.has("title")) {
+                               title = prog.getString("title");
                        }
-                       String description = prog.getString("longDescription");
+            if (title != null && !title.isEmpty()) {
+                result.addTitle(title);
+            } else {
+                doNotCache = true;
+            }
+            String description = null;
+            if (prog.has("longDescription")) description = prog.getString("longDescription");
                        if (description==null || description.isEmpty()) {
-                       description = prog.getString("description");
-                               if (description==null || description.isEmpty()) {
-                                       description = prog.getString("shortDescription");
-                               }
+                           if (prog.has("description")) description = prog.getString("description");
                        }
-                       result.addDescription(description);
-
-                       JSONArray cast = prog.getJSONArray("cast");
-                       for( int j=0; j<cast.size(); j++) {
-                               result.addActor(cast.getString(j));
+                       if (description==null || description.isEmpty()) {
+                if (prog.has("shortDescription")) description = prog.getString("shortDescription");
                        }
+            if (description!= null && !description.isEmpty()) {
+                result.addDescription(description);
+            } else {
+                doNotCache = true;
+            }
 
-                       JSONArray directors = prog.getJSONArray("directors");
-                       for( int j=0; j<directors.size(); j++) {
-                               result.addDirector(directors.getString(j));
-                       }
-                       JSONArray categories = prog.getJSONArray("categories");
-                       for( int j=0; j<categories.size(); j++) {
-                               String cat = categories.getJSONObject(j).getString("title");
-                               if (!cat.contains("/")) {
-                                       // Remove things like "drama/drama" and subcategories
-                                       result.addCategory(config.translateCategory(cat));
-                               }
-                       }
-                       if (prog.containsKey("seriesEpisodeNumber")){
+            if (prog.has("cast")) { 
+                       JSONArray cast = prog.getJSONArray("cast");
+                       for( int j=0; j<cast.size(); j++) {
+                               result.addActor(cast.getString(j));
+                       }
+            }
+            
+            if (prog.has("directors")) { 
+                       JSONArray directors = prog.getJSONArray("directors");
+                       for( int j=0; j<directors.size(); j++) {
+                               result.addDirector(directors.getString(j));
+                       }
+            }
+
+            if (prog.has("categories")) { 
+                       JSONArray categories = prog.getJSONArray("categories");
+                       for( int j=0; j<categories.size(); j++) {
+                               String cat = categories.getJSONObject(j).getString("title");
+                               if (!cat.contains("/")) {
+                                       // Remove things like "drama/drama" and subcategories
+                                       result.addCategory(config.translateCategory(cat));
+                               }
+                       }
+            }
+                       if (prog.has("seriesEpisodeNumber")){
                                String episode = prog.getString("seriesEpisodeNumber");
                                result.addEpisode(episode,"onscreen");
                        }
-                       if (prog.containsKey("parentalRating")){
+                       /* Disabled, contains disinformation
+                       if (prog.has("parentalRating")){
                                String rating  = prog.getString("parentalRating");
                                result.addRating("kijkwijzer", "Afgeraden voor kinderen jonger dan "+rating+" jaar");
                        }
+                       */
                        /*
-                       // Do this here, because we can only add to these fields. Pity if
-                       // they're updated
-                       result.addTitle(programme.getString("titel"));
-                       String genre = programme.getString("genre");
-                       if (genre != null && !genre.isEmpty())
-                               result.addCategory(config.translateCategory(genre));
-                       String kijkwijzer = programme.getString("kijkwijzer");
-                       if (kijkwijzer != null && !kijkwijzer.isEmpty()) {
-                               List<String> list = parseKijkwijzer(kijkwijzer);
-                               if (config.joinKijkwijzerRatings) {
-                                       // mythtv doesn't understand multiple <rating> tags
-                                       result.addRating("kijkwijzer", StringUtils.join(list, ","));
-                               } else {
-                                       for (String rating : list) {
-                                               result.addRating("kijkwijzer", rating);
-                                       }
-                               }
-                               // TODO add icon from HTML detail page
-                       }
+                               // TODO add icon 
                        */
                } else {
                        // System.out.println("From cache: " +
@@ -289,8 +288,7 @@ public class Horizon extends AbstractEPGSource implements EPGSource {
                }
                // TODO other fields
 
-               if (!cached) {
-                       // FIXME where to do this?
+               if (!cached && !doNotCache) {
                        cache.put(getId(), id, result);
                }
                logger.debug(result);
@@ -319,7 +317,7 @@ public class Horizon extends AbstractEPGSource implements EPGSource {
                                c.serialize(writer);
                        }
                        writer.flush();
-                       List<Programme> programmes = horizon.getProgrammes(my_channels, 2);
+                       List<Programme> programmes = horizon.getProgrammes(my_channels, 3);
                        for (Programme p : programmes) {
                                p.serialize(writer);
                        }
index 9248120cc90d8396ee09446f2906b8ec01c76ae8..28578550fa87265615f97b87f4bb916e2f60dcc6 100644 (file)
@@ -1,7 +1,7 @@
 package org.vanbest.xmltv;
 
 /*
- Copyright (c) 2012 Jan-Pascal van Best <janpascal@vanbest.org>
+ Copyright (c) 2012-2013 Jan-Pascal van Best <janpascal@vanbest.org>
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
index 654c4fb161b399cff3a4f04f1ea18070751effdb..f315089b8fbbf48aca877b30a401b05c4eb7dfc9 100644 (file)
@@ -1,7 +1,7 @@
 package org.vanbest.xmltv;
 
 /*
- Copyright (c) 2012 Jan-Pascal van Best <janpascal@vanbest.org>
+ Copyright (c) 2012-2013 Jan-Pascal van Best <janpascal@vanbest.org>
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by