From: Jan-Pascal van Best Date: Tue, 5 Mar 2013 12:43:37 +0000 (+0100) Subject: Fix Horizon for fetching other days than tomorrow; updated copyright, X-Git-Tag: 1.2.0 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=a7257dd12b856a1429f27b3cf9680889e296bb53;p=tv_grab_nl_java Fix Horizon for fetching other days than tomorrow; updated copyright, README and Changelog --- diff --git a/Changelog b/Changelog index f7094b6..32bfff4 100644 --- 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 1c8dce0..5050962 100644 --- 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 +Copyright (c) 2012-2013 Jan-Pascal van Best 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 7193469..8b4af3b 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.vanbest.xmltv.tv_grab_nl_java tv_grab_nl_java - 1.1.1-SNAPSHOT + 1.2.0 scm:git:git://github.com/janpascal/tv_grab_nl_java.git scm:git:https://janpascal@github.com/janpascal/tv_grab_nl_java.git diff --git a/src/main/java/org/vanbest/xmltv/AbstractEPGSource.java b/src/main/java/org/vanbest/xmltv/AbstractEPGSource.java index 3ac496b..b410282 100644 --- a/src/main/java/org/vanbest/xmltv/AbstractEPGSource.java +++ b/src/main/java/org/vanbest/xmltv/AbstractEPGSource.java @@ -1,5 +1,21 @@ package org.vanbest.xmltv; +/* +Copyright (c) 2012-2013 Jan-Pascal van Best + +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; diff --git a/src/main/java/org/vanbest/xmltv/Horizon.java b/src/main/java/org/vanbest/xmltv/Horizon.java index 01c50fe..6d012e3 100644 --- a/src/main/java/org/vanbest/xmltv/Horizon.java +++ b/src/main/java/org/vanbest/xmltv/Horizon.java @@ -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 getProgrammes(List channels, int day) throws Exception { List result = new ArrayList(); - 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 list = parseKijkwijzer(kijkwijzer); - if (config.joinKijkwijzerRatings) { - // mythtv doesn't understand multiple 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 programmes = horizon.getProgrammes(my_channels, 2); + List programmes = horizon.getProgrammes(my_channels, 3); for (Programme p : programmes) { p.serialize(writer); } diff --git a/src/main/java/org/vanbest/xmltv/ProgrammeCache.java b/src/main/java/org/vanbest/xmltv/ProgrammeCache.java index 9248120..2857855 100644 --- a/src/main/java/org/vanbest/xmltv/ProgrammeCache.java +++ b/src/main/java/org/vanbest/xmltv/ProgrammeCache.java @@ -1,7 +1,7 @@ package org.vanbest.xmltv; /* - Copyright (c) 2012 Jan-Pascal van Best + Copyright (c) 2012-2013 Jan-Pascal van Best 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/src/main/java/org/vanbest/xmltv/TvGids.java b/src/main/java/org/vanbest/xmltv/TvGids.java index 654c4fb..f315089 100644 --- a/src/main/java/org/vanbest/xmltv/TvGids.java +++ b/src/main/java/org/vanbest/xmltv/TvGids.java @@ -1,7 +1,7 @@ package org.vanbest.xmltv; /* - Copyright (c) 2012 Jan-Pascal van Best + Copyright (c) 2012-2013 Jan-Pascal van Best 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