From 7273fd5890478d6ec1f3c566e0c5e4640ab79f15 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Wed, 10 Oct 2018 08:18:51 +0200 Subject: [PATCH] Reddit: ID also use title --- src/be/nikiroo/gofetch/support/Reddit.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 -- 2.27.0