X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fsupport%2FTheRegister.java;h=5903eaa64a2b8512712eb623290deed4db244db5;hb=b34d1f357b076c1697e381b70cb6ff1bb0278b91;hp=3d7496ab65c53f0d9d489b8f52fcadeb6512cce6;hpb=7686553a3f040e0efb9416bd8cc024f967356f98;p=gofetch.git diff --git a/src/be/nikiroo/gofetch/support/TheRegister.java b/src/be/nikiroo/gofetch/support/TheRegister.java index 3d7496a..5903eaa 100644 --- a/src/be/nikiroo/gofetch/support/TheRegister.java +++ b/src/be/nikiroo/gofetch/support/TheRegister.java @@ -3,9 +3,7 @@ package be.nikiroo.gofetch.support; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.jsoup.helper.DataUtil; @@ -18,6 +16,12 @@ import be.nikiroo.gofetch.data.Comment; import be.nikiroo.gofetch.data.Story; import be.nikiroo.utils.StringUtils; +/** + * Support https://www.theregister.co.uk/. + * + * @author niki + */ public class TheRegister extends BasicSupport { @Override public String getDescription() { @@ -46,17 +50,18 @@ public class TheRegister extends BasicSupport { String date = ""; String details = ""; String body = ""; + String categ = ""; + String author = ""; // nope - String topic = ""; - Element topicElement = article.previousElementSibling(); - if (topicElement != null) { - topic = "[" + topicElement.text().trim() + "] "; + Element categElement = article.previousElementSibling(); + if (categElement != null) { + categ = categElement.text().trim(); } + Element titleElement = article.getElementsByTag("h4").first(); if (titleElement != null) { title = StringUtils.unhtml(titleElement.text()).trim(); } - title = topic + title; Element dateElement = article.getElementsByClass("time_stamp") .first(); @@ -80,8 +85,8 @@ public class TheRegister extends BasicSupport { details += StringUtils.unhtml(detailsElement.text()).trim(); } - list.add(new Story(getType(), id, title, details, intUrl, extUrl, - body)); + list.add(new Story(getType(), id, title, author, date, categ, + details, intUrl, extUrl, body)); } return list; @@ -206,21 +211,4 @@ public class TheRegister extends BasicSupport { } } } - - // Return display date from epoch String, or "" if error - private static String date(String epochString) { - long epoch = 0; - try { - epoch = Long.parseLong(epochString); - } catch (Exception e) { - epoch = 0; - } - - if (epoch > 0) { - return new SimpleDateFormat("dd MMM YYYY").format(new Date( - 1000 * epoch)); - } - - return ""; - } }