X-Git-Url: http://git.nikiroo.be/?p=gofetch.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fsupport%2FPipedot.java;h=9ea70ff4bfcb37f2a6c08648857332dfd44282af;hp=edbb8047df8f57b18661ff8b15a0ffb62e0f70f2;hb=c9cffa913fe4ebc5cbe483cc5afe676e6cb54abd;hpb=6a4d14166b93ceb49db09053b9a4cb09703fdea2 diff --git a/src/be/nikiroo/gofetch/support/Pipedot.java b/src/be/nikiroo/gofetch/support/Pipedot.java index edbb804..9ea70ff 100644 --- a/src/be/nikiroo/gofetch/support/Pipedot.java +++ b/src/be/nikiroo/gofetch/support/Pipedot.java @@ -70,9 +70,38 @@ public class Pipedot extends BasicSupport { String details = ""; Elements detailsElements = article.getElementsByTag("div"); if (detailsElements.size() > 0) { - details = detailsElements.get(0).text(); + details = detailsElements.get(0).text().trim(); } + String author = ""; + int pos = details.indexOf("by "); + if (pos >= 0) { + author = details.substring(pos + "by ".length()).trim(); + pos = author.indexOf(" in "); + if (pos >= 0) { + author = author.substring(0, pos).trim(); + } + } + + String categ = ""; + pos = details.indexOf(" in "); + if (pos >= 0) { + categ = details.substring(pos + " in ".length()).trim(); + pos = categ.indexOf(" on "); + if (pos >= 0) { + categ = categ.substring(0, pos).trim(); + } + } + + String date = ""; + Element dateElement = article.getElementsByTag("time").first(); + if (dateElement != null) { + date = date(dateElement.attr("datetime")); + } + + // We already have all the details (date, author, id, categ) + details = ""; + String body = ""; for (Element elem : article.children()) { String tag = elem.tag().toString(); @@ -82,8 +111,8 @@ public class Pipedot extends BasicSupport { } } - list.add(new Story(getType(), id, title.text(), "", "", "", - details, intUrl, extUrl, body)); + list.add(new Story(getType(), id, title.text(), author, date, + categ, details, intUrl, extUrl, body)); } return list;