diff --git a/pom.xml b/pom.xml index 65e968f18..577dc5329 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.tonikelope MegaBasterd - 7.88 + 7.89 jar diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java b/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java index edf3d8ace..d8a7df4b9 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java @@ -31,6 +31,7 @@ import java.util.logging.Logger; */ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { + public static final int SMART_PROXY_RECHECK_509_TIME = 3600; private static final Logger LOG = Logger.getLogger(ChunkDownloader.class.getName()); private final int _id; private final Download _download; @@ -42,6 +43,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { private final ArrayList _excluded_proxy_list; private volatile boolean _reset_current_chunk; private volatile InputStream _chunk_inputstream = null; + private volatile long _509_timestamp = -1; private String _current_smart_proxy; @@ -150,25 +152,12 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { String worker_url = null; - long init_chunk_time = -1, finish_chunk_time = -1, pause_init_time, paused = 0L; + long pause_init_time, paused = 0L; byte[] buffer = new byte[DEFAULT_BYTE_BUFFER_SIZE]; SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager(); - if (MainPanel.isUse_smart_proxy() && proxy_manager != null && proxy_manager.isForce_smart_proxy()) { - - String[] smart_proxy = proxy_manager.getProxy(_excluded_proxy_list); - - _current_smart_proxy = smart_proxy[0]; - - smart_proxy_socks = smart_proxy[1].equals("socks"); - - if (!getDownload().isTurbo()) { - getDownload().enableTurboMode(); - } - } - while (!_download.getMain_panel().isExit() && !_exit && !_download.isStopped()) { if (_download.isPaused() && !_download.isStopped() && !_download.getChunkmanager().isExit()) { @@ -183,6 +172,10 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { } + if (http_error == 509 && _509_timestamp == -1) { + _509_timestamp = System.currentTimeMillis(); + } + if (worker_url == null || http_error == 403) { worker_url = _download.getDownloadUrlForWorker(); @@ -204,7 +197,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { MainPanel.LAST_EXTERNAL_COMMAND_TIMESTAMP = -1; } - if ((_current_smart_proxy != null || http_error == 509) && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()) { + if (MainPanel.isUse_smart_proxy() && ((proxy_manager != null && proxy_manager.isForce_smart_proxy()) || _current_smart_proxy != null || http_error == 509 || (_509_timestamp != -1 && _509_timestamp + SMART_PROXY_RECHECK_509_TIME * 1000 < System.currentTimeMillis())) && !MainPanel.isUse_proxy()) { if (_current_smart_proxy != null && chunk_error) { @@ -316,8 +309,6 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { try (OutputStream tmp_chunk_file_os = new BufferedOutputStream(new FileOutputStream(tmp_chunk_file))) { - init_chunk_time = System.currentTimeMillis(); - paused = 0L; int reads = 0; @@ -348,15 +339,12 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { } - finish_chunk_time = System.currentTimeMillis(); } } else { LOG.log(Level.INFO, "{0} Worker [{1}] has RECOVERED PREVIOUS chunk [{2}]! {3}", new Object[]{Thread.currentThread().getName(), _id, chunk_id, _download.getFile_name()}); - finish_chunk_time = -1; - chunk_reads = chunk_size; _download.getPartialProgress().add(chunk_size); @@ -368,7 +356,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { if (chunk_reads == chunk_size) { - LOG.log(Level.INFO, "{0} Worker [{1}] has DOWNLOADED chunk [{2}]! {3}", new Object[]{Thread.currentThread().getName(), _id, chunk_id, _download.getFile_name()}); + LOG.log(Level.INFO, "{0} Worker [{1}] has OK DOWNLOADED (" + (_current_smart_proxy != null ? "smartproxy" : "direct") + ") chunk [{2}]! {3}", new Object[]{Thread.currentThread().getName(), _id, chunk_id, _download.getFile_name()}); if (tmp_chunk_file != null && chunk_file != null && (!chunk_file.exists() || chunk_file.length() != chunk_size)) { @@ -385,6 +373,10 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { http_error = 0; + if (_current_smart_proxy != null && _509_timestamp != -1) { + _509_timestamp = -1; + } + _excluded_proxy_list.clear(); _download.getChunkmanager().secureNotify(); @@ -413,15 +405,9 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { _chunk_inputstream = null; } - if (_reset_current_chunk) { - LOG.log(Level.WARNING, "Worker [{0}] FORCE RESET CHUNK [{1}]! {2}", new Object[]{_id, chunk_id, _download.getFile_name()}); - _current_smart_proxy = null; - _reset_current_chunk = false; - } - if (chunk_error) { - LOG.log(Level.INFO, "{0} Worker [{1}] has FAILED downloading chunk [{2}]! {3}", new Object[]{Thread.currentThread().getName(), _id, chunk_id, _download.getFile_name()}); + LOG.log(Level.INFO, "{0} Worker [{1}] has FAILED downloading (" + (_current_smart_proxy != null ? "smartproxy" : "direct") + ") chunk [{2}]! {3}", new Object[]{Thread.currentThread().getName(), _id, chunk_id, _download.getFile_name()}); if (tmp_chunk_file != null && tmp_chunk_file.exists()) { tmp_chunk_file.delete(); @@ -457,6 +443,12 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { _current_smart_proxy = null; } + if (_reset_current_chunk) { + LOG.log(Level.WARNING, "Worker [{0}] FORCE RESET CHUNK [{1}]! {2}", new Object[]{_id, chunk_id, _download.getFile_name()}); + _current_smart_proxy = null; + _reset_current_chunk = false; + } + con.disconnect(); } } diff --git a/src/main/java/com/tonikelope/megabasterd/FolderLinkDialog.java b/src/main/java/com/tonikelope/megabasterd/FolderLinkDialog.java index bcf5a1749..5c3859911 100644 --- a/src/main/java/com/tonikelope/megabasterd/FolderLinkDialog.java +++ b/src/main/java/com/tonikelope/megabasterd/FolderLinkDialog.java @@ -26,6 +26,7 @@ import javax.swing.JOptionPane; import javax.swing.JTree; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; /** * @@ -47,6 +48,10 @@ public class FolderLinkDialog extends javax.swing.JDialog { private volatile boolean exit = false; + private volatile MegaMutableTreeNode _subfolder_node = null; + + private volatile boolean _subfolder_finish = false; + public List getDownload_links() { return Collections.unmodifiableList(_download_links); } @@ -326,12 +331,16 @@ public class FolderLinkDialog extends javax.swing.JDialog { node_bar.setVisible(true); skip_rest_button.setEnabled(false); skip_button.setEnabled(false); + THREAD_POOL.execute(() -> { + MiscTools.resetTreeFolderSizes(((MegaMutableTreeNode) file_tree.getModel().getRoot())); + MiscTools.calculateTreeFolderSizes(((MegaMutableTreeNode) file_tree.getModel().getRoot())); _genDownloadLiks(); - MiscTools.GUIRun(() -> { + + MiscTools.GUIRunAndWait(() -> { restore_button.setVisible(true); file_tree.setEnabled(true); @@ -345,6 +354,7 @@ public class FolderLinkDialog extends javax.swing.JDialog { skip_button.setEnabled(root_childs); skip_rest_button.setEnabled(root_childs); + }); }); @@ -414,6 +424,17 @@ public class FolderLinkDialog extends javax.swing.JDialog { String folder_id = findFirstRegex("#F!([^!]+)", _link, 1); + String subfolder_id = null; + + if (folder_id.contains("@")) { + + String[] fids = folder_id.split("@"); + + folder_id = fids[0]; + + subfolder_id = fids[1]; + } + String folder_key = findFirstRegex("#F![^!]+!(.+)", _link, 1); folder_nodes = ma.getFolderNodes(folder_id, folder_key, node_bar); @@ -515,7 +536,9 @@ public class FolderLinkDialog extends javax.swing.JDialog { final MegaMutableTreeNode roott = root; - MiscTools.GUIRun(() -> { + final String ssubfolder_id = subfolder_id; + + MiscTools.GUIRunAndWait(() -> { node_bar.setIndeterminate(true); @@ -526,6 +549,12 @@ public class FolderLinkDialog extends javax.swing.JDialog { ftree.setEnabled(true); }); + if (ssubfolder_id != null) { + + _subfolder_node = MiscTools.findMegaTreeNodeByID(roott, ssubfolder_id); + + } + } } catch (MegaAPIException mex) { @@ -620,7 +649,7 @@ public class FolderLinkDialog extends javax.swing.JDialog { } } - MiscTools.GUIRun(() -> { + MiscTools.GUIRunAndWait(() -> { total_space_label.setText("[" + formatBytes(_total_space) + "]"); @@ -634,6 +663,28 @@ public class FolderLinkDialog extends javax.swing.JDialog { working = false; }); + if (_subfolder_node != null && !_subfolder_finish) { + + MiscTools.GUIRunAndWait(() -> { + + file_tree.setSelectionPath(new TreePath(_subfolder_node.getPath())); + + }); + + _subfolder_finish = true; + + MiscTools.GUIRun(() -> { + skip_rest_button.setEnabled(true); + skip_rest_button.doClick(); + }); + + } else if (_subfolder_node != null && _subfolder_finish) { + MiscTools.GUIRunAndWait(() -> { + + file_tree.setSelectionPath(new TreePath(_subfolder_node.getPath())); + + }); + } }); }); } diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanel.java b/src/main/java/com/tonikelope/megabasterd/MainPanel.java index fcf2f32f4..9bb9ad2ad 100644 --- a/src/main/java/com/tonikelope/megabasterd/MainPanel.java +++ b/src/main/java/com/tonikelope/megabasterd/MainPanel.java @@ -69,7 +69,7 @@ import javax.swing.UIManager; */ public final class MainPanel { - public static final String VERSION = "7.88"; + public static final String VERSION = "7.89"; 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; diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanelView.java b/src/main/java/com/tonikelope/megabasterd/MainPanelView.java index 6610d6f19..5d48da1bc 100644 --- a/src/main/java/com/tonikelope/megabasterd/MainPanelView.java +++ b/src/main/java/com/tonikelope/megabasterd/MainPanelView.java @@ -14,7 +14,6 @@ import static com.tonikelope.megabasterd.DBTools.*; import static com.tonikelope.megabasterd.MainPanel.*; import static com.tonikelope.megabasterd.MiscTools.*; import java.awt.Color; -import java.awt.Dimension; import java.awt.datatransfer.DataFlavor; import java.awt.dnd.DnDConstants; import java.awt.dnd.DropTarget; @@ -177,13 +176,9 @@ public final class MainPanelView extends javax.swing.JFrame { String old_status = getKiss_server_status().getText(); if (!old_status.equals(status + " ")) { - Dimension frame_size = this.getSize(); getKiss_server_status().setText(status + " "); - pack(); - setSize(frame_size); - } }); } @@ -194,13 +189,9 @@ public final class MainPanelView extends javax.swing.JFrame { String old_status = getSmart_proxy_status().getText(); if (!old_status.equals(status + " ")) { - Dimension frame_size = this.getSize(); getSmart_proxy_status().setText(status + " "); - pack(); - setSize(frame_size); - } }); } @@ -212,13 +203,8 @@ public final class MainPanelView extends javax.swing.JFrame { String old_status = getMc_reverse_status().getText(); if (!old_status.equals(status + " ")) { - Dimension frame_size = this.getSize(); getMc_reverse_status().setText(status + " "); - - pack(); - setSize(frame_size); - } }); } @@ -1100,7 +1086,7 @@ public final class MainPanelView extends javax.swing.JFrame { Set folder_file_links = new HashSet(findAllRegex("(?:https?|mega)://[^\r\n]+#F\\*[^\r\n!]*?![^\r\n!]+![^\\?\r\n/]+", link_data, 0)); if (!folder_file_links.isEmpty()) { - ArrayList nlinks = ma.getNlinks(folder_file_links); + ArrayList nlinks = ma.GENERATE_N_LINKS(folder_file_links); urls.removeAll(folder_file_links); diff --git a/src/main/java/com/tonikelope/megabasterd/MegaAPI.java b/src/main/java/com/tonikelope/megabasterd/MegaAPI.java index 5382c6397..e27057bc0 100644 --- a/src/main/java/com/tonikelope/megabasterd/MegaAPI.java +++ b/src/main/java/com/tonikelope/megabasterd/MegaAPI.java @@ -161,7 +161,7 @@ public class MegaAPI implements Serializable { request = "[{\"a\":\"us\",\"user\":\"" + _email + "\",\"uh\":\"" + _user_hash + "\"}]"; } - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec="); String res = RAW_REQUEST(request, url_api); @@ -197,7 +197,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"us0\",\"user\":\"" + _email + "\"}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec="); String res = RAW_REQUEST(request, url_api); @@ -215,7 +215,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"mfag\",\"e\":\"" + email + "\"}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec="); String res = RAW_REQUEST(request, url_api); @@ -285,7 +285,7 @@ public class MegaAPI implements Serializable { URL url_api; - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + 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); @@ -329,7 +329,7 @@ public class MegaAPI implements Serializable { try { - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + 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); @@ -550,12 +550,12 @@ public class MegaAPI implements Serializable { request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]"; - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "") + "&n=" + folder_id); + url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "") + "&n=" + folder_id); } else { request = "[{\"a\":\"g\", \"g\":\"1\", \"p\":\"" + file_id + "\"}]"; - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); } String data = RAW_REQUEST(request, url_api); @@ -588,13 +588,13 @@ public class MegaAPI implements Serializable { request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]"; - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "") + "&n=" + folder_id); + url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "") + "&n=" + folder_id); } else { request = "[{\"a\":\"g\", \"p\":\"" + file_id + "\"}]"; - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); } String data = RAW_REQUEST(request, url_api); @@ -697,7 +697,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"u\", \"s\":" + String.valueOf(f.length()) + "}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + 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); @@ -741,7 +741,7 @@ public class MegaAPI implements Serializable { 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) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + 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); @@ -802,7 +802,7 @@ public class MegaAPI implements Serializable { request = "[{\"a\":\"pfa\", \"fa\":\"0*" + hash[0] + "/1*" + hash[1] + "\", \"n\":\"" + node_handle + "\"}]"; - url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); res = RAW_REQUEST(request, url_api); @@ -835,7 +835,7 @@ public class MegaAPI implements Serializable { byte[] enc_att = _encAttr("{\"n\":\"" + fbasename + "\"}", i32a2bin(Arrays.copyOfRange(ul_key, 0, 4))); - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); String request = "[{\"a\":\"p\", \"t\":\"" + mega_parent + "\", \"n\":[{\"h\":\"" + completion_handle + "\", \"t\":0, \"a\":\"" + Bin2UrlBASE64(enc_att) + "\", \"k\":\"" + Bin2UrlBASE64(encryptKey(i32a2bin(fkey), master_key)) + "\"}], \"i\":\"" + _req_id + "\", \"cr\" : [ [\"" + root_node + "\"] , [\"" + completion_handle + "\"] , [0,0, \"" + Bin2UrlBASE64(encryptKey(i32a2bin(fkey), share_key)) + "\"]]}]"; @@ -892,7 +892,7 @@ public class MegaAPI implements Serializable { byte[] enc_node_key = encryptKey(node_key, master_key); - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); String request = "[{\"a\":\"p\", \"t\":\"" + parent_node + "\", \"n\":[{\"h\":\"xxxxxxxx\",\"t\":1,\"a\":\"" + Bin2UrlBASE64(enc_att) + "\",\"k\":\"" + Bin2UrlBASE64(enc_node_key) + "\"}],\"i\":\"" + _req_id + "\"}]"; @@ -922,7 +922,7 @@ public class MegaAPI implements Serializable { byte[] enc_node_key_s = encryptKey(node_key, share_key); - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); String request = "[{\"a\":\"p\", \"t\":\"" + parent_node + "\", \"n\":[{\"h\":\"xxxxxxxx\",\"t\":1,\"a\":\"" + Bin2UrlBASE64(enc_att) + "\",\"k\":\"" + Bin2UrlBASE64(enc_node_key) + "\"}],\"i\":\"" + _req_id + "\", \"cr\" : [ [\"" + root_node + "\"] , [\"xxxxxxxx\"] , [0,0, \"" + Bin2UrlBASE64(enc_node_key_s) + "\"]]}]"; @@ -952,7 +952,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"l\", \"n\":\"" + node + "\"}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + 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); @@ -983,7 +983,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"l\", \"n\":\"" + node + "\", \"i\":\"" + _req_id + "\"}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + 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); @@ -1030,7 +1030,7 @@ public class MegaAPI implements Serializable { //OJO String request = "[{\"a\":\"s2\",\"n\":\"" + node + "\",\"s\":[{\"u\":\"EXP\",\"r\":0}],\"i\":\"" + _req_id + "\",\"ok\":\"AAAAAAAAAAAAAAAAAAAAAA\",\"ha\":\"AAAAAAAAAAAAAAAAAAAAAA\",\"cr\":[[\"" + node + "\"],[\"" + node + "\"],[0,0,\"" + enc_nk + "\"]]}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : "")); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "")); return RAW_REQUEST(request, url_api); @@ -1062,7 +1062,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\"}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (API_KEY != null ? "&ak=" + API_KEY : "") + "&n=" + folder_id); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + "&n=" + folder_id); String res = RAW_REQUEST(request, url_api); @@ -1076,12 +1076,13 @@ public class MegaAPI implements Serializable { int s = ((List) res_map[0].get("f")).size(); - MiscTools.GUIRun(() -> { - bar.setIndeterminate(false); - bar.setMaximum(s); - bar.setValue(0); - }); - + if (bar != null) { + MiscTools.GUIRun(() -> { + bar.setIndeterminate(false); + bar.setMaximum(s); + bar.setValue(0); + }); + } int conta_nodo = 0; for (Object o : (Iterable) res_map[0].get("f")) { @@ -1090,10 +1091,12 @@ public class MegaAPI implements Serializable { int c = conta_nodo; - MiscTools.GUIRun(() -> { + if (bar != null) { + MiscTools.GUIRun(() -> { - bar.setValue(c); - }); + bar.setValue(c); + }); + } HashMap node = (HashMap) o; @@ -1155,7 +1158,7 @@ public class MegaAPI implements Serializable { return folder_nodes; } - public ArrayList getNlinks(Set links) { + public ArrayList GENERATE_N_LINKS(Set links) { HashMap> map = new HashMap<>(); @@ -1206,7 +1209,7 @@ public class MegaAPI implements Serializable { String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\"}]"; - URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (API_KEY != null ? "&ak=" + API_KEY : "") + "&n=" + folder_id); + URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + "&n=" + folder_id); String res = RAW_REQUEST(request, url_api); diff --git a/src/main/java/com/tonikelope/megabasterd/MiscTools.java b/src/main/java/com/tonikelope/megabasterd/MiscTools.java index 879b0e778..4aae15070 100644 --- a/src/main/java/com/tonikelope/megabasterd/MiscTools.java +++ b/src/main/java/com/tonikelope/megabasterd/MiscTools.java @@ -660,6 +660,24 @@ public class MiscTools { } + public static MegaMutableTreeNode findMegaTreeNodeByID(MegaMutableTreeNode root, String node_id) { + + Enumeration e = root.depthFirstEnumeration(); + + while (e.hasMoreElements()) { + + MegaMutableTreeNode node = (MegaMutableTreeNode) e.nextElement(); + + HashMap mega_node = (HashMap) node.getUserObject(); + + if (mega_node.get("h").equals(node_id)) { + return node; + } + } + + return null; + } + public static DefaultMutableTreeNode sortTree(DefaultMutableTreeNode root) { Enumeration e = root.depthFirstEnumeration(); @@ -1564,6 +1582,8 @@ public class MiscTools { data = data.replaceAll("(?:https://)?mega(?:\\.co)?\\.nz/folder/([^#]+)#([^\r\n/]+)/file/([^\r\n/]+)", "https://mega.nz/#F*$3!$1!$2"); + data = data.replaceAll("(?:https://)?mega(?:\\.co)?\\.nz/folder/([^#]+)#([^\r\n/]+)/folder/([^\r\n/]+)", "https://mega.nz/#F!$1@$3!$2"); + return data.replaceAll("(?:https://)?mega(?:\\.co)?\\.nz/folder/([^#]+)#([^\r\n]+)", "https://mega.nz/#F!$1!$2").replaceAll("(?:https://)?mega(?:\\.co)?\\.nz/file/([^#]+)#([^\r\n]+)", "https://mega.nz/#!$1!$2"); } diff --git a/src/main/java/com/tonikelope/megabasterd/SmartMegaProxyManager.java b/src/main/java/com/tonikelope/megabasterd/SmartMegaProxyManager.java index 05e84f223..fd81cec19 100644 --- a/src/main/java/com/tonikelope/megabasterd/SmartMegaProxyManager.java +++ b/src/main/java/com/tonikelope/megabasterd/SmartMegaProxyManager.java @@ -39,6 +39,7 @@ public final class SmartMegaProxyManager { public static String DEFAULT_SMART_PROXY_URL = null; public static final int PROXY_BLOCK_TIME = 300; public static final int PROXY_AUTO_REFRESH_SLEEP_TIME = 30; + private static final Logger LOG = Logger.getLogger(SmartMegaProxyManager.class.getName()); private volatile String _proxy_list_url; private final LinkedHashMap _proxy_list; @@ -70,6 +71,24 @@ public final class SmartMegaProxyManager { refreshProxyList(); } + private synchronized int countBlockedProxies() { + + int i = 0; + + Long current_time = System.currentTimeMillis(); + + for (String k : _proxy_list.keySet()) { + + if (_proxy_list.get(k)[0] > current_time) { + + i++; + } + } + + return i; + + } + public synchronized void refreshSmartProxySettings() { String smartproxy_ban_time = DBTools.selectSettingValue("smartproxy_ban_time"); @@ -159,6 +178,9 @@ public final class SmartMegaProxyManager { LOG.log(Level.WARNING, "[Smart Proxy] BLOCKING PROXY {0} ({1} secs) ({2})", new Object[]{proxy, _ban_time, cause}); } + + _main_panel.getView().updateSmartProxyStatus("SmartProxy: ON (" + String.valueOf(getProxyCount() - countBlockedProxies()) + ")" + (this.isForce_smart_proxy() ? " F!" : "")); + } } diff --git a/src/main/java/com/tonikelope/megabasterd/StreamerDialog.java b/src/main/java/com/tonikelope/megabasterd/StreamerDialog.java index 18211cb47..37f768ab3 100644 --- a/src/main/java/com/tonikelope/megabasterd/StreamerDialog.java +++ b/src/main/java/com/tonikelope/megabasterd/StreamerDialog.java @@ -238,7 +238,7 @@ public class StreamerDialog extends javax.swing.JDialog implements ClipboardChan links.add(link); - List nlinks = ma.getNlinks(links); + List nlinks = ma.GENERATE_N_LINKS(links); link = (String) nlinks.get(0); } diff --git a/src/main/resources/images/mbasterd_screen.png b/src/main/resources/images/mbasterd_screen.png index f9fd6c094..26de44762 100644 Binary files a/src/main/resources/images/mbasterd_screen.png and b/src/main/resources/images/mbasterd_screen.png differ