From eb23e4fa82c415a35c3b8393d7c30b5e111b3e55 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Tue, 21 Oct 2014 01:10:09 -0700 Subject: [PATCH] 1.0.87 - Motherless video ripper --- pom.xml | 2 +- .../rarchives/ripme/ripper/VideoRipper.java | 8 ++- .../ripper/rippers/MotherlessRipper.java | 5 ++ .../rippers/video/MotherlessVideoRipper.java | 68 +++++++++++++++++++ .../com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/video/MotherlessVideoRipper.java diff --git a/pom.xml b/pom.xml index d2e52897..5fae5e2d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.86 + 1.0.87 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/VideoRipper.java b/src/main/java/com/rarchives/ripme/ripper/VideoRipper.java index 2e1ae173..f1263673 100644 --- a/src/main/java/com/rarchives/ripme/ripper/VideoRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/VideoRipper.java @@ -40,7 +40,7 @@ public abstract class VideoRipper extends AbstractRipper { } @Override - public void addURLToDownload(URL url, File saveAs) { + public boolean addURLToDownload(URL url, File saveAs) { if (Utils.getConfigBoolean("urls_only.save", false)) { // Output URL to file String urlFile = this.workingDir + File.separator + "urls.txt"; @@ -53,16 +53,18 @@ public abstract class VideoRipper extends AbstractRipper { observer.update(this, msg); } catch (IOException e) { logger.error("Error while writing to " + urlFile, e); + return false; } } else { threadPool.addThread(new DownloadVideoThread(url, saveAs, this)); } + return true; } @Override - public void addURLToDownload(URL url, File saveAs, String referrer, Map cookies) { - addURLToDownload(url, saveAs); + public boolean addURLToDownload(URL url, File saveAs, String referrer, Map cookies) { + return addURLToDownload(url, saveAs); } @Override 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 f98bfd17..91c38bed 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/MotherlessRipper.java @@ -29,6 +29,11 @@ public class MotherlessRipper extends AlbumRipper { @Override public boolean canRip(URL url) { + try { + getGID(url); + } catch (Exception e) { + return false; + } return url.getHost().endsWith(DOMAIN); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/video/MotherlessVideoRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/video/MotherlessVideoRipper.java new file mode 100644 index 00000000..275c6ba5 --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/video/MotherlessVideoRipper.java @@ -0,0 +1,68 @@ +package com.rarchives.ripme.ripper.rippers.video; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.rarchives.ripme.ripper.VideoRipper; +import com.rarchives.ripme.utils.Http; +import com.rarchives.ripme.utils.Utils; + +public class MotherlessVideoRipper extends VideoRipper { + + private static final String HOST = "motherless"; + + public MotherlessVideoRipper(URL url) throws IOException { + super(url); + } + + @Override + public String getHost() { + return HOST; + } + + @Override + public boolean canRip(URL url) { + Pattern p = Pattern.compile("^https?://[wm.]*motherless\\.com/[A-Z0-9]+.*$"); + Matcher m = p.matcher(url.toExternalForm()); + return m.matches(); + } + + @Override + public URL sanitizeURL(URL url) throws MalformedURLException { + return url; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("^https?://[wm.]*motherless\\.com/([A-Z0-9]+).*$"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1); + } + + throw new MalformedURLException( + "Expected motherless format:" + + "motherless.com/####" + + " Got: " + url); + } + + @Override + public void rip() throws IOException { + logger.info(" Retrieving " + this.url); + String html = Http.url(this.url).get().toString(); + if (html.contains("__fileurl = '")) { + System.err.println("WTF"); + } + List vidUrls = Utils.between(html, "__fileurl = '", "';"); + if (vidUrls.size() == 0) { + throw new IOException("Could not find video URL at " + url); + } + String vidUrl = vidUrls.get(0); + addURLToDownload(new URL(vidUrl), HOST + "_" + getGID(this.url)); + waitForThreads(); + } +} \ 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 20d76348..c97d2942 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.86"; + private static final String DEFAULT_VERSION = "1.0.87"; 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";