Reddit: ID also use title
authorNiki Roo <roo.niki@gmail.com>
Wed, 10 Oct 2018 06:18:51 +0000 (08:18 +0200)
committerNiki Roo <roo.niki@gmail.com>
Wed, 10 Oct 2018 06:18:51 +0000 (08:18 +0200)
src/be/nikiroo/gofetch/support/Reddit.java

index 278a1a21a18898975d2a377ab4b6e26e2df7bf5d..2732894a4fe77168b21ccaeda8cb92d562382a95 100644 (file)
@@ -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