Skip to content

Commit 8bfae56

Browse files
committed
Vinebox ripper
1 parent 7c63f3a commit 8bfae56

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.rarchives.ripme.ripper.rippers;
2+
3+
import java.io.IOException;
4+
import java.net.MalformedURLException;
5+
import java.net.URL;
6+
import java.util.regex.Matcher;
7+
import java.util.regex.Pattern;
8+
9+
import org.apache.log4j.Logger;
10+
import org.jsoup.HttpStatusException;
11+
import org.jsoup.Jsoup;
12+
import org.jsoup.nodes.Document;
13+
import org.jsoup.nodes.Element;
14+
15+
import com.rarchives.ripme.ripper.AbstractRipper;
16+
17+
public class VineboxRipper extends AbstractRipper {
18+
19+
private static final String DOMAIN = "vinebox.co",
20+
HOST = "vinebox";
21+
private static final Logger logger = Logger.getLogger(VineboxRipper.class);
22+
23+
public VineboxRipper(URL url) throws IOException {
24+
super(url);
25+
}
26+
27+
@Override
28+
public boolean canRip(URL url) {
29+
return url.getHost().endsWith(DOMAIN);
30+
}
31+
32+
@Override
33+
public URL sanitizeURL(URL url) throws MalformedURLException {
34+
Pattern p = Pattern.compile("^https?://(www\\.)?vinebox\\.co/u/([a-zA-Z0-9]{1,}).*$");
35+
Matcher m = p.matcher(url.toExternalForm());
36+
if (!m.matches()) {
37+
throw new MalformedURLException("Expected format: http://vinebox.co/u/USERNAME");
38+
}
39+
return new URL("http://vinebox.co/u/" + m.group(m.groupCount()));
40+
}
41+
42+
@Override
43+
public void rip() throws IOException {
44+
int page = 0;
45+
Document doc;
46+
while (true) {
47+
page++;
48+
String urlPaged = this.url.toExternalForm() + "?page=" + page;
49+
logger.info("[ ] Retrieving " + urlPaged);
50+
try {
51+
doc = Jsoup.connect(urlPaged).get();
52+
} catch (HttpStatusException e) {
53+
logger.debug("Hit end of pages at page " + page, e);
54+
break;
55+
}
56+
for (Element element : doc.select("video")) {
57+
addURLToDownload(new URL(element.attr("src")));
58+
}
59+
try {
60+
Thread.sleep(1000);
61+
} catch (InterruptedException e) {
62+
logger.error("[!] Interrupted while waiting to load next page", e);
63+
break;
64+
}
65+
}
66+
waitForThreads();
67+
}
68+
69+
@Override
70+
public String getHost() {
71+
return HOST;
72+
}
73+
74+
@Override
75+
public String getGID(URL url) throws MalformedURLException {
76+
Pattern p = Pattern.compile("^https?://(www\\.)?vinebox\\.co/u/([a-zA-Z0-9]{1,}).*$");
77+
System.err.println(url);
78+
Matcher m = p.matcher(url.toExternalForm());
79+
if (!m.matches()) {
80+
throw new MalformedURLException("Expected format: http://vinebox.co/u/USERNAME");
81+
}
82+
return m.group(m.groupCount());
83+
}
84+
85+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.rarchives.ripme.tst.ripper.rippers;
2+
3+
import java.io.IOException;
4+
import java.net.URL;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
import com.rarchives.ripme.ripper.rippers.VineboxRipper;
9+
10+
public class VineboxRipperTest extends RippersTest {
11+
12+
public void testVineboxAlbums() throws IOException {
13+
if (false && !DOWNLOAD_CONTENT) {
14+
return;
15+
}
16+
List<URL> contentURLs = new ArrayList<URL>();
17+
contentURLs.add(new URL("http://vinebox.co/u/wiZS1MvkgEo"));
18+
for (URL url : contentURLs) {
19+
try {
20+
VineboxRipper ripper = new VineboxRipper(url);
21+
ripper.rip();
22+
assert(ripper.getWorkingDir().listFiles().length > 1);
23+
deleteDir(ripper.getWorkingDir());
24+
} catch (Exception e) {
25+
e.printStackTrace();
26+
fail("Error while ripping URL " + url + ": " + e.getMessage());
27+
}
28+
}
29+
}
30+
31+
}

0 commit comments

Comments
 (0)