コード例 #1
0
ファイル: FileCloud.java プロジェクト: tetratec/AutoSite
/**
 * @author vigneshwaran
 * @author davidepastore
 */
public class FileCloud extends AbstractUploader implements UploaderAccountNecessary {

  FileCloudAccount fileCloudAccount = (FileCloudAccount) AccountsManager.getAccount("FileCloud.io");

  private HttpClient httpclient = NUHttpClient.getHttpClient();
  private HttpResponse httpResponse;
  private NUHttpPost httpPost;
  private String stringResponse;
  private JSONObject jSonObject;

  private String uploadURL;
  private long minFileSizeLimit = 1024l;

  public FileCloud(File file) {

    super(file);
    host = "FileCloud.io";
    downURL = UploadStatus.PLEASEWAIT.getLocaleSpecificString();
    delURL = UploadStatus.NA.getLocaleSpecificString();
    // It has to be successful.. as it won't work without login
    if (fileCloudAccount.loginsuccessful) {
      host = fileCloudAccount.username + " | FileCloud.io";
    }

    maxFileSizeLimit = 2097152000l; // 2000 MB
  }

  @Override
  public void run() {

    try {
      if (fileCloudAccount.loginsuccessful) {
        host = fileCloudAccount.username + " | FileCloud.io";
      } else {
        host = "FileCloud.io";

        uploadInvalid();
        return;
      }

      // Check file size (max)
      if (file.length() > maxFileSizeLimit) {
        throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
      }

      // Check file size (min)
      if (file.length() < minFileSizeLimit) {
        throw new NUMinFileSizeException(minFileSizeLimit, file.getName(), host);
      }

      uploadInitialising();
      NULogger.getLogger().info("Getting upload url from FileCloud.....");
      stringResponse =
          NUHttpClientUtils.getData(
              "http://api.filecloud.io/api-fetch_upload_url.api?response=json");

      // Get JSONObject
      jSonObject = new JSONObject(stringResponse);
      String responseStatus = jSonObject.getString("status");

      if ("ok".equals(responseStatus)) {
        uploadURL = jSonObject.getString("upload_url");
        NULogger.getLogger().log(Level.INFO, "FileCloud Upload URL : {0}", uploadURL);
        fileUpload();
        uploadFinished();
      } else {
        // Handle errors
        throw new Exception("Error: " + jSonObject.getString("message"));
      }

    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      Logger.getLogger(FileCloud.class.getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }

  private void fileUpload() throws Exception {
    httpPost = new NUHttpPost(uploadURL);

    MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

    mpEntity.addPart("akey", new StringBody(fileCloudAccount.getFileCloudAPIKey()));

    mpEntity.addPart("Filedata", createMonitoredFileBody());
    httpPost.setEntity(mpEntity);
    NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
    NULogger.getLogger().info("Now uploading your file into filecloud.io .....");
    uploading();
    httpResponse = httpclient.execute(httpPost);
    HttpEntity resEntity = httpResponse.getEntity();
    NULogger.getLogger().info(httpResponse.getStatusLine().toString());
    if (resEntity != null) {
      stringResponse = EntityUtils.toString(resEntity);
    }

    // Get JSONObject
    jSonObject = new JSONObject(stringResponse);
    String responseStatus = jSonObject.getString("status");

    if (!"ok".equals(responseStatus)) {
      // Handle errors
      throw new Exception("Error: " + jSonObject.getString("message"));
    }

    String downloadURL = "http://filecloud.io/" + jSonObject.getString("ukey");
    NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadURL);
    downURL = downloadURL;

    status = UploadStatus.UPLOADFINISHED;
  }
}
コード例 #2
0
ファイル: AnonFiles.java プロジェクト: tetratec/AutoSite
/** @author davidepastore */
public class AnonFiles extends AbstractUploader {
  private HttpClient httpclient = NUHttpClient.getHttpClient();
  private HttpResponse httpResponse;
  private NUHttpPost httpPost;
  private String responseString;
  private JSONObject jSonObject;
  private String uploadURL = "https://anonfiles.com/api";

  private ArrayList<String> allowedExtensions = new ArrayList<String>();

  private String downloadlink = "";

  public AnonFiles(File file) {
    super(file);
    downURL = UploadStatus.PLEASEWAIT.getLocaleSpecificString();
    delURL = UploadStatus.NA.getLocaleSpecificString();
    host = "AnonFiles.com";
    maxFileSizeLimit = 524288000l; // 500 MB
  }

  /** Add all the allowed extensions */
  private void addExtensions() {
    allowedExtensions.add("jpg");
    allowedExtensions.add("jpeg");
    allowedExtensions.add("gif");
    allowedExtensions.add("png");
    allowedExtensions.add("pdf");
    allowedExtensions.add("css");
    allowedExtensions.add("txt");
    allowedExtensions.add("avi");
    allowedExtensions.add("mpeg");
    allowedExtensions.add("mpg");
    allowedExtensions.add("mp3");
    allowedExtensions.add("doc");
    allowedExtensions.add("docx");
    allowedExtensions.add("odt");
    allowedExtensions.add("apk");
    allowedExtensions.add("7z");
    allowedExtensions.add("rmvb");
    allowedExtensions.add("zip");
    allowedExtensions.add("rar");
    allowedExtensions.add("mkv");
    allowedExtensions.add("xls");
  }

  @Override
  public void run() {
    try {

      // Check size
      if (file.length() > maxFileSizeLimit) {
        throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), host);
      }

      addExtensions();

      // Check extension
      if (!FileUtils.checkFileExtension(allowedExtensions, file)) {
        throw new NUFileExtensionException(file.getName(), host);
      }

      uploadInitialising();

      httpPost = new NUHttpPost(uploadURL);
      MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      mpEntity.addPart("file", createMonitoredFileBody());
      httpPost.setEntity(mpEntity);

      NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
      NULogger.getLogger().info("Now uploading your file into AnonFiles.com");
      uploading();
      httpResponse = httpclient.execute(httpPost);
      responseString = EntityUtils.toString(httpResponse.getEntity());

      // Read the links
      gettingLink();
      jSonObject = new JSONObject(responseString);
      if (jSonObject.getString("status").equals("success")) {
        downloadlink = jSonObject.getString("url");
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
      } else {
        throw new Exception("Upload failed: " + jSonObject.getString("msg"));
      }

      downURL = downloadlink;

      uploadFinished();
    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }
}
コード例 #3
0
/**
 * @author Dinesh
 * @author davidepastore
 */
public class BayFilesAccount extends AbstractAccount {

  private final HttpClient httpclient = NUHttpClient.getHttpClient();
  private HttpResponse httpResponse;
  private NUHttpPost httpPost;
  private CookieStore cookieStore;
  private String stringResponse;
  private JSONObject jSonOjbject;

  public BayFilesAccount() {
    KEY_USERNAME = "******";
    KEY_PASSWORD = "******";
    HOSTNAME = "BayFiles.com";
  }

  @Override
  public void disableLogin() {
    resetLogin();
    NULogger.getLogger().log(Level.INFO, "{0} account disabled", getHOSTNAME());
  }

  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to bayfiles.com");
      httpPost = new NUHttpPost("http://bayfiles.net/ajax_login");
      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("action", "login"));
      formparams.add(new BasicNameValuePair("username", getUsername()));
      formparams.add(new BasicNameValuePair("password", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);

      httpResponse = httpclient.execute(httpPost, httpContext);
      stringResponse = EntityUtils.toString(httpResponse.getEntity());

      // NULogger.getLogger().log(Level.INFO, "BayFiles.com stringResponse: {0}", stringResponse);

      jSonOjbject = new JSONObject(stringResponse);

      if (jSonOjbject.has("reload")) {
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("Bayfiles.com login succeeded :)");
      } else {
        String error = jSonOjbject.getString("error");

        if ("Login failed. Please try again".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }

    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      AccountsManager.getInstance().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }

  private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    // NULogger.getLogger().info("Getting startup cookies & link from ArabLoads.com");
    // responseString = NUHttpClientUtils.getData("http://arabloads.com", httpContext);
  }

  private void resetLogin() {
    loginsuccessful = false;
    username = "";
    password = "";
  }
}
コード例 #4
0
ファイル: SlingFile.java プロジェクト: tetratec/AutoSite
/**
 * @author dinesh
 * @author davidepastore
 */
public class SlingFile extends AbstractUploader {

  SlingFileAccount slingFileAccount =
      (SlingFileAccount) AccountsManager.getAccount("SlingFile.com");

  private HttpClient httpclient = NUHttpClient.getHttpClient();
  private HttpContext httpContext = new BasicHttpContext();
  private HttpResponse httpResponse;
  private NUHttpPost httpPost;
  private NUHttpGet httpGet;
  private CookieStore cookieStore;
  private String stringResponse;
  private String uploadURL;
  private String progressID;
  private String rauLink;
  private URI URILink;
  private JSONObject jSonObject;

  private String ssd = "";
  private String encUserID = "";
  private String postURL = "";
  private String downloadlink = "";
  private String deletelink = "";
  private long fileSizeLimit = 2147483648l; // 2 GB

  public SlingFile(File file) {
    super(file);
    downURL = UploadStatus.PLEASEWAIT.getLocaleSpecificString();
    delURL = UploadStatus.PLEASEWAIT.getLocaleSpecificString();
    host = "SlingFile.com";
    if (slingFileAccount.loginsuccessful) {
      host = slingFileAccount.username + " | SlingFile.com";
    }
  }

  private void initialize() throws Exception {

    NULogger.getLogger().info("After login, geting the link again :)");
    httpGet = new NUHttpGet("http://www.slingfile.com/");
    httpResponse = httpclient.execute(httpGet, httpContext);
    stringResponse = EntityUtils.toString(httpResponse.getEntity());
    // FileUtils.saveInFile("SlingFile.com.html", stringResponse);

    // See here: http://www.slingfile.com/media/plupload.beauty.js
    // http://www.plupload.com/punbb/viewtopic.php?pid=5686
    jSonObject =
        new JSONObject(
            StringUtils.stringBetweenTwoStrings(stringResponse, "var uploaderSettings = ", ";"));

    uploadURL = jSonObject.getString("uploadURL");
    ssd = jSonObject.getString("ssd");

    if (jSonObject.has("encUserID")) {
      encUserID = jSonObject.getString("encUserID");
    }

    progressID = guid();
    postURL = uploadURL + progressID;
    rauLink =
        StringUtils.stringBetweenTwoStrings(stringResponse, "document.location.href = '", "'");
    NULogger.getLogger().log(Level.INFO, "progressID: " + progressID);

    URILink = URIUtils.createURI(rauLink);
  }

  @Override
  public void run() {
    try {
      if (slingFileAccount.loginsuccessful) {
        host = slingFileAccount.username + " | SlingFile.com";
        httpContext = slingFileAccount.getHttpContext();
      } else {
        host = "SlingFile.com";
        cookieStore = new BasicCookieStore();
        httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
      }

      if (file.length() > fileSizeLimit) {
        throw new NUMaxFileSizeException(
            fileSizeLimit, file.getName(), slingFileAccount.getHOSTNAME());
      }
      uploadInitialising();
      initialize();

      httpPost = new NUHttpPost(postURL);
      MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      mpEntity.addPart("X-Progress-ID", new StringBody(progressID));
      mpEntity.addPart("uFileID", new StringBody(progressID));
      mpEntity.addPart("uid", new StringBody(encUserID));
      if (slingFileAccount.loginsuccessful) {
        mpEntity.addPart("folderid", new StringBody("0"));
      }
      mpEntity.addPart("ssd", new StringBody(ssd));
      mpEntity.addPart("Filename", new StringBody(file.getName()));
      mpEntity.addPart("name", new StringBody(file.getName()));
      mpEntity.addPart("Upload", new StringBody("Submit Query"));
      mpEntity.addPart("file", createMonitoredFileBody());
      httpPost.setEntity(mpEntity);
      NULogger.getLogger().log(Level.INFO, "executing request {0}", httpPost.getRequestLine());
      NULogger.getLogger().info("Now uploading your file into slingfile.com");
      uploading();
      HttpResponse response = httpclient.execute(httpPost, httpContext);
      stringResponse = EntityUtils.toString(response.getEntity());

      if ("done".equals(stringResponse)) {
        NULogger.getLogger().log(Level.INFO, "upload done!");

        gettingLink();
        httpGet = new NUHttpGet(URILink);
        httpResponse = httpclient.execute(httpGet, httpContext);

        stringResponse = EntityUtils.toString(httpResponse.getEntity());
        // FileUtils.saveInFile("SlingFile.com.html", stringResponse);
        Document doc = Jsoup.parse(stringResponse);
        downloadlink =
            doc.select("div#container div#mainContent fieldset table tbody tr td input")
                .first()
                .val();
        deletelink =
            doc.select("div#container div#mainContent fieldset table tbody tr td input")
                .eq(3)
                .val();

        NULogger.getLogger().log(Level.INFO, "Delete link : {0}", deletelink);
        NULogger.getLogger().log(Level.INFO, "Download link : {0}", downloadlink);
        downURL = downloadlink;
        delURL = deletelink;
      } else {
        throw new Exception("Upload isn't good.");
      }

      uploadFinished();
    } catch (Exception e) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, e);

      uploadFailed();
    }
  }

  /**
   * Implementation of guid of <a
   * href="http://www.slingfile.com/media/plupload.beauty.js">plupload</a>.
   *
   * @return the guid string
   */
  private String guid() {
    int f = 0;
    Long number = new Long(new Date().getTime());
    String o = Long.toString(number, 32);
    for (int p = 0; p < 5; p++) {
      o += Long.toString((Math.round(Math.random() * 65535)), 32);
    }
    // return (g.guidPrefix || "p") + o + (f++).toString(32);
    return ("p") + o + Integer.toString(f++, 32);
  }
}
コード例 #5
0
/** @author MNidhal */
public class FileParadoxAccount extends AbstractAccount {

  private final HttpClient httpclient = NUHttpClient.getHttpClient();
  private HttpResponse httpResponse;
  private NUHttpPost httpPost;
  private CookieStore cookieStore;
  private String responseString;

  public FileParadoxAccount() {
    KEY_USERNAME = "******";
    KEY_PASSWORD = "******";
    HOSTNAME = "FileParadox.in";
  }

  @Override
  public void disableLogin() {
    resetLogin();
    NULogger.getLogger().log(Level.INFO, "{0} account disabled", getHOSTNAME());
  }

  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to FileParadox.in");
      httpPost = new NUHttpPost("http://fileparadox.in");

      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("op", "login"));
      formparams.add(new BasicNameValuePair("login", getUsername()));
      formparams.add(new BasicNameValuePair("password", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);
      httpResponse = httpclient.execute(httpPost, httpContext);
      NULogger.getLogger().info(httpResponse.getStatusLine().toString());
      Header lastHeader = httpResponse.getLastHeader("Location");

      if (lastHeader != null && lastHeader.getValue().contains("op=upload_form")) {
        EntityUtils.consume(httpResponse.getEntity());
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("FileParadox.in login successful!");

      } else {
        // Get error message
        responseString = EntityUtils.toString(httpResponse.getEntity());
        // FileUtils.saveInFile("FileParadoxAccount.html", responseString);
        Document doc = Jsoup.parse(responseString);
        String error = doc.select(".err").first().text();

        if ("Incorrect Login or Password".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }
    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      AccountsManager.getInstance().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      JOptionPane.showMessageDialog(
          NeembuuUploader.getInstance(),
          "<html>" + TranslationProvider.get("neembuuuploader.accounts.loginerror") + "</html>",
          HOSTNAME,
          JOptionPane.WARNING_MESSAGE);
      AccountsManager.getInstance().setVisible(true);
    }
  }

  private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    // NULogger.getLogger().info("Getting startup cookies & link from FileParadox.in");
    // responseString = NUHttpClientUtils.getData("http://fileparadox.in", httpContext);
  }

  private void resetLogin() {
    loginsuccessful = false;
    username = "";
    password = "";
  }
}
コード例 #6
0
ファイル: FireDrive.java プロジェクト: tetratec/AutoSite
/** @author davidepastore */
public class FireDrive extends AbstractUploader {

  FireDriveAccount fireDriveAccount =
      (FireDriveAccount) AccountsManager.getAccount("FireDrive.com");
  //    private String apiURL = "http://upload.putlocker.com/uploadapi.php";
  private final HttpClient httpclient = NUHttpClient.getHttpClient();
  private HttpContext httpContext = new BasicHttpContext();

  public FireDrive(File file) {
    super(file);
    downURL = UploadStatus.PLEASEWAIT.getLocaleSpecificString();
    delURL = UploadStatus.NA.getLocaleSpecificString();
    host = "FireDrive.com";

    if (fireDriveAccount.loginsuccessful) {
      host = fireDriveAccount.username + " | FireDrive.com";
    }

    maxFileSizeLimit = 1073741824l; // 1 GB
  }

  /** Upload with <a href="http://www.putlocker.com/apidocs.php">API</a>. */
  private void apiUpload() throws UnsupportedEncodingException, IOException, Exception {
    //        uploading();
    //        ContentBody cbFile = createMonitoredFileBody();
    //        NUHttpPost httppost = new NUHttpPost(apiURL);
    //        MultipartEntity mpEntity = new MultipartEntity();
    //
    //        mpEntity.addPart("file", cbFile);
    //        mpEntity.addPart("user", new StringBody(fireDriveAccount.username));
    //        mpEntity.addPart("password", new StringBody(fireDriveAccount.password));
    //        mpEntity.addPart("convert", new StringBody("1"));
    //        httppost.setEntity(mpEntity);
    //        HttpResponse response = httpclient.execute(httppost);
    //        String reqResponse = EntityUtils.toString(response.getEntity());
    //        //NULogger.getLogger().info(reqResponse);
    //
    //        if(reqResponse.contains("File Uploaded Successfully")){
    //            gettingLink();
    //            downURL = StringUtils.stringBetweenTwoStrings(reqResponse, "<link>", "</link>");
    //        }
    //        else{
    //            //Handle the errors
    //            status = UploadStatus.GETTINGERRORS;
    //            throw new Exception(StringUtils.stringBetweenTwoStrings(reqResponse, "<message>",
    // "</message>"));
    //        }
  }

  /** Upload with normal uploader. */
  public void normalUpload() throws IOException, Exception {
    String uploadPostUrl;
    NUHttpPost httppost;
    HttpResponse response;
    String reqResponse;

    uploadPostUrl = "https://upload.firedrive.com/web";

    // Getting vars
    final String getUrl = "http://www.firedrive.com/upload?_=" + System.currentTimeMillis();
    reqResponse = NUHttpClientUtils.getData(getUrl, httpContext);
    final String vars = StringUtils.stringBetweenTwoStrings(reqResponse, "return '", "'");

    NULogger.getLogger().log(Level.INFO, "getUrl: {0}", getUrl);
    NULogger.getLogger().log(Level.INFO, "vars: {0}", vars);

    // Start the upload
    uploading();

    httppost = new NUHttpPost(uploadPostUrl);
    MultipartEntity mpEntity = new MultipartEntity();
    mpEntity.addPart("name", new StringBody(file.getName()));
    mpEntity.addPart("vars", new StringBody(vars));
    mpEntity.addPart("target_folder", new StringBody("0"));
    mpEntity.addPart("target_group", new StringBody("0"));
    mpEntity.addPart("file", createMonitoredFileBody());
    httppost.setEntity(mpEntity);
    response = httpclient.execute(httppost, httpContext);
    reqResponse = EntityUtils.toString(response.getEntity());

    JSONObject jSonObject = new JSONObject(reqResponse);

    if (jSonObject.getString("result").equals("success")) {
      // Now we can read the link
      gettingLink();
      downURL = "http://www.firedrive.com/file/" + jSonObject.getString("id");
      NULogger.getLogger().log(Level.INFO, "Download URL: {0}", downURL);
    } else {
      // Handle errors
      NULogger.getLogger().info(reqResponse);
      throw new Exception("Error in firedrive.com. Take a look to last jSonObject!");
    }
  }

  @Override
  public void run() {
    uploadInitialising();
    try {
      if (fireDriveAccount.loginsuccessful) {
        httpContext = fireDriveAccount.getHttpContext();

        if (fireDriveAccount.isPremium()) {
          maxFileSizeLimit = 53687091200l; // 50 GB
        } else {
          maxFileSizeLimit = 1073741824l; // 1 GB
        }

      } else {
        httpContext.setAttribute(ClientContext.COOKIE_STORE, new BasicCookieStore());
      }

      if (file.length() > maxFileSizeLimit) {
        throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), getHost());
      }

      normalUpload();
      uploadFinished();
    } catch (NUException ex) {
      ex.printError();
      uploadInvalid();
    } catch (Exception e) {
      NULogger.getLogger().log(Level.INFO, "Exception: {0}", e);
      uploadFailed();
    }
  }
}