Merge pull request #702 from cyian-1756/redditVideoFix
Reddit ripper can now rip videos from v.redd.it
This commit is contained in:
commit
aaaa75b134
@ -17,6 +17,10 @@ import com.rarchives.ripme.ui.UpdateUtils;
|
|||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
import com.rarchives.ripme.utils.RipUtils;
|
import com.rarchives.ripme.utils.RipUtils;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
|
||||||
|
import javax.swing.text.Document;
|
||||||
|
import javax.swing.text.Element;
|
||||||
|
|
||||||
public class RedditRipper extends AlbumRipper {
|
public class RedditRipper extends AlbumRipper {
|
||||||
|
|
||||||
@ -179,6 +183,32 @@ public class RedditRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private URL parseRedditVideoMPD(String vidURL) {
|
||||||
|
org.jsoup.nodes.Document doc = null;
|
||||||
|
try {
|
||||||
|
doc = Http.url(vidURL + "/DASHPlaylist.mpd").ignoreContentType().get();
|
||||||
|
int largestHeight = 0;
|
||||||
|
String baseURL = null;
|
||||||
|
// Loops over all the videos and finds the one with the largest height and sets baseURL to the base url of that video
|
||||||
|
for (org.jsoup.nodes.Element e : doc.select("MPD > Period > AdaptationSet > Representation")) {
|
||||||
|
String height = e.attr("height");
|
||||||
|
if (height.equals("")) {
|
||||||
|
height = "0";
|
||||||
|
}
|
||||||
|
if (largestHeight < Integer.parseInt(height)) {
|
||||||
|
largestHeight = Integer.parseInt(height);
|
||||||
|
baseURL = doc.select("MPD > Period > AdaptationSet > Representation[height=" + height + "]").select("BaseURL").text();
|
||||||
|
}
|
||||||
|
LOGGER.info("H " + e.attr("height") + " V " + e.attr("width"));
|
||||||
|
}
|
||||||
|
return new URL(vidURL + "/" + baseURL);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void handleURL(String theUrl, String id) {
|
private void handleURL(String theUrl, String id) {
|
||||||
URL originalURL;
|
URL originalURL;
|
||||||
try {
|
try {
|
||||||
@ -198,6 +228,11 @@ public class RedditRipper extends AlbumRipper {
|
|||||||
savePath += id + "-" + m.group(1) + ".jpg";
|
savePath += id + "-" + m.group(1) + ".jpg";
|
||||||
addURLToDownload(urls.get(0), new File(savePath));
|
addURLToDownload(urls.get(0), new File(savePath));
|
||||||
}
|
}
|
||||||
|
if (url.contains("v.redd.it")) {
|
||||||
|
String savePath = this.workingDir + File.separator;
|
||||||
|
savePath += id + "-" + url.split("/")[3] + ".mp4";
|
||||||
|
addURLToDownload(parseRedditVideoMPD(urls.get(0).toExternalForm()), new File(savePath));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
addURLToDownload(urls.get(0), id + "-", "", theUrl, null);
|
addURLToDownload(urls.get(0), id + "-", "", theUrl, null);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,9 @@ public class RipUtils {
|
|||||||
logger.warn("Exception while retrieving eroshare page:", e);
|
logger.warn("Exception while retrieving eroshare page:", e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
} else if (url.toExternalForm().contains("v.redd.it")) {
|
||||||
|
result.add(url);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (url.toExternalForm().contains("erome.com")) {
|
else if (url.toExternalForm().contains("erome.com")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user