79bbac09f21f — Andrew@Edwin8 tip 6 years ago
A few fixes, and changing the output format so the links work nicely at CFC.
1 files changed, 9 insertions(+), 6 deletions(-)

M src/main/java/com/civfanatics/downloadtraverser/Main.java
M src/main/java/com/civfanatics/downloadtraverser/Main.java +9 -6
@@ 39,14 39,14 @@ public class Main {
         sites.add("telefragged.com");
         
         try {
-            fw = new FileWriter("D:\\My Documents\\!Documents\\Civilization\\Atomic Gamer\\Civ3GraphicsModpacks.txt");
+            fw = new FileWriter("D:\\My Documents\\!Documents\\Civilization\\Atomic Gamer\\Civ4Downloads.txt");
         }
         catch(IOException ex) {
             System.out.println("IOException");
             System.exit(1);
         }
         
-        traverseFolder(root + "downloads.php?do=cat&id=15", "Civilization III Graphics Modpacks", 0, 1);
+        traverseFolder(root + "downloads.php?do=cat&id=1", "Civilization IV Downloads", 0, 1);
         
         try {
             fw.close();

          
@@ 74,11 74,13 @@ public class Main {
             
             for (Element table : potentialTables) {
                 Elements matches = table.select("a:containsOwn(Rating)");
+                //If it contains the Main link, it's too high-level for us
+                Elements mainMatches = table.select("a:containsOwn(Main");
                 if (matches.size() > 0) {
                     //Grab downloads from this table.  Also will have to grab the Next Page element, if it exists.
                     //Check if there's a page nav.  If so, we'll use that for navving, and use the other table for DL'ing
                     Elements pageNav = table.select("div.pageNav");
-                    if (pageNav.size() == 0) {
+                    if (pageNav.size() == 0 && mainMatches.size() == 0) {
                         System.out.println(spaces + "Found downloads");
                         
                         Elements rows = table.select("tr");

          
@@ 102,7 104,7 @@ public class Main {
                             String description = descSize.substring(0, nbsp);
                             String sizeComments = descSize.substring(nbsp + 8);
                             int semicolon = sizeComments.indexOf(";");
-                            String size = sizeComments.substring(0, semicolon);
+                            //String size = sizeComments.substring(0, semicolon);
                             
                             //Now get author
                             Element author = data.get(2);

          
@@ 132,7 134,7 @@ public class Main {
                             System.out.println("URL : " + url + ", name: " + name);
                         }
                     }
-                    else {
+                    else if (pageNav.size() > 0) {
                         System.out.println(spaces + "Found page nav");
                         //And traverse pages...
                         Elements topPageNavElements = pageNav.first().select("td");

          
@@ 213,7 215,8 @@ public class Main {
                 String location = map.get("Location").get(0);
                 for (String site : sites) {
                     if (location.contains(site)) {
-                        fw.write(download.getName() + " at " + download.getUrl() + " is at " + site + "\n");
+                        String cfcLink = "[url]" + root + download.getUrl() + "[/url]";
+                        fw.write(download.getName() + " at " + cfcLink + " is at " + site + "\n");
                         fw.flush();
                         break;
                     }