From ab4fb97eac3f976f98996aac1b19736e8e8de09e Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 16 Jun 2018 12:18:42 -0400 Subject: [PATCH 1/2] Twitter ripper now get retweets when ripping a profile and gets largest video when downloading a video --- .../ripme/ripper/rippers/TwitterRipper.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java index cd5cf582..4187f5d1 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java @@ -123,7 +123,7 @@ public class TwitterRipper extends AlbumRipper { .append("&include_entities=true") .append("&exclude_replies=true") .append("&trim_user=true") - .append("&include_rts=false") + .append("&include_rts=true") .append("&count=" + 200); break; case SEARCH: @@ -187,14 +187,18 @@ public class TwitterRipper extends AlbumRipper { url = media.getString("media_url"); if (media.getString("type").equals("video")) { JSONArray variants = media.getJSONObject("video_info").getJSONArray("variants"); + int largestBitrate = 0; + String urlToDownload = null; + // Loop over all the video options and find the biggest video for (int j = 0; j < medias.length(); j++) { JSONObject variant = (JSONObject) variants.get(i); - if (variant.has("bitrate") && variant.getInt("bitrate") == 832000) { - addURLToDownload(new URL(variant.getString("url"))); - parsedCount++; - break; + if (variant.getInt("bitrate") > largestBitrate) { + largestBitrate = variant.getInt("bitrate"); + urlToDownload = variant.getString("url"); } } + addURLToDownload(new URL(urlToDownload)); + parsedCount++; } else if (media.getString("type").equals("photo")) { if (url.contains(".twimg.com/")) { url += ":orig"; From c4d6f6d9fd9a628f9146c62b0251875b50489de3 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 16 Jun 2018 12:29:27 -0400 Subject: [PATCH 2/2] twitter ripper now prfixes filenames --- .../ripme/ripper/rippers/TwitterRipper.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java index 4187f5d1..94ab41a3 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/TwitterRipper.java @@ -20,6 +20,8 @@ import com.rarchives.ripme.utils.Utils; public class TwitterRipper extends AlbumRipper { + int downloadUrls = 1; + private static final String DOMAIN = "twitter.com", HOST = "twitter"; @@ -197,12 +199,18 @@ public class TwitterRipper extends AlbumRipper { urlToDownload = variant.getString("url"); } } - addURLToDownload(new URL(urlToDownload)); + if (urlToDownload != null) { + addURLToDownload(new URL(urlToDownload), getPrefix(downloadUrls)); + downloadUrls++; + } else { + LOGGER.error("URLToDownload was null"); + } parsedCount++; } else if (media.getString("type").equals("photo")) { if (url.contains(".twimg.com/")) { url += ":orig"; - addURLToDownload(new URL(url)); + addURLToDownload(new URL(url), getPrefix(downloadUrls)); + downloadUrls++; parsedCount++; } else { LOGGER.debug("Unexpected media_url: " + url); @@ -215,6 +223,10 @@ public class TwitterRipper extends AlbumRipper { return parsedCount; } + public String getPrefix(int index) { + return String.format("%03d_", index); + } + @Override public void rip() throws IOException { getAccessToken();