From 01448cc9a021a120b10a3436021a00a6ac95f285 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Wed, 15 Aug 2018 05:34:01 -0400 Subject: [PATCH] Added ripper for hdporner --- .../ripme/ripper/rippers/HqpornerRipper.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/HqpornerRipper.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/HqpornerRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/HqpornerRipper.java new file mode 100644 index 00000000..e95467bb --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/HqpornerRipper.java @@ -0,0 +1,94 @@ +package com.rarchives.ripme.ripper.rippers; + +import com.rarchives.ripme.ripper.AbstractSingleFileRipper; +import com.rarchives.ripme.utils.Http; +import org.jsoup.nodes.Document; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.rarchives.ripme.App.logger; + +public class HqpornerRipper extends AbstractSingleFileRipper { + + + public HqpornerRipper(URL url) throws IOException { + super(url); + } + + private String getVideoFromMyDaddycc(String url) { + Pattern p = Pattern.compile("(//[a-zA-Z0-9\\.]+/pub/cid/[a-z0-9]+/1080.mp4)"); + try { + logger.info("Downloading " + url); + Document page = Http.url(url).referrer(url).get(); + Matcher m = p.matcher(page.html()); + logger.info(page.html()); + if (m.find()) { + return m.group(0); + } + + + } catch (IOException e) { + logger.error("Unable to get page with video"); + } + return null; + } + + private String getVideoName() { + try { + String filename = getGID(url); + return filename; + } catch (MalformedURLException e) { + return "1080"; + } + } + + @Override + public String getHost() { + return "hqporner"; + } + + @Override + public String getDomain() { + return "hqporner.com"; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("https?://hqporner.com/hdporn/([a-zA-Z0-9_-]*).html/?$"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1); + } + throw new MalformedURLException("Expected hqporner URL format: " + + "hqporner.com/hdporn/NAME - got " + url + " instead"); + } + + @Override + public Document getFirstPage() throws IOException { + // "url" is an instance field of the superclass + return Http.url(url).get(); + } + + @Override + public List getURLsFromPage(Document doc) { + List result = new ArrayList<>(); + result.add("https:" + getVideoFromMyDaddycc("https:" + doc.select("div.videoWrapper > iframe").attr("src"))); + return result; + } + + @Override + public boolean tryResumeDownload() {return true;} + + @Override + public void downloadURL(URL url, int index) { + addURLToDownload(url, "", "", "", null, getVideoName(), "mp4"); + } + + +}