Fix bug due to 'id'-handling change
authorNiki Roo <niki@nikiroo.be>
Fri, 7 Sep 2018 07:09:58 +0000 (09:09 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 7 Sep 2018 07:09:58 +0000 (09:09 +0200)
src/be/nikiroo/gofetch/support/BasicSupport.java
src/be/nikiroo/gofetch/support/LWN.java
src/be/nikiroo/gofetch/support/Phoronix.java
src/be/nikiroo/gofetch/support/Slashdot.java

index 80fe5d236d31c2379856a8245f09e80b4cfeab79..972852333fed4707ecd9ed2812e45c7f2ee00f8b 100644 (file)
@@ -32,7 +32,7 @@ import be.nikiroo.utils.StringUtils;
  */
 public abstract class BasicSupport {
        /** The downloader to use for all websites. */
-       protected static Downloader downloader = new Downloader("gofetcher");
+       static protected Downloader downloader = new Downloader("gofetcher");
 
        static private String preselector;
 
@@ -106,7 +106,11 @@ public abstract class BasicSupport {
                                        continue;
                                }
 
-                               if (id.isEmpty()) {
+                               if (!id.isEmpty()) {
+                                       while (id.length() < 10) {
+                                               id = "0" + id;
+                                       }
+                               } else {
                                        id = date.replace(":", "_").replace("+", "_");
                                }
 
index eac12e5c239c37aa921d2945333d1b7fbc4c4e9a..144fdc90514039656168bf41fef8b850a027d4fe 100644 (file)
@@ -53,12 +53,7 @@ public class LWN extends BasicSupport {
 
        @Override
        protected String getArticleId(Document doc, Element article) {
-               String id = getArticleIntUrl(doc, article).replaceAll("[^0-9]", "");
-               while (id.length() < 10) {
-                       id = "0" + id;
-               }
-
-               return id;
+               return getArticleIntUrl(doc, article).replaceAll("[^0-9]", "");
        }
 
        @Override
index 5338cd639ff2ebe2435834336af1232320827ebf..8f257fbb0d7b3a36d17a8601a61fc3bfd3de6149 100644 (file)
@@ -45,9 +45,6 @@ class Phoronix extends BasicSupport {
                                        id = id.substring(pos + 1);
                                }
 
-                               while (id.length() < 10) {
-                                       id = "0" + id;
-                               }
                                return id;
                        }
                }
index 6fb51a6dd32cb5f0bd37692165560ca1fdb915b9..43ce13d023ff498d3a759e9eac884f351d10e79a 100644 (file)
@@ -45,10 +45,6 @@ public class Slashdot extends BasicSupport {
                                id = id.substring("title-".length());
                        }
 
-                       while (id.length() < 10) {
-                               id = "0" + id;
-                       }
-
                        return id;
                }