Exemplo n.º 1
0
 private static void tryResUrls(Picture picture) {
   String hi_res = "";
   String url = picture.media_url.toString();
   for (String ending : Main.endings) {
     try {
       hi_res = url.replace(url.substring(url.lastIndexOf("_"), url.lastIndexOf(".")), ending);
       URL hi_url = new URL(hi_res);
       File hi_name = Helper.extractMediaFileNameFromURL(hi_url);
       if (hi_name.equals(picture.media_name)) {
         picture.hi_url = hi_url;
         picture.hi_name = hi_name;
         picture.downloaded_hi = true;
         break;
       } else {
         boolean success = Helper.downloadFileFromURLToFileInTemp(hi_url, hi_name);
         if (success) {
           picture.hi_url = hi_url;
           picture.hi_name = hi_name;
           picture.downloaded_hi = true;
           Helper.moveTempImageToStore(hi_name, new File(Main.blogdir, picture.md5_id));
           break;
         }
       }
     } catch (MalformedURLException ex) {
       Main.error(String.format("Attempted hi res url %s is a malformed URL.", hi_res));
     }
   }
 }
Exemplo n.º 2
0
 public static void load() {
   Main.status("Loading databases.");
   File file = new File(blogdir, "picpic.db");
   List<Object> objects = Helper.loadObjectFromFile(file);
   if (objects == null || objects.size() != 1) {
     Main.error("Unable to load database files so creating new database.");
     reset();
   } else {
     Main.post_post_hash = (HashMap<Post, Post>) objects.get(0);
     Main.pic_pic_hash.clear();
     Main.pic_post_hash.clear();
     Main.dup_post_list.clear();
     Main.setupPosts();
   }
   Main.status("Done loading databases.");
 }