Example #1
0
 public static void main(String[] args) {
   if (args.length == 0) {
     gui = new Gui();
     gui.setVisible(true);
   } else if (args.length == 3 || args.length == 4) {
     Main.setBlogName(args[0]);
     Main.load();
     if (args.length == 3) {
       int start, limit;
       try {
         start = Integer.parseInt(args[1]);
         limit = Integer.parseInt(args[2]);
       } catch (Exception e) {
         Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
         Main.status("start_page and end_page must be integers >= 1");
         return;
       }
       Main.run(start, limit);
       Main.save();
     } else if (args.length == 4 && args[3].equals("-hires")) {
       Main.downloadHiRes();
       Main.save();
     } else {
       Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
     }
   } else {
     Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
   }
 }
Example #2
0
 private static void status(String status) {
   if (gui == null) {
     System.out.println(status);
   } else {
     gui.setStatus(status);
   }
 }
Example #3
0
 private static void error(String error) {
   if (gui == null) {
     System.err.println(error);
   } else {
     gui.setStatus(error);
   }
 }
Example #4
0
 public static void downloadHiRes() {
   Main.status("Downloading hi res versions of photos in database.");
   if (gui != null) {
     gui.setProgress(0);
     gui.setMaxProgress(pic_pic_hash.keySet().size());
   }
   int progress = 0;
   for (Picture picture : pic_pic_hash.keySet()) {
     if (!picture.downloaded_hi) {
       tryResUrls(picture);
     }
     if (gui != null) {
       gui.setProgress(progress);
       progress++;
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
     progress++;
   }
   Main.status("Done downloading hi res versions.");
 }
Example #5
0
 public static void run(int start_page, int end_page) {
   if (start_page < 1 || end_page < 1) {
     Main.status("start_page and end_page must be integers >= 1");
     return;
   }
   int progress = 0;
   if (gui != null) {
     gui.setProgress(progress);
   }
   if (end_page >= start_page) {
     if (gui != null) {
       gui.setMaxProgress(end_page - start_page);
     }
     for (int i = start_page; i <= end_page; i++) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   } else {
     if (gui != null) {
       gui.setMaxProgress(start_page - end_page);
     }
     for (int i = start_page; i >= end_page; i--) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
   }
   Main.writeDuplicates();
 }