diff --git a/pom.xml b/pom.xml index e3aa1ce6..e7698687 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.51 + 1.0.52 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgboxRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgboxRipper.java new file mode 100644 index 00000000..e2e05204 --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgboxRipper.java @@ -0,0 +1,80 @@ +package com.rarchives.ripme.ripper.rippers; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.ui.RipStatusMessage.STATUS; +import com.rarchives.ripme.utils.Utils; + +public class ImgboxRipper extends AlbumRipper { + + private static final String DOMAIN = "imgbox.com", + HOST = "imgbox"; + private static final Logger logger = Logger.getLogger(ImgboxRipper.class); + + public ImgboxRipper(URL url) throws IOException { + super(url); + } + + @Override + public boolean canRip(URL url) { + return url.getHost().endsWith(DOMAIN); + } + + @Override + public URL sanitizeURL(URL url) throws MalformedURLException { + return url; + } + + @Override + public void rip() throws IOException { + logger.info(" Retrieving " + this.url); + sendUpdate(STATUS.LOADING_RESOURCE, url.toExternalForm()); + Document doc = Jsoup.connect(this.url.toExternalForm()) + .userAgent(USER_AGENT) + .get(); + Elements images = doc.select("div.boxed-content > a > img"); + if (images.size() == 0) { + logger.error("No images found at " + this.url); + throw new IOException("No images found at " + this.url); + } + int index = 0; + for (Element image : images) { + index++; + String imageUrl = image.attr("src").replace("s.imgbox.com", "i.imgbox.com"); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(imageUrl), prefix); + } + + waitForThreads(); + } + + @Override + public String getHost() { + return HOST; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("^https?://[wm.]*imgbox\\.com/g/([a-zA-Z0-9]+).*$"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1); + } + throw new MalformedURLException("Expected imgbox.com URL format: " + + "imgbox.com/g/albumid - got " + url + "instead"); + } +} diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index 14f67e70..77c792d0 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -106,6 +106,7 @@ public class MainWindow implements Runnable, RipStatusHandler { private static JCheckBox configAutoupdateCheckbox; private static JCheckBox configPlaySound; private static JCheckBox configSaveOrderCheckbox; + private static JCheckBox configShowPopup; private static TrayIcon trayIcon; private static MenuItem trayMenuMain; @@ -170,6 +171,7 @@ public class MainWindow implements Runnable, RipStatusHandler { Utils.setConfigBoolean("auto.update", configAutoupdateCheckbox.isSelected()); Utils.setConfigBoolean("play.sound", configPlaySound.isSelected()); Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected()); + Utils.setConfigBoolean("download.show_popup", configShowPopup.isSelected()); saveHistory(); Utils.saveConfig(); } @@ -316,6 +318,9 @@ public class MainWindow implements Runnable, RipStatusHandler { configSaveOrderCheckbox = new JCheckBox("Save images in order", Utils.getConfigBoolean("download.save_order", true)); configSaveOrderCheckbox.setHorizontalAlignment(JCheckBox.RIGHT); configSaveOrderCheckbox.setHorizontalTextPosition(JCheckBox.LEFT); + configShowPopup = new JCheckBox("Notification when rip starts", Utils.getConfigBoolean("download.show_popup", false)); + configShowPopup.setHorizontalAlignment(JCheckBox.RIGHT); + configShowPopup.setHorizontalTextPosition(JCheckBox.LEFT); configSaveDirLabel = new JLabel(); try { String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory())); @@ -336,7 +341,8 @@ public class MainWindow implements Runnable, RipStatusHandler { gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc); gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configPlaySound, gbc); gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configSaveOrderCheckbox, gbc); - gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc); + gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configShowPopup, gbc); + gbc.gridy = 9; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc); gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc); gbc.gridy = 0; pane.add(ripPanel, gbc); @@ -699,7 +705,8 @@ public class MainWindow implements Runnable, RipStatusHandler { ripper.setObserver((RipStatusHandler) this); Thread t = new Thread(ripper); t.start(); - if (!mainFrame.isVisible() || !mainFrame.isActive()) { + if (configShowPopup.isSelected() && + (!mainFrame.isVisible() || !mainFrame.isActive())) { mainFrame.toFront(); mainFrame.setAlwaysOnTop(true); trayIcon.displayMessage(mainFrame.getTitle(), "Started ripping " + ripper.getURL().toExternalForm(), MessageType.INFO); diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 2171c582..d5c7ad24 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils; public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.0.51"; + private static final String DEFAULT_VERSION = "1.0.52"; private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String mainFileName = "ripme.jar";