X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fsupport%2FSlashdot.java;h=4746cc2eacfb28b41d3983ae6baddd34e5939dd0;hb=b34d1f357b076c1697e381b70cb6ff1bb0278b91;hp=43d35f4afa13281d8565da54e113fab82529f35f;hpb=86d03b2e4fe0a2b53b83e981388394f3c5965f27;p=gofetch.git diff --git a/src/be/nikiroo/gofetch/support/Slashdot.java b/src/be/nikiroo/gofetch/support/Slashdot.java index 43d35f4..4746cc2 100644 --- a/src/be/nikiroo/gofetch/support/Slashdot.java +++ b/src/be/nikiroo/gofetch/support/Slashdot.java @@ -14,6 +14,7 @@ import org.jsoup.select.Elements; import be.nikiroo.gofetch.data.Comment; import be.nikiroo.gofetch.data.Story; +import be.nikiroo.utils.StringUtils; /** * Support https://slashdot.org/. @@ -63,14 +64,38 @@ public class Slashdot extends BasicSupport { details = detailsElements.get(0).text(); } + // details: + // "Posted by AUTHOR on DATE from the further-crackdown dept." + String author = ""; + int pos = details.indexOf(" on "); + if (details.startsWith("Posted by ") && pos >= 0) { + author = details.substring("Posted by ".length(), pos).trim(); + } + pos = details.indexOf(" from the "); + if (pos >= 0) { + details = details.substring(pos).trim(); + } + String body = ""; Element bodyElement = doc.getElementById("text-" + id); if (bodyElement != null) { body = bodyElement.text(); } - list.add(new Story(getType(), id, title.text(), details, intUrl, - extUrl, body)); + String categ = ""; + Element categElement = doc.getElementsByClass("topic").first(); + if (categElement != null) { + categ = StringUtils.unhtml(categElement.text()).trim(); + } + + String date = ""; + Element dateElement = doc.getElementsByTag("time").first(); + if (dateElement != null) { + date = StringUtils.unhtml(dateElement.text()).trim(); + } + + list.add(new Story(getType(), id, title.text(), author, date, + categ, details, intUrl, extUrl, body)); } return list;