From: Niki Roo Date: Wed, 10 Oct 2018 06:18:51 +0000 (+0200) Subject: Reddit: ID also use title X-Git-Url: http://git.nikiroo.be/?p=gofetch.git;a=commitdiff_plain;h=7273fd5890478d6ec1f3c566e0c5e4640ab79f15 Reddit: ID also use title --- diff --git a/src/be/nikiroo/gofetch/support/Reddit.java b/src/be/nikiroo/gofetch/support/Reddit.java index 278a1a2..2732894 100644 --- a/src/be/nikiroo/gofetch/support/Reddit.java +++ b/src/be/nikiroo/gofetch/support/Reddit.java @@ -59,8 +59,15 @@ public class Reddit extends BasicSupport { @Override protected String getArticleId(Document doc, Element article) { - // Use the date, Luke - return ""; + String date = getArticleDate(doc, article); + String title = getArticleTitle(doc, article); + + String id = (date + "_" + title).replaceAll("[^a-zA-Z0-9_-]", "_"); + if (id.length() > 40) { + id = id.substring(0, 40); + } + + return id; } @Override