diff --git a/pom.xml b/pom.xml index a52c6244..d3461f4b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.45 + 1.0.46 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ButttoucherRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ButttoucherRipper.java index e5b09e6e..49c0555a 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ButttoucherRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ButttoucherRipper.java @@ -12,6 +12,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class ButttoucherRipper extends AlbumRipper { @@ -59,7 +60,11 @@ public class ButttoucherRipper extends AlbumRipper { String smallImage = thumb.attr("src"); String image = smallImage.replace("m.", "."); index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ChanRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ChanRipper.java index 4a65edc2..7f194e79 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ChanRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ChanRipper.java @@ -14,6 +14,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class ChanRipper extends AlbumRipper { @@ -114,7 +115,11 @@ public class ChanRipper extends AlbumRipper { continue; } index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); attempted.add(image); } } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java index f8f3046b..2720770a 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java @@ -52,6 +52,7 @@ public class DeviantartRipper extends AlbumRipper { int index = 0; String nextURL = this.url.toExternalForm(); + // Iterate over every page while (nextURL != null) { logger.info(" Retrieving " + nextURL); @@ -60,6 +61,7 @@ public class DeviantartRipper extends AlbumRipper { .userAgent(USER_AGENT) .get(); + // Iterate over all thumbnails for (Element thumb : doc.select("div.zones-container a.thumb")) { if (isStopped()) { break; @@ -68,6 +70,7 @@ public class DeviantartRipper extends AlbumRipper { if (img.attr("transparent").equals("false")) { continue; // a.thumbs to other albums are invisible } + index++; String fullSize = null; @@ -80,6 +83,7 @@ public class DeviantartRipper extends AlbumRipper { continue; } } + try { URL fullsizeURL = new URL(fullSize); String imageId = fullSize.substring(fullSize.lastIndexOf('-') + 1); @@ -98,6 +102,8 @@ public class DeviantartRipper extends AlbumRipper { logger.error("[!] Interrupted while waiting for page to load", e); break; } + + // Find the next page nextURL = null; for (Element nextButton : doc.select("a.away")) { if (nextButton.attr("href").contains("offset=" + index)) { @@ -111,6 +117,11 @@ public class DeviantartRipper extends AlbumRipper { waitForThreads(); } + /** + * Convert alpha-numeric string into a corresponding number + * @param alpha String to convert + * @return Numeric representation of 'alpha' + */ public static long alphaToLong(String alpha) { long result = 0; for (int i = 0; i < alpha.length(); i++) { @@ -119,6 +130,12 @@ public class DeviantartRipper extends AlbumRipper { return result; } + /** + * Convert character at index in a string 'text' to numeric form (base-36) + * @param text Text to retrieve the character from + * @param index Index of the desired character + * @return Number representing character at text[index] + */ private static int charToInt(String text, int index) { char c = text.charAt(text.length() - index - 1); c = Character.toLowerCase(c); @@ -127,6 +144,13 @@ public class DeviantartRipper extends AlbumRipper { return number; } + /** + * Tries to get full size image from thumbnail URL + * @param thumb Thumbnail URL + * @param throwException Whether or not to throw exception when full size image isn't found + * @return Full-size image URL + * @throws Exception If it can't find the full-size URL + */ public static String thumbToFull(String thumb, boolean throwException) throws Exception { thumb = thumb.replace("http://th", "http://fc"); List fields = new ArrayList(Arrays.asList(thumb.split("/"))); @@ -146,6 +170,14 @@ public class DeviantartRipper extends AlbumRipper { return result.toString(); } + /** + * If largest resolution for image at 'thumb' is found, starts downloading + * and returns null. + * If it finds a larger resolution on another page, returns the image URL. + * @param thumb Thumbnail URL + * @param page Page the thumbnail is retrieved from + * @return Highest-resolution version of the image based on thumbnail URL and the page. + */ public String smallToFull(String thumb, String page) { try { Response resp = Jsoup.connect(page) @@ -159,10 +191,14 @@ public class DeviantartRipper extends AlbumRipper { throw new IOException("no download page found"); } String fsimage = els.get(0).attr("href"); - String imageId = fsimage.substring(fsimage.lastIndexOf('-') + 1); - imageId = imageId.substring(0, imageId.indexOf('.')); - long imageIdLong = alphaToLong(imageId); - addURLToDownload(new URL(fsimage), String.format("%010d_", imageIdLong), "", page, cookies); + + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + String imageId = fsimage.substring(fsimage.lastIndexOf('-') + 1); + imageId = imageId.substring(0, imageId.indexOf('.')); + prefix = String.format("%010d_", alphaToLong(imageId)); + } + addURLToDownload(new URL(fsimage), prefix, "", page, cookies); return null; } catch (IOException ioe) { try { diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java index 0a96d384..87ab1901 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DrawcrowdRipper.java @@ -14,6 +14,7 @@ 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 DrawcrowdRipper extends AlbumRipper { @@ -76,7 +77,11 @@ public class DrawcrowdRipper extends AlbumRipper { .replaceAll("/medium/", "/large/") .replaceAll("/small/", "/large/"); index++; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } Elements loadMore = albumDoc.select("a#load-more"); if (loadMore.size() == 0) { diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/EHentaiRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/EHentaiRipper.java index 2123f039..67b9bdf9 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/EHentaiRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/EHentaiRipper.java @@ -14,6 +14,7 @@ import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class EHentaiRipper extends AlbumRipper { private static final String DOMAIN = "g.e-hentai.org", HOST = "e-hentai"; @@ -98,12 +99,19 @@ public class EHentaiRipper extends AlbumRipper { if (m.matches()) { // Manually discover filename from URL String savePath = this.workingDir + File.separator; - savePath += String.format("%03d_%s", index + 1, m.group(1)); + if (Utils.getConfigBoolean("download.save_order", true)) { + savePath += String.format("%03d_", index + 1); + } + savePath += m.group(1); addURLToDownload(new URL(imgsrc), new File(savePath)); } else { // Provide prefix and let the AbstractRipper "guess" the filename - addURLToDownload(new URL(imgsrc), String.format("%03d_", index + 1)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index + 1); + } + addURLToDownload(new URL(imgsrc), prefix); } String href = a.attr("href"); diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java index b0ed61b2..ac800d3a 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java @@ -13,6 +13,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class EightmusesRipper extends AlbumRipper { @@ -53,10 +54,13 @@ public class EightmusesRipper extends AlbumRipper { if (image.startsWith("//")) { image = "http:" + image; } - //image = image.replace(" ", "%20"); - URL imageURL = new URL(image); index += 1; - addURLToDownload(imageURL, String.format("%03d_", index)); + URL imageURL = new URL(image); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(imageURL, prefix); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java index 8fed3bc8..b92f955f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java @@ -246,7 +246,11 @@ public class FlickrRipper extends AlbumRipper { return; } else { - String prefix = String.format("%03d_%s_", index, Utils.filesystemSafe(title)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + prefix += Utils.filesystemSafe(title); synchronized (flickrThreadPool) { addURLToDownload(new URL(fullsizeImages.get(0).attr("src")), prefix); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagearnRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagearnRipper.java index c08b7167..b12b0e93 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagearnRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagearnRipper.java @@ -12,6 +12,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class ImagearnRipper extends AlbumRipper { @@ -67,7 +68,11 @@ public class ImagearnRipper extends AlbumRipper { String image = thumb.attr("src"); image = image.replaceAll("thumbs[0-9]*\\.imagearn\\.com/", "img.imagearn.com/imags/"); index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java index c241903e..1305f2ea 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java @@ -13,6 +13,7 @@ import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; import com.rarchives.ripme.ui.RipStatusMessage.STATUS; +import com.rarchives.ripme.utils.Utils; public class ImagefapRipper extends AlbumRipper { @@ -110,7 +111,11 @@ public class ImagefapRipper extends AlbumRipper { "http://x.*.fap.to/images/thumb/", "http://fap.to/images/full/"); index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } String nextURL = null; for (Element a : albumDoc.select("a.link3")) { diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java index f534272f..5adfc42f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java @@ -129,7 +129,10 @@ public class ImgurRipper extends AlbumRipper { subdirFile.mkdirs(); } index += 1; - saveAs += String.format("%03d_%s", index, imgurImage.getSaveAs()); + if (Utils.getConfigBoolean("download.save_order", true)) { + saveAs += String.format("%03d_", index); + } + saveAs += imgurImage.getSaveAs(); addURLToDownload(imgurImage.url, new File(saveAs)); } } @@ -279,7 +282,11 @@ public class ImgurRipper extends AlbumRipper { imagesFound++; JSONObject image = images.getJSONObject(i); String imageUrl = "http://i.imgur.com/" + image.getString("hash") + image.getString("ext"); - addURLToDownload(new URL(imageUrl), String.format("%03d_", imagesFound)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", imagesFound); + } + addURLToDownload(new URL(imageUrl), prefix); } if (imagesFound >= imagesTotal) { break; diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/IrarchivesRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/IrarchivesRipper.java index 94197f77..25312480 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/IrarchivesRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/IrarchivesRipper.java @@ -75,7 +75,10 @@ public class IrarchivesRipper extends AlbumRipper { int albumIndex = 0; for (ImgurImage image : album.images) { albumIndex++; - String saveAs = String.format("%s-%03d_", post.getString("hexid"), albumIndex); + String saveAs = String.format("%s-", post.getString("hexid")); + if (Utils.getConfigBoolean("download.save_order", true)) { + saveAs += String.format("%03d_", albumIndex); + } addURLToDownload(image.url, saveAs); } } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/KinkyshareRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/KinkyshareRipper.java index dade912d..b28faf21 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/KinkyshareRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/KinkyshareRipper.java @@ -12,6 +12,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class KinkyshareRipper extends AlbumRipper { @@ -67,8 +68,12 @@ public class KinkyshareRipper extends AlbumRipper { if (image.startsWith("/")) { image = "http://kinkyshare.com" + image; } - index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + index += 1; + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/MinusRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/MinusRipper.java index 90e0fb35..d9e0fc08 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/MinusRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/MinusRipper.java @@ -176,7 +176,11 @@ public class MinusRipper extends AlbumRipper { String image = "http://i.minus.com/i" + item.getString("id") + extension; - addURLToDownload(new URL(image), String.format("%03d_", i + 1), subdir); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", i + 1); + } + addURLToDownload(new URL(image), prefix, subdir); } } } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ModelmayhemRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ModelmayhemRipper.java index d191c70f..c17dea2e 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ModelmayhemRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ModelmayhemRipper.java @@ -18,6 +18,7 @@ import org.jsoup.nodes.Document; import com.rarchives.ripme.ripper.AlbumRipper; import com.rarchives.ripme.ui.RipStatusMessage.STATUS; +import com.rarchives.ripme.utils.Utils; public class ModelmayhemRipper extends AlbumRipper { @@ -105,7 +106,11 @@ public class ModelmayhemRipper extends AlbumRipper { logger.info("Got empty image for " + picture.toString(2)); continue; } - addURLToDownload(new URL(bigImage), String.format("%03d_", i + 1)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", i + 1); + } + addURLToDownload(new URL(bigImage), prefix); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java index b40765fd..77045195 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java @@ -13,6 +13,7 @@ import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; import com.rarchives.ripme.ripper.DownloadThreadPool; +import com.rarchives.ripme.utils.Utils; public class MotherlessRipper extends AlbumRipper { @@ -121,7 +122,11 @@ public class MotherlessRipper extends AlbumRipper { Matcher m = p.matcher(doc.outerHtml()); if (m.matches()) { String file = m.group(1); - addURLToDownload(new URL(file), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(file), prefix); } else { logger.warn("[!] could not find '__fileurl' at " + url); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java index e12d894d..d234a604 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java @@ -192,7 +192,11 @@ public class RedditRipper extends AlbumRipper { addURLToDownload(urls.get(0), id + "-"); } else if (urls.size() > 1) { for (int i = 0; i < urls.size(); i++) { - addURLToDownload(urls.get(i), id + String.format("-%03d-", i + 1)); + String prefix = id + "-"; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix += String.format("%03d-", i + 1); + } + addURLToDownload(urls.get(i), prefix); } } } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/TeenplanetRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/TeenplanetRipper.java index d383b933..ea67b908 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/TeenplanetRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/TeenplanetRipper.java @@ -13,6 +13,7 @@ import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class TeenplanetRipper extends AlbumRipper { @@ -82,7 +83,11 @@ public class TeenplanetRipper extends AlbumRipper { "/thumbs/", "/"); index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/VkRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/VkRipper.java index 9af65715..4c2ddf5b 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/VkRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/VkRipper.java @@ -19,6 +19,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class VkRipper extends AlbumRipper { @@ -83,7 +84,11 @@ public class VkRipper extends AlbumRipper { int vidid = jsonVideo.getInt(1); String videoURL = com.rarchives.ripme.ripper.rippers.video.VkRipper.getVideoURLAtPage( "http://vk.com/video" + oid + "_" + vidid); - addURLToDownload(new URL(videoURL), String.format("%03d_", i + 1)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", i + 1); + } + addURLToDownload(new URL(videoURL), prefix); try { Thread.sleep(500); } catch (InterruptedException e) { diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java index 5f05ee64..5f12bead 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java @@ -12,6 +12,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.utils.Utils; public class XhamsterRipper extends AlbumRipper { @@ -52,7 +53,11 @@ public class XhamsterRipper extends AlbumRipper { "_160\\.", "_1000."); index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); + String prefix = ""; + if (Utils.getConfigBoolean("download.save_order", true)) { + prefix = String.format("%03d_", index); + } + addURLToDownload(new URL(image), prefix); } nextURL = null; for (Element element : doc.select("a.last")) { diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index 2b448548..899d1b8d 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -105,6 +105,7 @@ public class MainWindow implements Runnable, RipStatusHandler { private static JTextField configRetriesText; private static JCheckBox configAutoupdateCheckbox; private static JCheckBox configPlaySound; + private static JCheckBox configSaveOrderCheckbox; private static TrayIcon trayIcon; private static MenuItem trayMenuMain; @@ -168,6 +169,7 @@ public class MainWindow implements Runnable, RipStatusHandler { Utils.setConfigBoolean("clipboard.autorip", ClipboardUtils.getClipboardAutoRip()); Utils.setConfigBoolean("auto.update", configAutoupdateCheckbox.isSelected()); Utils.setConfigBoolean("play.sound", configPlaySound.isSelected()); + Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected()); saveHistory(); Utils.saveConfig(); } @@ -310,6 +312,9 @@ public class MainWindow implements Runnable, RipStatusHandler { configPlaySound = new JCheckBox("Sound when rip completes", Utils.getConfigBoolean("play.sound", false)); configPlaySound.setHorizontalAlignment(JCheckBox.RIGHT); configPlaySound.setHorizontalTextPosition(JCheckBox.LEFT); + configSaveOrderCheckbox = new JCheckBox("Save images in order", Utils.getConfigBoolean("download.save_order", true)); + configSaveOrderCheckbox.setHorizontalAlignment(JCheckBox.RIGHT); + configSaveOrderCheckbox.setHorizontalTextPosition(JCheckBox.LEFT); configSaveDirLabel = new JLabel(); try { String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory())); @@ -329,7 +334,8 @@ public class MainWindow implements Runnable, RipStatusHandler { gbc.gridx = 1; configurationPanel.add(configRetriesText, gbc); 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(configSaveDirLabel, gbc); + gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configSaveOrderCheckbox, gbc); + gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc); gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc); gbc.gridy = 0; pane.add(ripPanel, gbc); @@ -487,6 +493,12 @@ public class MainWindow implements Runnable, RipStatusHandler { Utils.setConfigBoolean("file.overwrite", configOverwriteCheckbox.isSelected()); } }); + configSaveOrderCheckbox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected()); + } + }); } private void setupTrayIcon() { @@ -647,6 +659,7 @@ public class MainWindow implements Runnable, RipStatusHandler { if (!logPanel.isVisible()) { optionLog.doClick(); } + urlString = urlString.trim(); if (urlString.toLowerCase().startsWith("gonewild:")) { urlString = "http://gonewild.com/user/" + urlString.substring(urlString.indexOf(':') + 1); } @@ -823,7 +836,7 @@ public class MainWindow implements Runnable, RipStatusHandler { } public static void ripAlbumStatic(String url) { - ripTextfield.setText(url); + ripTextfield.setText(url.trim()); ripButton.doClick(); } } \ No newline at end of file diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 86602917..3a42b458 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.45"; + private static final String DEFAULT_VERSION = "1.0.46"; 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"; diff --git a/src/main/resources/rip.properties b/src/main/resources/rip.properties index 020c464f..5a2c0206 100644 --- a/src/main/resources/rip.properties +++ b/src/main/resources/rip.properties @@ -21,4 +21,6 @@ gw.api = gonewild twitter.max_requests = 10 -clipboard.autorip = false \ No newline at end of file +clipboard.autorip = false + +download.save_order = true