Advertisement
sebbu

jd/plugins/hoster/FEmbedCom.java

Jul 1st, 2018
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.66 KB | None | 0 0
  1. package jd.plugins.hoster;
  2.  
  3. import org.appwork.utils.Regex;
  4.  
  5. import jd.PluginWrapper;
  6. import jd.http.URLConnectionAdapter;
  7. import jd.http.requests.PostRequest;
  8. import jd.plugins.DownloadLink;
  9. import jd.plugins.DownloadLink.AvailableStatus;
  10. import jd.plugins.HostPlugin;
  11. import jd.plugins.LinkStatus;
  12. import jd.plugins.PluginException;
  13. import jd.plugins.PluginForHost;
  14. import jd.plugins.components.PluginJSonUtils;
  15.  
  16. @HostPlugin(revision = "$Revision: 34675 $", interfaceVersion = 2, names = { "fembed.com" }, urls = { "decryptedforFEmbedHosterPlugin://.*" })
  17. public class FEmbedCom extends PluginForHost {
  18.     public FEmbedCom(PluginWrapper wrapper) {
  19.         super(wrapper);
  20.     }
  21.  
  22.     @Override
  23.     public String getAGBLink() {
  24.         return "https://www.fembed.com/";
  25.     }
  26.  
  27.     private String data = "";
  28.     private String url;
  29.  
  30.     @Override
  31.     public void correctDownloadLink(DownloadLink link) {
  32.         String url = link.getDownloadURL().replaceFirst("decryptedforFEmbedHosterPlugin://", "https://");
  33.         link.setUrlDownload(url);
  34.     }
  35.  
  36.     @Override
  37.     public AvailableStatus requestFileInformation(DownloadLink parameter) throws Exception {
  38.         if (parameter.getDownloadSize() > 0 && url != null && !url.isEmpty()) {
  39.             return AvailableStatus.TRUE;
  40.         }
  41.         String file_id = new Regex(parameter.getPluginPatternMatcher(), "/(?:f|v)/([a-zA-Z0-9_-]+)$").getMatch(0);
  42.         final PostRequest postRequest = new PostRequest("https://www.fembed.com/api/source/" + file_id);
  43.         data = br.getPage(postRequest);
  44.         String success = PluginJSonUtils.getJson(PluginJSonUtils.unescape(data), "success");
  45.         if (success == "false") {
  46.             return AvailableStatus.FALSE;
  47.         }
  48.         String label = parameter.getStringProperty("label");
  49.         String data2 = PluginJSonUtils.getJson(PluginJSonUtils.unescape(data), "data");
  50.         String[] data2_ar = PluginJSonUtils.getJsonResultsFromArray(data2);
  51.         int index = 0;
  52.         int cur = -1;
  53.         for (String ar : data2_ar) {
  54.             String url2 = PluginJSonUtils.getJson(ar, "file");
  55.             String label2 = PluginJSonUtils.getJson(ar, "label");
  56.             if (label.equals(label2) || data2_ar.length == 1) {
  57.                 cur = index;
  58.                 url = url2;
  59.                 URLConnectionAdapter con = null;
  60.                 con = this.br.openHeadConnection(url2);
  61.                 if (!con.getContentType().contains("html")) {
  62.                     long size = con.getLongContentLength();
  63.                     parameter.setDownloadSize(size);
  64.                 }
  65.                 con.disconnect();
  66.                 break;
  67.             }
  68.             index++;
  69.         }
  70.         data = br.getPage(postRequest);
  71.         if (cur != -1) {
  72.             url = PluginJSonUtils.getJson(PluginJSonUtils.getJsonResultsFromArray(PluginJSonUtils.getJson(PluginJSonUtils.unescape(data), "data"))[cur], "file");
  73.         }
  74.         return AvailableStatus.TRUE;
  75.     }
  76.  
  77.     @Override
  78.     public void handleFree(DownloadLink link) throws Exception {
  79.         requestFileInformation(link);
  80.         br.clearAuthentications();
  81.         dl = jd.plugins.BrowserAdapter.openDownload(br, link, url, true, 1);
  82.         url = null;
  83.         if (dl.getConnection().getContentType().contains("html")) {
  84.             br.followConnection();
  85.             throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
  86.         }
  87.         dl.startDownload();
  88.     }
  89.  
  90.     @Override
  91.     public void reset() {
  92.     }
  93.  
  94.     @Override
  95.     public void resetDownloadlink(DownloadLink link) {
  96.     }
  97.  
  98.     @Override
  99.     public int getMaxSimultanFreeDownloadNum() {
  100.         return -1;
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement