<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.6
Installatie
-----------
-0. Het programma vereist Java7. Onder Debian te installeren met 'apt-get install openjdk-7-jre'.
+0. Het programma vereist een Java runtime, versie 6 of hoger. Onder Debian te installeren met
+ $ apt-get install openjdk-6-jre
1. Download de .zip file (tv_grab_nl_java-VERSIE.zip) en pak 'm uit. Op Github te vinden via de URL
https://github.com/janpascal/tv_grab_nl_java/downloads
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.7</source>
- <target>1.7</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
protected Config config;
protected ProgrammeCache cache;
protected Stats stats = new Stats();
+
+ public static final int MAX_FETCH_TRIES=5;
public AbstractEPGSource(Config config) {
this.config = config;
protected String fetchURL(URL url) throws Exception {
Thread.sleep(config.niceMilliseconds);
StringBuffer buf = new StringBuffer();
- try {
- BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream()));
- String s;
- while ((s = reader.readLine()) != null) buf.append(s);
- } catch (IOException e) {
+ boolean done = false;
+ IOException finalException = null;
+ for(int count = 0; count<MAX_FETCH_TRIES && !done; count++) {
+ try {
+ BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream()));
+ String s;
+ while ((s = reader.readLine()) != null) buf.append(s);
+ done = true;
+ } catch (IOException e) {
+ if (!config.quiet) {
+ System.out.println("Error fetching from url " + url + ", count="+count);
+ }
+ finalException = e;
+ }
+ }
+ if (!done) {
stats.fetchErrors++;
- throw new Exception("Error getting program data from url " + url, e);
+ throw new Exception("Error getting program data from url " + url, finalException);
}
return buf.toString();
}
if (!s.contains(":")) continue;
if (s.startsWith("#")) continue;
List<String> parts = splitLine(s);
- switch (parts.get(0).toLowerCase()) {
- case "channel":
+ String key = parts.get(0).toLowerCase();
+ if(key.equals("channel")) {
Channel c = null;
// System.out.println("Adding channel " + parts + " in file format " + fileformat);
switch(fileformat) {
if (parts.size()>4) {
c.addIcon(parts.get(4));
}
- switch(parts.get(2)) {
- case "enabled": c.setEnabled(true); break;
- case "disabled": c.setEnabled(false); break;
- default: System.out.println("Error in config file, unknown channel status \"" + parts.get(2) + "\", should be enabled or disabled");
+ String value = parts.get(2);
+ if (value.equals("enabled")) {
+ c.setEnabled(true);
+ } else if (value.equals("disabled")) {
+ c.setEnabled(false);
+ } else {
+ System.out.println("Error in config file, unknown channel status \"" + parts.get(2) + "\", should be enabled or disabled");
}
}
result.channels.add(c);
- break;
- case "category" :
+ } else if (key.equals("category")) {
result.cattrans.put(parts.get(1), parts.get(2));
- break;
- case "config-file-format" :
+ } else if (key.equals("config-file-format")) {
try {
fileformat = Integer.parseInt(parts.get(1));
} catch (NumberFormatException e) {
System.out.println("Unknown config file format " + parts.get(1));
fileformat = CURRENT_FILE_FORMAT;
}
- break;
- case "cache-file":
+ } else if (key.equals("cache-file")) {
result.cacheFile = new File(parts.get(1));
- break;
- case "nice-time-milliseconds":
+ } else if (key.equals("nice-time-milliseconds")) {
result.niceMilliseconds = Integer.parseInt(parts.get(1));
+ } else {
+ System.out.println("Unknown key " + key + " in config file!");
}
}
} catch (IOException e) {
System.out.println("tv_grab_nl_java comes with ABSOLUTELY NO WARRANTY. It is free software, and you are welcome to redistribute it");
System.out.println("under certain conditions; `tv_grab_nl_java --license' for details.");
- System.out.println("Fetching programme data for days " + this.offset + "-" + (this.offset+this.days-1));
+ System.out.println("Fetching programme data for " + this.days + " starting from day " + this.offset);
int enabledCount = 0;
for(Channel c: config.channels) { if (c.enabled) enabledCount++; }
System.out.println("... from " + enabledCount + " channels");
Document xml = null;\r
try {\r
xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(url.openStream());\r
- } catch (SAXException | IOException | ParserConfigurationException e) {\r
+ } catch (Exception e) {\r
// TODO Auto-generated catch block\r
e.printStackTrace();\r
}\r
}\r
Element e = (Element)n;\r
stat.setString(xmlKeyMap.get(e.getTagName())+1, e.getTextContent());\r
- switch (e.getTagName()) {\r
- case "genre":\r
+ String tag = e.getTagName();\r
+ if (tag.equals("genre")) {\r
prog.addCategory(config.translateCategory(e.getTextContent()));\r
- break;\r
- case "eindtijd":\r
+ } else if (tag.equals("eindtijd")) {\r
prog.endTime = parseTime(date, e.getTextContent());\r
- break;\r
- case "omroep":\r
- case "kijkwijzer":\r
- case "presentatie":\r
- case "wwwadres":\r
- case "alginhoud":\r
- case "inhoud":\r
- case "tt_inhoud":\r
- case "zendernr":\r
- case "titel":\r
- case "bijvnwlanden":\r
- case "afl_titel":\r
- case "site_path":\r
- case "ondertiteling":\r
- case "begintijd":\r
- case "pgmsoort":\r
- break;\r
- default:\r
+ } else if (tag.equals("omroep")) {\r
+ } else if (tag.equals("kijkwijzer")) {\r
+ } else if (tag.equals("presentatie")) {\r
+ } else if (tag.equals("wwwadres")) {\r
+ } else if (tag.equals("alginhoud")) {\r
+ } else if (tag.equals("inhoud")) {\r
+ } else if (tag.equals("tt_inhoud")) {\r
+ } else if (tag.equals("zendernr")) {\r
+ } else if (tag.equals("titel")) {\r
+ } else if (tag.equals("bijvnwlanden")) {\r
+ } else if (tag.equals("afl_titel")) {\r
+ } else if (tag.equals("site_path")) {\r
+ } else if (tag.equals("ondertiteling")) {\r
+ } else if (tag.equals("begintijd")) {\r
+ } else if (tag.equals("pgmsoort")) {\r
+ } else {\r
throw new RTLException("Ignoring unknown tag " + n.getNodeName() + ", content: \"" + e.getTextContent() + "\"");\r
}\r
//prog.endTime = parseTime(date, root.)\r
//System.out.println(" infoLine: " + m2.group());
//System.out.println(" key: " + m2.group(1));
//System.out.println(" value: " + m2.group(2));
- String key = m2.group(1);
+ String key = m2.group(1).toLowerCase();
String value = m2.group(2);
- switch(key.toLowerCase()) {
- case "bijzonderheden":
+ if (key.equals("bijzonderheden")) {
String[] list = value.split(",");
for( String item: list) {
if (item.toLowerCase().contains("teletekst")) {
}
}
}
- break;
+ } else {
+ // ignore other keys for now
}
Matcher m3 = kijkwijzerPattern.matcher(progInfo);
List<String> kijkwijzer = new ArrayList<String>();
*/
import java.util.Date;
+import org.apache.commons.lang.StringEscapeUtils;
public class TvGidsProgramme {
public String getDb_id() {
Channel channel = null;
public void fixup(Config config) {
- this.titel = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(titel);
- this.genre = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(genre);
- this.soort = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(soort);
- this.highlight_content = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(highlight_content);
+ titel = titel==null?"":StringEscapeUtils.unescapeHtml(titel);
+ genre = genre==null?"":StringEscapeUtils.unescapeHtml(genre);
+ soort = soort==null?"":StringEscapeUtils.unescapeHtml(soort);
+ highlight_content = highlight_content==null?"":StringEscapeUtils.unescapeHtml(highlight_content);
genre = config.translateCategory(genre);
}
import java.io.Serializable;
+import org.apache.commons.lang.StringEscapeUtils;
+
public class TvGidsProgrammeDetails implements Serializable {
String db_id;
String titel;
public boolean herhaling = false;
public void fixup(TvGidsProgramme p, boolean quiet) {
- this.titel = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(titel);
- this.genre = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(genre);
- this.synop = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(synop);
- this.synop = this.synop.replaceAll("<br>", " ").
+ titel = titel==null?"":StringEscapeUtils.unescapeHtml(titel);
+ genre = genre==null?"":StringEscapeUtils.unescapeHtml(genre);
+ synop = synop==null?"":StringEscapeUtils.unescapeHtml(synop);
+ synop = this.synop.replaceAll("<br>", " ").
replaceAll("<br />", " ").
replaceAll("<p>", " ").
replaceAll("</p>", " ").
replaceAll("<em>", " ").
replaceAll("</em>", " ").
trim();
- if ((synop == null || synop.isEmpty()) && ( genre == null || (!genre.toLowerCase().equals("movies") && !genre.toLowerCase().equals("film")))) {
+ if (synop.isEmpty() && (!genre.toLowerCase().equals("movies") && !genre.toLowerCase().equals("film"))) {
String[] parts = p.titel.split("[[:space:]]*:[[:space:]]*", 2);
if (parts.length >= 2 ) {
if (!quiet) {
synop = parts[1].trim();
}
}
- this.presentatie = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(presentatie);
- this.acteursnamen_rolverdeling = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(acteursnamen_rolverdeling);
- this.regisseur = org.apache.commons.lang.StringEscapeUtils.unescapeHtml(regisseur);
+ presentatie = presentatie==null?"":StringEscapeUtils.unescapeHtml(presentatie);
+ acteursnamen_rolverdeling = acteursnamen_rolverdeling==null?"":StringEscapeUtils.unescapeHtml(acteursnamen_rolverdeling);
+ regisseur = regisseur==null?"":StringEscapeUtils.unescapeHtml(regisseur);
}
public String getDb_id() {
public void writeChannels(List<Channel> channels) throws XMLStreamException {
for(Channel c: channels) {
+ if (!c.enabled) continue;
c.serialize(writer);
writeln();
}