Advertisement
sebbu

jd/plugins/decrypter/FEmbedDecrypter .java

Jul 4th, 2018
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.13 KB | None | 0 0
  1. package jd.plugins.decrypter;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.appwork.utils.Regex;
  6.  
  7. import jd.PluginWrapper;
  8. import jd.controlling.ProgressController;
  9. import jd.http.requests.PostRequest;
  10. import jd.plugins.CryptedLink;
  11. import jd.plugins.DecrypterPlugin;
  12. import jd.plugins.DownloadLink;
  13. import jd.plugins.FilePackage;
  14. import jd.plugins.PluginForDecrypt;
  15. import jd.plugins.components.PluginJSonUtils;
  16.  
  17. @DecrypterPlugin(revision = "$Revision: 34675 $", interfaceVersion = 2, names = { "fembed.com" }, urls = { "https?://(www\\.)?fembed.com/(f|v)/([a-zA-Z0-9_-]+)" })
  18. public class FEmbedDecrypter extends PluginForDecrypt {
  19.     public FEmbedDecrypter(PluginWrapper wrapper) {
  20.         super(wrapper);
  21.     }
  22.  
  23.     private String _filename;
  24.  
  25.     public void setFilename(String filename) {
  26.         this._filename = filename;
  27.     }
  28.  
  29.     public String getFilename() {
  30.         return this._filename;
  31.     }
  32.  
  33.     @Override
  34.     public ArrayList<DownloadLink> decryptIt(CryptedLink parameter, ProgressController progress) throws Exception {
  35.         final ArrayList<DownloadLink> ret = new ArrayList<DownloadLink>();
  36.         String filename = getFilename();
  37.         String file_id = new Regex(parameter.getCryptedUrl(), "/(?:f|v)/([a-zA-Z0-9_-]+)$").getMatch(0);
  38.         final PostRequest postRequest = new PostRequest("https://www.fembed.com/api/source/" + file_id);
  39.         String data = br.getPage(postRequest);
  40.         String success = PluginJSonUtils.getJson(PluginJSonUtils.unescape(data), "success");
  41.         if (success.equals("false")) {
  42.             DownloadLink link = createDownloadlink(parameter.getCryptedUrl().replaceAll("https?://", "decryptedforFEmbedHosterPlugin://"));
  43.             link.setForcedFileName(filename + ".mp4");
  44.             link.setAvailable(false);
  45.             ret.add(link);
  46.             return ret;
  47.         }
  48.         String json_data = PluginJSonUtils.getJson(PluginJSonUtils.unescape(data), "data");
  49.         String[] json_data_ar = PluginJSonUtils.getJsonResultsFromArray(json_data);
  50.         for (String data_ar : json_data_ar) {
  51.             String label = PluginJSonUtils.getJson(data_ar, "label");
  52.             String type = PluginJSonUtils.getJson(data_ar, "type");
  53.             DownloadLink link = createDownloadlink(parameter.getCryptedUrl().replaceAll("https?://", "decryptedforFEmbedHosterPlugin://"));
  54.             link.setProperty("label", label);
  55.             link.setLinkID("fembed" + "." + file_id + "." + label);
  56.             if (!filename.isEmpty()) {
  57.                 link.setFinalFileName(filename + "-" + label + "." + type);
  58.             } else {
  59.                 link.setForcedFileName(file_id + "-" + label + "." + type);
  60.             }
  61.             ret.add(link);
  62.         }
  63.         if (json_data_ar.length > 1) {
  64.             final FilePackage filePackage = FilePackage.getInstance();
  65.             String title;
  66.             if (filename != null && !filename.isEmpty()) {
  67.                 title = filename;
  68.             } else {
  69.                 title = file_id;
  70.             }
  71.             filePackage.setName(title);
  72.             filePackage.addLinks(ret);
  73.         }
  74.         return ret;
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement