Skip to content

Commit

Permalink
7.93
Browse files Browse the repository at this point in the history
Improve load time of very big folders
  • Loading branch information
tonikelope committed Oct 19, 2023
1 parent 9729a2b commit 3988eb7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>7.92</version>
<version>7.93</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,6 @@ private void _genDownloadLiks() {

if (node.isLeaf() && node != root && ((HashMap<String, Object>) node.getUserObject()).get("size") != null) {

System.out.println(((HashMap<String, Object>) node.getUserObject()).get("name"));

String path = "";

Object[] object_path = node.getUserObjectPath();
Expand All @@ -620,8 +618,6 @@ private void _genDownloadLiks() {

path = path.replaceAll("^/+", "").replaceAll("^\\+", "").trim();

System.out.println(path);

String url = "https://mega.nz/#N!" + ((Map<String, Object>) node.getUserObject()).get("h") + "!" + ((Map<String, Object>) node.getUserObject()).get("key") + "###n=" + folder_id;

HashMap<String, Object> download_link = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
*/
public final class MainPanel {

public static final String VERSION = "7.92";
public static final String VERSION = "7.93";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/com/tonikelope/megabasterd/MegaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException;
import javax.swing.JProgressBar;
Expand Down Expand Up @@ -367,8 +368,6 @@ public void fetchNodes() throws IOException {

private String RAW_REQUEST(String request, URL url_api) throws MegaAPIException {

System.out.println(request);

String response = null, current_smart_proxy = null;

int mega_error = 0, http_error = 0, conta_error = 0, http_status;
Expand Down Expand Up @@ -444,6 +443,8 @@ private String RAW_REQUEST(String request, URL url_api) throws MegaAPIException

con.setRequestProperty("Content-type", "text/plain;charset=UTF-8");

con.setRequestProperty("Accept-Encoding", "gzip");

con.setRequestProperty("User-Agent", MainPanel.DEFAULT_USER_AGENT);

con.setUseCaches(false);
Expand All @@ -468,7 +469,7 @@ private String RAW_REQUEST(String request, URL url_api) throws MegaAPIException

} else {

try (InputStream is = con.getInputStream(); ByteArrayOutputStream byte_res = new ByteArrayOutputStream()) {
try (InputStream is = "gzip".equals(con.getContentEncoding()) ? new GZIPInputStream(con.getInputStream()) : con.getInputStream(); ByteArrayOutputStream byte_res = new ByteArrayOutputStream()) {

byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE];

Expand Down Expand Up @@ -740,13 +741,10 @@ public String uploadThumbnails(Upload upload, String node_handle, String filenam

String request = "[{\"a\":\"ufa\", \"s\":" + String.valueOf(file_bytes[0].length) + ", \"ssl\":1}, {\"a\":\"ufa\", \"s\":" + String.valueOf(file_bytes[1].length) + ", \"ssl\":1}]";

System.out.println(request);
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

System.out.println(res);

ObjectMapper objectMapper = new ObjectMapper();

HashMap[] res_map = objectMapper.readValue(res, HashMap[].class);
Expand Down Expand Up @@ -794,7 +792,6 @@ public String uploadThumbnails(Upload upload, String node_handle, String filenam

hash[h] = MiscTools.Bin2UrlBASE64(byte_res.toByteArray());

System.out.println(hash[h]);
}

h++;
Expand All @@ -806,14 +803,10 @@ public String uploadThumbnails(Upload upload, String node_handle, String filenam

res = RAW_REQUEST(request, url_api);

System.out.println(request);

objectMapper = new ObjectMapper();

String[] resp = objectMapper.readValue(res, String[].class);

System.out.println((String) resp[0]);

return (String) resp[0];

} catch (MegaAPIException mae) {
Expand Down Expand Up @@ -1060,7 +1053,7 @@ public HashMap<String, Object> getFolderNodes(String folder_id, String folder_ke

HashMap<String, Object> folder_nodes = null;

String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\"}]";
String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\", \"ca\":\"1\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + "&n=" + folder_id);

Expand Down
Binary file modified src/main/resources/images/mbasterd_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3988eb7

Please sign in to comment.