mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-23 18:16:18 +02:00
1.8
This commit is contained in:
parent
97da191376
commit
a85604d3bb
@ -6,9 +6,7 @@ import java.util.logging.Level;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import javax.swing.JOptionPane;
|
||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MainPanel.VERSION;
|
||||
import static megabasterd.MiscTools.copyTextToClipboard;
|
||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||
@ -176,7 +174,7 @@ public final class AboutDialog extends javax.swing.JDialog {
|
||||
|
||||
try {
|
||||
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
HashMap<String, Object> folder_nodes = ma.getFolderNodes("lYsRWaQB", "uVhntmyKcVECRaOxAbcL4A");
|
||||
|
||||
|
@ -7,7 +7,6 @@ import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static megabasterd.MainPanel.THROTTLE_SLICE_SIZE;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||
|
||||
@ -121,7 +120,7 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(MainPanel.CONNECTION_TIMEOUT);
|
||||
conn.setReadTimeout(MainPanel.CONNECTION_TIMEOUT);
|
||||
conn.setRequestProperty("User-Agent", USER_AGENT);
|
||||
conn.setRequestProperty("User-Agent", MegaAPI.USER_AGENT);
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
|
||||
error = false;
|
||||
|
@ -8,7 +8,6 @@ import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static megabasterd.MainPanel.THROTTLE_SLICE_SIZE;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
||||
|
||||
|
||||
@ -60,7 +59,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(MainPanel.CONNECTION_TIMEOUT);
|
||||
conn.setReadTimeout(MainPanel.CONNECTION_TIMEOUT);
|
||||
conn.setRequestProperty("User-Agent", USER_AGENT);
|
||||
conn.setRequestProperty("User-Agent", MegaAPI.USER_AGENT);
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
is = new ThrottledInputStream(conn.getInputStream(), getDownload().getMain_panel().getStream_supervisor());
|
||||
http_status = conn.getResponseCode();
|
||||
|
@ -131,7 +131,7 @@ public final class ChunkUploader implements Runnable, SecureNotifiable {
|
||||
conn.setReadTimeout(MainPanel.CONNECTION_TIMEOUT);
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("User-Agent", MainPanel.USER_AGENT);
|
||||
conn.setRequestProperty("User-Agent", MegaAPI.USER_AGENT);
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
conn.setFixedLengthStreamingMode(chunk.getSize());
|
||||
|
||||
|
@ -34,9 +34,7 @@ import static megabasterd.CryptTools.genCrypter;
|
||||
import static megabasterd.DBTools.deleteDownload;
|
||||
import static megabasterd.DBTools.insertDownload;
|
||||
import static megabasterd.DBTools.selectSettingValueFromDB;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.UrlBASE642Bin;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
import static megabasterd.MiscTools.checkMegaDownloadUrl;
|
||||
@ -876,7 +874,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
||||
try {
|
||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", _url, 0) != null )
|
||||
{
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
download_url = ma.getMegaFileDownloadUrl(_url);
|
||||
}
|
||||
@ -1153,7 +1151,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
||||
|
||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null)
|
||||
{
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
file_info = ma.getMegaFileMetadata(link);
|
||||
}
|
||||
@ -1253,7 +1251,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
||||
{
|
||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", _url, 0) != null)
|
||||
{
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
dl_url = ma.getMegaFileDownloadUrl(link);
|
||||
|
||||
|
@ -15,9 +15,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
||||
import static megabasterd.MiscTools.deleteSelectedTreeItems;
|
||||
import static megabasterd.MiscTools.formatBytes;
|
||||
@ -448,7 +446,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
||||
|
||||
if(ma == null) {
|
||||
|
||||
ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
ma = new MegaAPI();
|
||||
|
||||
try {
|
||||
|
||||
|
@ -11,9 +11,7 @@ import static java.util.logging.Level.SEVERE;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
||||
import static megabasterd.MiscTools.deleteSelectedTreeItems;
|
||||
import static megabasterd.MiscTools.findFirstRegex;
|
||||
@ -297,7 +295,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
||||
try {
|
||||
HashMap<String,Object> folder_nodes;
|
||||
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
String folder_id = findFirstRegex("#F!([^!]+)", _link, 1);
|
||||
|
||||
|
@ -23,10 +23,8 @@ import static java.util.logging.Logger.getLogger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.crypto.CipherInputStream;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.STREAMER_PORT;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.checkMegaDownloadUrl;
|
||||
import static megabasterd.MiscTools.findFirstRegex;
|
||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
||||
@ -210,7 +208,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
||||
{
|
||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null)
|
||||
{
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
file_info = ma.getMegaFileMetadata(link);
|
||||
}
|
||||
@ -279,7 +277,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
||||
{
|
||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null)
|
||||
{
|
||||
MegaAPI ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma = new MegaAPI();
|
||||
|
||||
dl_url = ma.getMegaFileDownloadUrl(link);
|
||||
}
|
||||
@ -539,7 +537,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
||||
|
||||
urlConn.setConnectTimeout(MainPanel.CONNECTION_TIMEOUT);
|
||||
|
||||
urlConn.setRequestProperty("User-Agent", MainPanel.USER_AGENT);
|
||||
urlConn.setRequestProperty("User-Agent", MegaAPI.USER_AGENT);
|
||||
|
||||
urlConn.setRequestProperty("Connection", "close");
|
||||
|
||||
|
@ -58,8 +58,6 @@ import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION="1.8";
|
||||
public static final String MEGA_API_KEY=null;
|
||||
public static final String USER_AGENT="MEGAsync/2.9.8.0";
|
||||
public static final int CONNECTION_TIMEOUT = 30000;
|
||||
public static final int THROTTLE_SLICE_SIZE=16*1024;
|
||||
public static final int STREAMER_PORT = 1337;
|
||||
@ -595,7 +593,7 @@ public final class MainPanel {
|
||||
|
||||
try {
|
||||
|
||||
ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
ma = new MegaAPI();
|
||||
|
||||
ma.login(email, bin2i32a(BASE642Bin((String)account_info.get("password_aes"))), (String)account_info.get("user_hash"));
|
||||
|
||||
|
@ -29,9 +29,7 @@ import static megabasterd.CryptTools.decryptMegaDownloaderLink;
|
||||
import static megabasterd.DBTools.deleteMegaAccount;
|
||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||
import static megabasterd.MainPanel.ICON_FILE;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MainPanel.VERSION;
|
||||
import static megabasterd.MiscTools.BASE642Bin;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
@ -750,7 +748,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
MegaAPI ma=getMain_panel().getMega_active_accounts().get(mega_account)!=null?getMain_panel().getMega_active_accounts().get(mega_account):new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
MegaAPI ma=getMain_panel().getMega_active_accounts().get(mega_account)!=null?getMain_panel().getMega_active_accounts().get(mega_account):new MegaAPI();
|
||||
|
||||
try {
|
||||
|
||||
|
@ -33,8 +33,11 @@ import org.codehaus.jackson.map.ObjectMapper;
|
||||
public final class MegaAPI {
|
||||
|
||||
public static final String API_URL = "https://g.api.mega.co.nz";
|
||||
|
||||
public static final String API_KEY = null;
|
||||
public static final String USER_AGENT="MEGAsync/2.9.8.0";
|
||||
public static final int REQ_ID_LENGTH = 10;
|
||||
|
||||
|
||||
public static int checkMEGAError(String data)
|
||||
{
|
||||
String error = findFirstRegex("^\\[?(\\-[0-9]+)\\]?$", data, 1);
|
||||
@ -44,9 +47,7 @@ public final class MegaAPI {
|
||||
|
||||
private int _seqno;
|
||||
|
||||
private String _sid;
|
||||
|
||||
private String _api_key;
|
||||
private String _sid;
|
||||
|
||||
private int[] _master_key;
|
||||
|
||||
@ -66,10 +67,8 @@ public final class MegaAPI {
|
||||
|
||||
private String _req_id;
|
||||
|
||||
private String _user_agent;
|
||||
|
||||
|
||||
public MegaAPI(String api_key, String user_agent)
|
||||
|
||||
public MegaAPI()
|
||||
{
|
||||
_req_id = null;
|
||||
_trashbin_id = null;
|
||||
@ -80,8 +79,6 @@ public final class MegaAPI {
|
||||
_password_aes = null;
|
||||
_rsa_priv_key = null;
|
||||
_master_key = null;
|
||||
_api_key = api_key;
|
||||
_user_agent = user_agent;
|
||||
_sid = null;
|
||||
_req_id = genID(REQ_ID_LENGTH);
|
||||
|
||||
@ -104,10 +101,6 @@ public final class MegaAPI {
|
||||
return _sid;
|
||||
}
|
||||
|
||||
public String getApi_key() {
|
||||
return _api_key;
|
||||
}
|
||||
|
||||
public int[] getMaster_key() {
|
||||
return _master_key;
|
||||
}
|
||||
@ -134,7 +127,7 @@ public final class MegaAPI {
|
||||
|
||||
String request = "[{\"a\":\"us\", \"user\":\""+_email+"\", \"uh\":\""+_user_hash+"\"}]";
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res = _rawRequest(request, url_api);
|
||||
|
||||
@ -198,7 +191,7 @@ public final class MegaAPI {
|
||||
|
||||
URL url_api;
|
||||
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res = _rawRequest(request, url_api);
|
||||
|
||||
@ -239,7 +232,7 @@ public final class MegaAPI {
|
||||
|
||||
try {
|
||||
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res = _rawRequest(request, url_api);
|
||||
|
||||
@ -295,7 +288,7 @@ public final class MegaAPI {
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setRequestProperty("User-Agent", _user_agent);
|
||||
conn.setRequestProperty("User-Agent", USER_AGENT);
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
|
||||
OutputStream out;
|
||||
@ -378,12 +371,12 @@ public final class MegaAPI {
|
||||
|
||||
request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\""+file_id+"\"}]";
|
||||
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(_api_key!=null?"&ak="+_api_key:"")+"&n="+folder_id);
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(API_KEY!=null?"&ak="+API_KEY:"")+"&n="+folder_id);
|
||||
|
||||
} else {
|
||||
|
||||
request = "[{\"a\":\"g\", \"g\":\"1\", \"p\":\""+file_id+"\"}]";
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(_api_key!=null?"&ak="+_api_key:""));
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
}
|
||||
|
||||
String data = _rawRequest(request, url_api);
|
||||
@ -415,13 +408,13 @@ public final class MegaAPI {
|
||||
|
||||
request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\""+file_id+"\"}]";
|
||||
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(_api_key!=null?"&ak="+_api_key:"")+"&n="+folder_id);
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(API_KEY!=null?"&ak="+API_KEY:"")+"&n="+folder_id);
|
||||
|
||||
} else {
|
||||
|
||||
request = "[{\"a\":\"g\", \"p\":\""+file_id+"\"}]";
|
||||
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(_api_key!=null?"&ak="+_api_key:""));
|
||||
url_api = new URL(API_URL+"/cs?id="+_seqno+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
}
|
||||
|
||||
String data = _rawRequest(request, url_api);
|
||||
@ -513,7 +506,7 @@ public final class MegaAPI {
|
||||
|
||||
String request = "[{\"a\":\"u\", \"s\":"+String.valueOf(f.length())+"}]";
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res = _rawRequest(request, url_api);
|
||||
|
||||
@ -538,7 +531,7 @@ public final class MegaAPI {
|
||||
|
||||
byte[] enc_att = _encAttr("{\"n\":\""+fbasename+"\"}", i32a2bin(Arrays.copyOfRange(ul_key, 0, 4)));
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
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))+"\"]]}]";
|
||||
|
||||
@ -591,7 +584,7 @@ public final class MegaAPI {
|
||||
|
||||
byte[] enc_node_key = encryptKey(node_key, master_key);
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String request="[{\"a\":\"p\", \"t\":\""+parent_node+"\", \"n\":[{\"h\":\"xxxxxxxx\",\"t\":1,\"a\":\""+Bin2UrlBASE64(enc_att)+"\",\"k\":\""+Bin2UrlBASE64(enc_node_key)+"\"}],\"i\":\""+_req_id+"\"}]";
|
||||
|
||||
@ -624,7 +617,7 @@ public final class MegaAPI {
|
||||
|
||||
byte[] enc_node_key_s = encryptKey(node_key, share_key);
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
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)+"\"]]}]";
|
||||
|
||||
@ -657,7 +650,7 @@ public final class MegaAPI {
|
||||
|
||||
String request = "[{\"a\":\"l\", \"n\":\""+node+"\"}]";
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res=_rawRequest(request, url_api);
|
||||
|
||||
@ -690,7 +683,7 @@ public final class MegaAPI {
|
||||
|
||||
String request = "[{\"a\":\"l\", \"n\":\""+node+"\", \"i\":\""+_req_id+"\"}]";
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res=_rawRequest(request, url_api);
|
||||
|
||||
@ -741,7 +734,7 @@ public final class MegaAPI {
|
||||
|
||||
System.out.println(request);
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(_api_key!=null?"&ak="+_api_key:""));
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+"&sid="+_sid+(API_KEY!=null?"&ak="+API_KEY:""));
|
||||
|
||||
String res=_rawRequest(request, url_api);
|
||||
|
||||
@ -775,7 +768,7 @@ public final class MegaAPI {
|
||||
|
||||
String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\"}]";
|
||||
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+(_api_key!=null?"&ak="+_api_key:"")+"&n="+folder_id);
|
||||
URL url_api = new URL(API_URL+"/cs?id="+_seqno+(API_KEY!=null?"&ak="+API_KEY:"")+"&n="+folder_id);
|
||||
|
||||
String res=_rawRequest(request, url_api);
|
||||
|
||||
|
@ -34,6 +34,8 @@ import org.codehaus.jackson.map.ObjectMapper;
|
||||
*/
|
||||
public final class MegaCrypterAPI {
|
||||
|
||||
public static final String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0";
|
||||
|
||||
private static String _rawRequest(String request, URL url_api) throws IOException, MegaCrypterAPIException {
|
||||
|
||||
HttpURLConnection conn = (HttpURLConnection) url_api.openConnection();
|
||||
@ -41,7 +43,7 @@ public final class MegaCrypterAPI {
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setRequestProperty("User-Agent", MainPanel.USER_AGENT);
|
||||
conn.setRequestProperty("User-Agent", USER_AGENT);
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
|
||||
OutputStream out;
|
||||
|
@ -51,7 +51,6 @@ import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import static megabasterd.MainPanel.CONNECTION_TIMEOUT;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
|
||||
public final class MiscTools {
|
||||
|
||||
@ -528,7 +527,7 @@ public final class MiscTools {
|
||||
|
||||
URLConnection conn = url.openConnection();
|
||||
|
||||
conn.setRequestProperty("User-Agent", MainPanel.USER_AGENT);
|
||||
conn.setRequestProperty("User-Agent", MegaCrypterAPI.USER_AGENT);
|
||||
|
||||
String content_encoding = conn.getContentEncoding();
|
||||
|
||||
@ -823,7 +822,7 @@ public final class MiscTools {
|
||||
URL url = new URL(string_url+"/0-0");
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||
connection.setRequestProperty("User-Agent", USER_AGENT);
|
||||
connection.setRequestProperty("User-Agent", MegaAPI.USER_AGENT);
|
||||
|
||||
try (InputStream is = connection.getInputStream()) {
|
||||
while(is.read()!=-1);
|
||||
|
@ -16,9 +16,7 @@ import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import static megabasterd.DBTools.insertSettingValueInDB;
|
||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||
import static megabasterd.MainPanel.MEGA_API_KEY;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MainPanel.USER_AGENT;
|
||||
import static megabasterd.MiscTools.Bin2BASE64;
|
||||
import static megabasterd.MiscTools.i32a2bin;
|
||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||
@ -725,7 +723,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
|
||||
if(dialog._main_panel.getMega_accounts().get(email) == null){
|
||||
|
||||
ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
ma = new MegaAPI();
|
||||
|
||||
try {
|
||||
ma.login(email, pass);
|
||||
@ -746,7 +744,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
|
||||
if(!mega_account_data.get("password").equals(pass)) {
|
||||
|
||||
ma = new MegaAPI(MEGA_API_KEY, USER_AGENT);
|
||||
ma = new MegaAPI();
|
||||
|
||||
try {
|
||||
ma.login(email, pass);
|
||||
|
Loading…
x
Reference in New Issue
Block a user