v1.2.8 - Option to prefer .MP4 over .GIF in imgur ripper.

Closes #266
This commit is contained in:
4pr0n 2015-12-24 13:40:04 -08:00
parent bd70b6f4dd
commit b9d5347262
4 changed files with 29 additions and 5 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId> <groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId> <artifactId>ripme</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.7</version> <version>1.2.8</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -212,11 +212,15 @@ public class ImgurRipper extends AlbumRipper {
int imagesLength = images.length(); int imagesLength = images.length();
for (int i = 0; i < imagesLength; i++) { for (int i = 0; i < imagesLength; i++) {
JSONObject image = images.getJSONObject(i); JSONObject image = images.getJSONObject(i);
String ext = image.getString("ext");
if (ext.equals(".gif") && Utils.getConfigBoolean("prefer.mp4", false)) {
ext = ".mp4";
}
URL imageURL = new URL( URL imageURL = new URL(
// CDN url is provided elsewhere in the document // CDN url is provided elsewhere in the document
"http://i.imgur.com/" "http://i.imgur.com/"
+ image.get("hash") + image.get("hash")
+ image.get("ext")); + ext);
ImgurImage imgurImage = new ImgurImage(imageURL, ImgurImage imgurImage = new ImgurImage(imageURL,
image.getString("title"), image.getString("title"),
image.getString("description")); image.getString("description"));
@ -239,12 +243,16 @@ public class ImgurRipper extends AlbumRipper {
int imagesLength = images.length(); int imagesLength = images.length();
for (int i = 0; i < imagesLength; i++) { for (int i = 0; i < imagesLength; i++) {
JSONObject image = images.getJSONObject(i); JSONObject image = images.getJSONObject(i);
String ext = image.getString("ext");
if (ext.equals(".gif") && Utils.getConfigBoolean("prefer.mp4", false)) {
ext = ".mp4";
}
URL imageURL = new URL( URL imageURL = new URL(
"http://i.imgur.com/" "http://i.imgur.com/"
+ image.getString("hash") + image.getString("hash")
+ image.getString("ext")); + ext);
ImgurImage imgurImage = new ImgurImage(imageURL); ImgurImage imgurImage = new ImgurImage(imageURL);
imgurImage.extension = image.getString("ext"); imgurImage.extension = ext;
imgurAlbum.addImage(imgurImage); imgurAlbum.addImage(imgurImage);
} }
return imgurAlbum; return imgurAlbum;
@ -280,6 +288,9 @@ public class ImgurRipper extends AlbumRipper {
logger.error("[!] Unable to find image in div: " + thumb.toString()); logger.error("[!] Unable to find image in div: " + thumb.toString());
continue; continue;
} }
if (image.endsWith(".gif") && Utils.getConfigBoolean("prefer.mp4", false)) {
image = image.replace(".gif", ".mp4");
}
ImgurImage imgurImage = new ImgurImage(new URL(image)); ImgurImage imgurImage = new ImgurImage(new URL(image));
imgurAlbum.addImage(imgurImage); imgurAlbum.addImage(imgurImage);
} }

View File

@ -137,6 +137,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
private static JCheckBox configSaveAlbumTitles; private static JCheckBox configSaveAlbumTitles;
private static JCheckBox configClipboardAutorip; private static JCheckBox configClipboardAutorip;
private static JCheckBox configSaveDescriptions; private static JCheckBox configSaveDescriptions;
private static JCheckBox configPreferMp4;
private static TrayIcon trayIcon; private static TrayIcon trayIcon;
private static MenuItem trayMenuMain; private static MenuItem trayMenuMain;
@ -210,6 +211,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
Utils.setConfigBoolean("album_titles.save", configSaveAlbumTitles.isSelected()); Utils.setConfigBoolean("album_titles.save", configSaveAlbumTitles.isSelected());
Utils.setConfigBoolean("clipboard.autorip", configClipboardAutorip.isSelected()); Utils.setConfigBoolean("clipboard.autorip", configClipboardAutorip.isSelected());
Utils.setConfigBoolean("descriptions.save", configSaveDescriptions.isSelected()); Utils.setConfigBoolean("descriptions.save", configSaveDescriptions.isSelected());
Utils.setConfigBoolean("prefer.mp4", configPreferMp4.isSelected());
saveHistory(); saveHistory();
Utils.saveConfig(); Utils.saveConfig();
} }
@ -462,6 +464,9 @@ public class MainWindow implements Runnable, RipStatusHandler {
configSaveDescriptions = new JCheckBox("Save descriptions", Utils.getConfigBoolean("descriptions.save", true)); configSaveDescriptions = new JCheckBox("Save descriptions", Utils.getConfigBoolean("descriptions.save", true));
configSaveDescriptions.setHorizontalAlignment(JCheckBox.RIGHT); configSaveDescriptions.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveDescriptions.setHorizontalTextPosition(JCheckBox.LEFT); configSaveDescriptions.setHorizontalTextPosition(JCheckBox.LEFT);
configPreferMp4 = new JCheckBox("Prefer MP4 over GIF", Utils.getConfigBoolean("prefer.mp4", false));
configPreferMp4.setHorizontalAlignment(JCheckBox.RIGHT);
configPreferMp4.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveDirLabel = new JLabel(); configSaveDirLabel = new JLabel();
try { try {
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory())); String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
@ -489,6 +494,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configClipboardAutorip, gbc); gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configClipboardAutorip, gbc);
gbc.gridx = 1; configurationPanel.add(configSaveAlbumTitles, gbc); gbc.gridx = 1; configurationPanel.add(configSaveAlbumTitles, gbc);
gbc.gridy = 9; gbc.gridx = 0; configurationPanel.add(configSaveDescriptions, gbc); gbc.gridy = 9; gbc.gridx = 0; configurationPanel.add(configSaveDescriptions, gbc);
gbc.gridx = 1; configurationPanel.add(configPreferMp4, gbc);
gbc.gridy =10; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc); gbc.gridy =10; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc); gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
@ -750,6 +756,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
Utils.configureLogger(); Utils.configureLogger();
} }
}); });
configPreferMp4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
Utils.setConfigBoolean("prefer.mp4", configPreferMp4.isSelected());
Utils.configureLogger();
}
});
queueListModel.addListDataListener(new ListDataListener() { queueListModel.addListDataListener(new ListDataListener() {
@Override @Override
public void intervalAdded(ListDataEvent arg0) { public void intervalAdded(ListDataEvent arg0) {

View File

@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
public class UpdateUtils { public class UpdateUtils {
private static final Logger logger = Logger.getLogger(UpdateUtils.class); private static final Logger logger = Logger.getLogger(UpdateUtils.class);
private static final String DEFAULT_VERSION = "1.2.7"; private static final String DEFAULT_VERSION = "1.2.8";
private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar"; private static final String mainFileName = "ripme.jar";