Merge branch 'master' into pichunter

This commit is contained in:
cyian-1756 2017-11-16 18:09:11 -05:00 committed by GitHub
commit d435b1a638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 7 deletions

View File

@ -70,12 +70,12 @@ public class ChanRipper extends AbstractHTMLRipper {
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.warn("Failed to get thread title from " + url); logger.warn("Failed to get thread title from " + url);
} }
return doc.select("title").first().text();
} catch (Exception e) { } catch (Exception e) {
// Fall back to default album naming convention // Fall back to default album naming convention
logger.warn("Failed to get album title from " + url, e); logger.warn("Failed to get album title from " + url, e);
} }
return super.getAlbumTitle(url); // Fall back on the GID
return getHost() + "_" + getGID(url);
} }
@Override @Override
@ -117,6 +117,12 @@ public class ChanRipper extends AbstractHTMLRipper {
if (m.matches()) { if (m.matches()) {
return m.group(1); return m.group(1);
} }
// xchan
p = Pattern.compile("^.*\\.[a-z]{1,3}/board/[a-zA-Z0-9]+/thread/([0-9]+)/?.*$");
m = p.matcher(u);
if (m.matches()) {
return m.group(1);
}
} }
throw new MalformedURLException( throw new MalformedURLException(
@ -211,6 +217,6 @@ public class ChanRipper extends AbstractHTMLRipper {
@Override @Override
public void downloadURL(URL url, int index) { public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index), "", this.url.toString(), null); addURLToDownload(url, getPrefix(index));
} }
} }

View File

@ -0,0 +1,75 @@
package com.rarchives.ripme.ripper.rippers;
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 org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
import com.rarchives.ripme.utils.Http;
public class TheyiffgalleryRipper extends AbstractHTMLRipper {
public TheyiffgalleryRipper(URL url) throws IOException {
super(url);
}
@Override
public String getHost() {
return "theyiffgallery";
}
@Override
public String getDomain() {
return "theyiffgallery.com";
}
@Override
public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("https?://theyiffgallery.com/index\\?/category/(\\d+)");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
}
throw new MalformedURLException("Expected theyiffgallery URL format: " +
"theyiffgallery.com/index?/category/#### - got " + url + " instead");
}
@Override
public Document getFirstPage() throws IOException {
// "url" is an instance field of the superclass
return Http.url(url).get();
}
@Override
public Document getNextPage(Document doc) throws IOException {
String nextPage = doc.select("span.navPrevNext > a").attr("href");
if (nextPage != null && !nextPage.isEmpty() && nextPage.contains("start-")) {
return Http.url("https://theyiffgallery.com/" + nextPage).get();
}
throw new IOException("No more pages");
}
@Override
public List<String> getURLsFromPage(Document doc) {
List<String> result = new ArrayList<>();
for (Element el : doc.select("ul.thumbnails > li.gdthumb")) {
String imageSource = el.select("a > img").attr("src");
imageSource = imageSource.replaceAll("_data/i", "");
imageSource = imageSource.replaceAll("-\\w\\w_\\w\\d+x\\d+", "");
result.add("https://theyiffgallery.com" + imageSource);
}
return result;
}
@Override
public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index));
}
}

View File

@ -29,6 +29,8 @@ import com.rarchives.ripme.ripper.rippers.VineRipper;
import com.rarchives.ripme.ripper.rippers.VkRipper; import com.rarchives.ripme.ripper.rippers.VkRipper;
import com.rarchives.ripme.ripper.rippers.XhamsterRipper; import com.rarchives.ripme.ripper.rippers.XhamsterRipper;
import com.rarchives.ripme.ripper.rippers.PichunterRipper; import com.rarchives.ripme.ripper.rippers.PichunterRipper;
import com.rarchives.ripme.ripper.rippers.TheyiffgalleryRipper;
/** /**
* Simple test cases for various rippers. * Simple test cases for various rippers.
@ -220,6 +222,11 @@ public class BasicRippersTest extends RippersTest {
testRipper(ripper); testRipper(ripper);
} }
public void testTheyiffgallery() throws IOException {
AbstractRipper ripper = new TheyiffgalleryRipper(new URL("https://theyiffgallery.com/index?/category/4303"));
testRipper(ripper);
}
/* /*
public void testSankakuChanRip() throws IOException { public void testSankakuChanRip() throws IOException {
AbstractRipper ripper = new SankakuComplexRipper(new URL("https://chan.sankakucomplex.com/?tags=cleavage")); AbstractRipper ripper = new SankakuComplexRipper(new URL("https://chan.sankakucomplex.com/?tags=cleavage"));
@ -278,8 +285,8 @@ public class BasicRippersTest extends RippersTest {
testRipper(ripper); testRipper(ripper);
} }
public void testXhamsterAlbums() throws IOException { // public void testXhamsterAlbums() throws IOException {
XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.com/photos/gallery/sexy-preggo-girls-9026608")); // XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.com/photos/gallery/sexy-preggo-girls-9026608"));
testRipper(ripper); // testRipper(ripper);
} // }
} }