コード例 #1
0
  // returns true if downloaded something, false if didn't
  private boolean downloadLinks(String linksText, JDFeedMeFeed feed, JDFeedMePost post) {
    // make sure we have something to download
    if (linksText.trim().length() == 0) return false;

    boolean skip_grabber = feed.getSkiplinkgrabber();
    boolean autostart = gui.getConfig().getStartdownloads();

    // handle a direct download
    if (skip_grabber) {
      // get all the links from the text
      ArrayList<DownloadLink> links = new DistributeData(linksText).findLinks();

      // create a new package for the data
      FilePackage fp = FilePackage.getInstance();
      fp.setName(post.getTitle() + " [JDFeedMe]");
      fp.addLinks(links);

      // download the package
      LinkGrabberController.getInstance().addLinks(links, skip_grabber, autostart);

      // restart the downloads if needed
      if (autostart) DownloadWatchDog.getInstance().startDownloads();
    } else // throw into the link grabber using the old code
    {
      new DistributeData(linksText, skip_grabber).start();
    }

    return true;
  }
コード例 #2
0
ファイル: KinoDomTv.java プロジェクト: sn0w/jdownloader
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    br.setCustomCharset("windows-1251");
    br.getPage(parameter);

    final String fpName = br.getRegex("<title>(.*?)(?:&raquo;.*)</title>").getMatch(0);
    String xmlLinks =
        br.getRegex("<param [^>]*?value=\"[^\"]*?file=([a-zA-Z0-9:/\\.\\-]+)[^\"]*?\" */>")
            .getMatch(0);
    if (xmlLinks == null)
      xmlLinks =
          br.getRegex("<embed [^>]*?flashvars=\"[^\"]*?file=([a-zA-Z0-9:/\\.\\-]+)[^\"]*?\" *>")
              .getMatch(0);
    if (xmlLinks == null) return decryptedLinks;

    br.getPage(xmlLinks);
    final String xmlFile = br.toString();
    if (xmlFile == null) return decryptedLinks;

    String[] links = HTMLParser.getHttpLinks(xmlFile, "");
    if (links == null || links.length == 0) return null;

    DownloadLink dl;
    for (String elem : links) decryptedLinks.add(dl = createDownloadlink(elem));

    if (fpName != null) {
      FilePackage fp = FilePackage.getInstance();
      fp.setName(fpName.trim());
      fp.addLinks(decryptedLinks);
    }
    return decryptedLinks;
  }
コード例 #3
0
ファイル: ReGetIt.java プロジェクト: sn0w/jdownloader
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   final String parameter = param.toString();
   br.setFollowRedirects(true);
   br.getPage(parameter);
   if (br.containsHTML("File not found|>Links were deleted|>No links available yet")) {
     logger.info("Link offline: " + parameter);
     return decryptedLinks;
   }
   // Get file/packagename
   String fpName = br.getRegex("<title>Download file (.*?) \\&mdash;").getMatch(0);
   if (fpName == null) fpName = br.getRegex("<h2>(.*?)</h2>").getMatch(0);
   String[] links =
       br.getRegex("\" align=\"absmiddle\"> .*?:[\t\n\r ]+<a href=\"(.*?)\"").getColumn(0);
   if (links == null || links.length == 0) {
     logger.warning("Decrypter broken for link: " + parameter);
     return null;
   }
   for (String finallink : links) {
     DownloadLink dl = createDownloadlink(finallink);
     // Set filename (if available) so filename is the same for every
     // host
     if (fpName != null) dl.setFinalFileName(fpName.trim());
     decryptedLinks.add(dl);
   }
   if (fpName != null) {
     FilePackage fp = FilePackage.getInstance();
     fp.setName(fpName.trim());
     fp.addLinks(decryptedLinks);
   }
   return decryptedLinks;
 }
コード例 #4
0
  @Override
  public void onDownloadControllerAddedPackage(FilePackage pkg) {
    HashMap<String, Object> dls = new HashMap<String, Object>();
    long afterUuid = -1l;
    PackageController<FilePackage, DownloadLink> controller = pkg.getControlledBy();
    if (controller != null) {
      boolean locked = controller.readLock();
      try {
        int index = controller.indexOf(pkg);
        if (index > 0) {
          FilePackage fp = controller.getPackages().get(index - 1);
          if (fp != null) {
            afterUuid = fp.getUniqueID().getID();
          }
        }
      } finally {
        controller.readUnlock(locked);
      }
    }
    dls.put("uuid", pkg.getUniqueID().getID());
    dls.put("afterUuid", afterUuid);

    fire(BASIC_EVENT.ADD_CONTENT.name(), null, BASIC_EVENT.ADD_CONTENT.name());
    fire(
        BASIC_EVENT.ADD_PACKAGE.name(),
        dls,
        BASIC_EVENT.ADD_PACKAGE.name() + "." + pkg.getUniqueID().getID());
    flushBuffer();
  }
コード例 #5
0
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   String parameter =
       "http://epicpaste.com/index.php/view/raw/"
           + new Regex(param.toString(), "([a-z0-9]+)$").getMatch(0);
   br.getPage(parameter);
   /** Link offline/invalid? */
   if (br.containsHTML(
       "(>404 Page Not Found<|>The page you requested was not found|<title>Stikked</title>)"))
     return decryptedLinks;
   final String fpName = br.getRegex("<h1>(.*?)</h1>").getMatch(0);
   final String pagePiece = br.getRegex("<pre>(.*?)</pre>").getMatch(0);
   if (pagePiece == null) {
     logger.warning("Decrypter broken for link: " + parameter);
     return null;
   }
   String[] links = HTMLParser.getHttpLinks(pagePiece, "");
   if (links == null || links.length == 0) {
     logger.warning("Decrypter broken for link: " + parameter);
     return null;
   }
   for (String singleLink : links)
     if (!new Regex(
             singleLink, "http://(www\\.)?epicpaste\\.com/index\\.php/view/(raw/)?[a-z0-9]+")
         .matches()) decryptedLinks.add(createDownloadlink(singleLink));
   if (fpName != null) {
     FilePackage fp = FilePackage.getInstance();
     fp.setName(Encoding.htmlDecode(fpName.trim()));
     fp.addLinks(decryptedLinks);
   }
   return decryptedLinks;
 }
コード例 #6
0
 /** fill given DownloadInformations with current details of this DownloadController */
 protected void getDownloadStatus(final DownloadInformations ds) {
   ds.reset();
   ds.addRunningDownloads(DownloadWatchDog.getInstance().getActiveDownloads());
   final boolean readL = readLock();
   try {
     LinkStatus linkStatus;
     boolean isEnabled;
     for (final FilePackage fp : packages) {
       synchronized (fp) {
         ds.addPackages(1);
         ds.addDownloadLinks(fp.size());
         for (final DownloadLink l : fp.getChildren()) {
           linkStatus = l.getLinkStatus();
           isEnabled = l.isEnabled();
           if (!linkStatus.hasStatus(LinkStatus.ERROR_ALREADYEXISTS) && isEnabled) {
             ds.addTotalDownloadSize(l.getDownloadSize());
             ds.addCurrentDownloadSize(l.getDownloadCurrent());
           }
           if (linkStatus.hasStatus(LinkStatus.ERROR_ALREADYEXISTS)) {
             ds.addDuplicateDownloads(1);
           } else if (!isEnabled) {
             ds.addDisabledDownloads(1);
           } else if (linkStatus.hasStatus(LinkStatus.FINISHED)) {
             ds.addFinishedDownloads(1);
           }
         }
       }
     }
   } finally {
     readUnlock(readL);
   }
 }
コード例 #7
0
ファイル: ZyvNt.java プロジェクト: john-peterson/jdownloader
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   String parameter = param.toString();
   br.setFollowRedirects(true);
   br.getPage(parameter);
   final String artist =
       br.getRegex("<title>Автор ([^<>\"/]*?) и его композиции</title>").getMatch(0);
   String[][] fileInfo =
       br.getRegex(
               "class=\"track artist_img_left\"><a href=\"(/pages/\\d+/\\d+\\.shtml)\">([^<>/\"]*?)</a></td><td class=\"date\">\\d{2}\\.\\d{2}\\.\\d{2}</td><td class=\"bitrate\">[0-9\t\n\r ]+</td><td class=\"size\">(\\d+(\\.\\d+)?)</td>")
           .getMatches();
   if (fileInfo == null || fileInfo.length == 0) {
     if (br.containsHTML(">Нет информации<")) {
       logger.info("Link offline: " + parameter);
       return decryptedLinks;
     }
     logger.warning("Decrypter broken for link: " + parameter);
     return null;
   }
   for (String[] file : fileInfo) {
     final DownloadLink dl = createDownloadlink("http://zaycev.net" + file[0]);
     dl.setFinalFileName(Encoding.htmlDecode(file[1].trim()) + ".mp3");
     dl.setDownloadSize(SizeFormatter.getSize(file[2] + " MB"));
     dl.setAvailable(true);
     decryptedLinks.add(dl);
   }
   if (artist != null) {
     FilePackage fp = FilePackage.getInstance();
     fp.setName(Encoding.htmlDecode(artist.trim()));
     fp.addLinks(decryptedLinks);
   }
   return decryptedLinks;
 }
コード例 #8
0
ファイル: RmxShrCmFldr.java プロジェクト: munix/jdget
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   final String parameter = param.toString();
   br.setFollowRedirects(true);
   br.getPage(parameter);
   if (br.containsHTML(">Dieser Container \\(ID\\) existiert nicht")) {
     logger.info("Link offline: " + parameter);
     return decryptedLinks;
   }
   final String fpName = br.getRegex("<h5><span title=\"([^<>\"]*?)\"").getMatch(0);
   final String links[] = br.getRegex("\\'(/download/[A-Za-z0-9]+)\'").getColumn(0);
   if (links == null || links.length == 0) {
     logger.warning("Decrypter broken for link: " + parameter);
     return null;
   }
   for (String link : links) {
     decryptedLinks.add(createDownloadlink("http://remixshare.com" + link));
   }
   if (fpName != null) {
     final FilePackage fp = FilePackage.getInstance();
     fp.setName(Encoding.htmlDecode(fpName.trim()));
     fp.addLinks(decryptedLinks);
   }
   return decryptedLinks;
 }
コード例 #9
0
 /** save the current FilePackages/DownloadLinks controlled by this DownloadController */
 public void saveDownloadLinks() {
   if (isSaveAllowed() == false) return;
   java.util.List<FilePackage> packages = null;
   final boolean readL = this.readLock();
   try {
     packages = new ArrayList<FilePackage>();
     for (Iterator iterator = this.packages.iterator(); iterator.hasNext(); ) {
       FilePackage p1 = (FilePackage) iterator.next();
       boolean exists = false;
       for (Iterator iterator2 = packages.iterator(); iterator2.hasNext(); ) {
         FilePackage p2 = (FilePackage) iterator2.next();
         if (p1.getUniqueID().equals(p2.getUniqueID())) exists = true;
       }
       if (!exists) packages.add(p1);
     }
   } finally {
     readUnlock(readL);
   }
   /* save as new Json ZipFile */
   try {
     save(packages, null);
   } catch (IOException e) {
     logger.log(e);
   }
 }
コード例 #10
0
ファイル: LtrstrWzCom.java プロジェクト: sn0w/jdownloader
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   String parameter = param.toString().replace("ultrastar-warez.com", "ultrastar-base.com");
   br.getPage(parameter);
   if (br.containsHTML(
       "(>Uploaded: 31\\.12\\.69 \\(23:00\\)<|class=\"title\"> \\- </span></td>)")) {
     logger.info("Link offline: " + parameter);
     return decryptedLinks;
   }
   String fpName = br.getRegex("<span class=\"title\">(.*?)</span>").getMatch(0);
   final String mirrors[] =
       br.getRegex(
               "<b>Download (\\d+)?:</b></td>[\t\r\n ]+<td colspan=\"4\" align=\"left\">(.*?)</td>")
           .getColumn(1);
   if (mirrors == null || mirrors.length == 0) return null;
   for (String mirror : mirrors) {
     final String[] links = HTMLParser.getHttpLinks(mirror, "");
     if (links == null || links.length == 0) continue;
     for (String dl : links) decryptedLinks.add(createDownloadlink(dl));
   }
   if (decryptedLinks.size() == 0) {
     logger.warning("Decrypter broken for link: " + parameter);
     return null;
   }
   if (fpName != null) {
     FilePackage fp = FilePackage.getInstance();
     fp.setName(fpName.trim());
     fp.addLinks(decryptedLinks);
   }
   return decryptedLinks;
 }
コード例 #11
0
 /**
  * return the first DownloadLink that does block given DownloadLink
  *
  * @param link
  * @return
  */
 public DownloadLink getFirstLinkThatBlocks(final DownloadLink link) {
   if (link == null) return null;
   final boolean readL = readLock();
   try {
     for (final FilePackage fp : packages) {
       synchronized (fp) {
         for (DownloadLink nextDownloadLink : fp.getChildren()) {
           if (nextDownloadLink == link) continue;
           if ((nextDownloadLink.getLinkStatus().hasStatus(LinkStatus.FINISHED))
               && nextDownloadLink.getFileOutput().equalsIgnoreCase(link.getFileOutput())) {
             if (new File(nextDownloadLink.getFileOutput()).exists()) {
               /*
                * fertige datei sollte auch auf der platte sein und nicht nur als fertig in der liste
                */
               return nextDownloadLink;
             }
           }
           if (nextDownloadLink.getLinkStatus().isPluginInProgress()
               && nextDownloadLink.getFileOutput().equalsIgnoreCase(link.getFileOutput()))
             return nextDownloadLink;
         }
       }
     }
   } finally {
     readUnlock(readL);
   }
   return null;
 }
コード例 #12
0
ファイル: OBoomCom.java プロジェクト: munix/jdget
 @Override
 public ArrayList<DownloadLink> decryptIt(CryptedLink parameter, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   br.getPage(wwwURL + "guestsession?source=" + APPID);
   String guestSession = br.getRegex("200,.*?\"(.*?)\"").getMatch(0);
   if (guestSession == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   String UID = new Regex(parameter.toString(), "#(share|folder)/([A-Z0-9\\-]+)").getMatch(1);
   if (UID == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   String name = null;
   if (parameter.toString().contains("#share")) {
     br.getPage(wwwURL + guestSession + "/share?share=" + UID);
     String files = br.getRegex("\"files\":\\[(.*?)\\]").getMatch(0);
     name = br.getRegex("\"name\":\"(.*?)\"").getMatch(0);
     if (name != null && "undefined".equals(name)) name = null;
     if (files != null) {
       String fileIDs[] = new Regex(files, "\"(.*?)\"").getColumn(0);
       for (String fileID : fileIDs) {
         decryptedLinks.add(createDownloadlink("https://www.oboom.com/#" + fileID));
       }
     }
   } else if (parameter.toString().contains("#folder")) {
     br.getPage(apiURL + "ls?item=" + UID + "&token=" + guestSession);
     name = br.getRegex("\"name\":\"(.*?)\"").getMatch(0);
     String[] files = br.getRegex("\\{\"size.*?\\}").getColumn(-1);
     if (files != null && files.length != 0) {
       for (final String f : files) {
         final String fname = getJson(f, "name");
         final String fsize = getJson(f, "size");
         final String fuid = getJson(f, "id");
         final String type = getJson(f, "type");
         final String state = getJson(f, "state");
         if (fuid != null && "file".equalsIgnoreCase(type)) {
           DownloadLink dl = createDownloadlink("https://www.oboom.com/#" + fuid);
           if ("online".equalsIgnoreCase(state)) dl.setAvailable(true);
           else dl.setAvailable(false);
           if (fname != null) dl.setName(fname);
           if (fsize != null) dl.setDownloadSize(Long.parseLong(fsize));
           try {
             dl.setLinkID(fuid);
           } catch (final Throwable e) {
             // not in JD2
           }
           decryptedLinks.add(dl);
         }
         if (fuid != null && !"file".equalsIgnoreCase(type)) {
           // sub folders maybe possible also ??
           return null; // should get users reporting issue!
         }
       }
     }
   }
   if (name != null) {
     FilePackage fp = FilePackage.getInstance();
     fp.setName(name);
     fp.addLinks(decryptedLinks);
   }
   return decryptedLinks;
 }
コード例 #13
0
 private void processPhotoSet(
     final ArrayList<DownloadLink> decryptedLinks,
     final Browser br,
     final String puid,
     final String fpname,
     final String hashTagsStr)
     throws Exception {
   final String gc = getGoogleCarousel(br);
   if (gc != null) {
     FilePackage fp = null;
     final String JSON =
         new Regex(gc, "<script type=\"application/ld\\+json\">(.*?)</script>").getMatch(0);
     final Map<String, Object> json = JavaScriptEngineFactory.jsonToJavaMap(JSON);
     final String articleBody = (String) json.get("articleBody");
     final String fpName =
         articleBody != null ? articleBody.replaceAll("[\r\n]+", "").trim() : fpname;
     if (fpName != null) {
       fp = FilePackage.getInstance();
       fp.setName(fpName);
     }
     // single entry objects are not in 'list'
     ArrayList<Object> results = null;
     try {
       results = (ArrayList<Object>) JavaScriptEngineFactory.walkJson(json, "image/@list");
     } catch (Throwable t) {
       // single entry ?
       final String[] a = new String[] {(String) json.get("image")};
       results = new ArrayList<Object>(Arrays.asList(a));
     }
     if (results != null) {
       int count = 1;
       final DecimalFormat df = new DecimalFormat(results.size() < 100 ? "00" : "000");
       for (final Object result : results) {
         final String url = (String) result;
         final DownloadLink dl = createDownloadlink("directhttp://" + url);
         if (fp != null) {
           fp.add(dl);
         }
         // cleanup...
         final String filename =
             setFileName(cleanupName(df.format(count) + " - " + fpName), puid)
                 + getFileNameExtensionFromString(url);
         if (!useOriginalFilename) {
           dl.setFinalFileName(filename);
         }
         dl.setAvailable(true);
         setMD5Hash(dl, url);
         setImageLinkID(dl, url, puid);
         if (hashTagsStr != null) {
           dl.setProperty(PROPERTY_TAGS, hashTagsStr);
         }
         dl.setComment(hashTagsStr);
         decryptedLinks.add(dl);
         count++;
       }
     }
   }
 }
コード例 #14
0
  private void pushDiff(DownloadLink dl) {

    for (Entry<Long, ChannelCollector> es : collectors.entrySet()) {
      if (es.getValue().hasIntervalSubscriptions()) {

        es.getValue().setLastPush(System.currentTimeMillis());

        HashMap<String, Object> diff = es.getValue().getDiff(dl);

        for (Entry<String, Object> entry : diff.entrySet()) {
          HashMap<String, Object> dls = new HashMap<String, Object>();
          dls.put("uuid", dl.getUniqueID().getID());
          dls.put(entry.getKey(), entry.getValue());
          EventObject eventObject =
              new SimpleEventObject(
                  DownloadControllerEventPublisher.this,
                  BASIC_EVENT.LINK_UPDATE.name() + "." + entry.getKey(),
                  dls,
                  BASIC_EVENT.LINK_UPDATE.name()
                      + "."
                      + entry.getKey()
                      + "."
                      + dl.getUniqueID().getID());
          // List<Long> publishTo = new ArrayList<Long>();
          // publishTo.add(es.getValue().getSubscriber().getSubscriptionID());
          pushToBuffer(es.getValue().getSubscriber(), eventObject);
        }

        FilePackage p = dl.getParentNode();
        if (p != null) {
          diff = es.getValue().getDiff(p);

          for (Entry<String, Object> entry : diff.entrySet()) {
            HashMap<String, Object> dls = new HashMap<String, Object>();
            dls.put("uuid", p.getUniqueID().getID());
            dls.put(entry.getKey(), entry.getValue());
            SimpleEventObject eventObject =
                new SimpleEventObject(
                    DownloadControllerEventPublisher.this,
                    BASIC_EVENT.PACKAGE_UPDATE.name() + "." + entry.getKey(),
                    dls,
                    BASIC_EVENT.LINK_UPDATE.name()
                        + "."
                        + entry.getKey()
                        + "."
                        + p.getUniqueID().getID());
            // List<Long> publishTo = new ArrayList<Long>();
            // publishTo.add(es.getValue().getSubscriber().getSubscriptionID());
            pushToBuffer(es.getValue().getSubscriber(), eventObject);
            // for (RemoteAPIEventsSender eventSender : remoteEventSenders) {
            // eventSender.publishEvent(eventObject, publishTo);
            // }
          }
        }
      }
    }
  }
コード例 #15
0
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    HashSet<String> set = new HashSet<String>();

    String parameter = param.toString();

    id =
        new Regex(parameter, "(https?://(?!www\\.)[a-z0-9]+\\.7958\\.com(/folder\\-\\d+)?)")
            .getMatch(0);
    profile = new Regex(parameter, "(https?://(?!www\\.)[a-z0-9]+\\.7958\\.com)/").getMatch(0);

    br.getPage(parameter);

    if (br.getRedirectLocation() != null && br.getRedirectLocation().contains("/404.html")) {
      logger.info("Incorrect URL or no longer exists : " + parameter);
      return decryptedLinks;
    }

    String fpName = null;
    // don't mess with this, unless you are feeling brave!
    String[] fpname =
        br.getRegex(
                "<div class=\"qjwm-foc\">[^\r\n]+<a href=\""
                    + profile
                    + "\" target=\"_blank\">(.*?)</a>(-<a href=\""
                    + profile
                    + "/folder-\\d+\">[^<]+</a>){0,2}-?(.*?)</div>")
            .getRow(0);
    if (fpname != null && fpname.length != 0) {
      if (fpname[2] != null && fpname[2].contains("com/folder-")) {
        logger.info("FREAK, this shouldn't be so! : " + br.getURL());
      }
      if ((fpname[2] == null || fpname[2].equals(""))
          && (fpname[0] != null && fpname[0].length() != 0)) {
        fpName = fpname[0];
      } else if ((fpname[2] != null || !fpname[2].equals(""))
          && (fpname[0] != null && fpname[0].length() != 0)) {
        fpName = fpname[0] + " - " + fpname[2];
      }
    }
    if (fpName == null || fpName.length() == 0) {
      logger.info("FREAK, this shouldn't happen! : " + br.getURL());
    }

    parsePage(set, decryptedLinks);
    // Buggy -> Disabled
    // parseNextPage(set, decryptedLinks);

    if (fpName != null) {
      FilePackage fp = FilePackage.getInstance();
      fp.setName(fpName.trim());
      fp.addLinks(decryptedLinks);
    }
    return decryptedLinks;
  }
コード例 #16
0
    static {
        FP = new FilePackage() {
            private static final long serialVersionUID = 1L;

            @Override
            public void _add(DownloadLink... links) {
            }

            @Override
            public void remove(DownloadLink... links) {
            }            

            @Override
            public UniqueAlltimeID getUniqueID() {
                return null;
            }
        };
        FP.setName(_JDT._.controller_packages_defaultname());
        FP.downloadLinkList = new ArrayList<DownloadLink>() {

            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public boolean isEmpty() {
                return true;
            }

            @Override
            public DownloadLink set(int index, DownloadLink element) {
                return null;
            }

            @Override
            public boolean add(DownloadLink e) {
                return true;
            }

            @Override
            public void add(int index, DownloadLink element) {
            }

            @Override
            public boolean addAll(Collection<? extends DownloadLink> c) {
                return false;
            }

            @Override
            public boolean addAll(int index, Collection<? extends DownloadLink> c) {
                return false;
            }

        };
    }
コード例 #17
0
 @Override
 public void onDownloadControllerRemovedPackage(FilePackage pkg) {
   HashMap<String, Object> dls = new HashMap<String, Object>();
   dls.put("uuid", pkg.getUniqueID().getID());
   fire(BASIC_EVENT.REMOVE_CONTENT.name(), null, null);
   fire(
       BASIC_EVENT.REMOVE_PACKAGE.name(),
       dls,
       BASIC_EVENT.REMOVE_PACKAGE.name() + "." + pkg.getUniqueID().getID());
   flushBuffer();
 }
コード例 #18
0
 public FilePackageStorable(FilePackage filePackage) {
   this.filePackage = filePackage;
   links = new ArrayList<DownloadLinkStorable>(filePackage.size());
   boolean readL = filePackage.getModifyLock().readLock();
   try {
     for (DownloadLink link : filePackage.getChildren()) {
       links.add(new DownloadLinkStorable(link));
     }
   } finally {
     filePackage.getModifyLock().readUnlock(readL);
   }
 }
コード例 #19
0
  @SuppressWarnings({"unchecked", "deprecation"})
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    final String parameter = param.toString();
    jd.plugins.hoster.AmpyaCom.initializeSession(this.br);

    br.getPage(jd.plugins.hoster.AmpyaCom.getApiUrl(parameter));
    if (br.getHttpConnection().getResponseCode() == 404) {
      decryptedLinks.add(this.createOfflinelink(parameter));
      return decryptedLinks;
    }

    String fpName = null;
    LinkedHashMap<String, Object> entries =
        (LinkedHashMap<String, Object>) JavaScriptEngineFactory.jsonToJavaObject(br.toString());
    final ArrayList<Object> ressourcelist = (ArrayList<Object>) entries.get("clips");
    for (final Object clipo : ressourcelist) {
      entries = (LinkedHashMap<String, Object>) clipo;
      final String title = (String) entries.get("title");
      final String artist = (String) entries.get("artist_name");
      final String video_id =
          Long.toString(JavaScriptEngineFactory.toLong(entries.get("video_id"), 0));
      if (fpName == null) {
        fpName = (String) entries.get("container_title");
      }
      if (title == null || artist == null || "0".equals(video_id)) {
        continue;
      }
      final DownloadLink dl =
          this.createDownloadlink(
              "http://ampyadecrypted.com/"
                  + System.currentTimeMillis()
                  + new Random().nextInt(1000000000));
      String filename = artist + " - " + title + ".mp4";
      filename = encodeUnicode(filename);
      dl.setFinalFileName(filename);
      dl.setAvailable(true);
      dl.setContentUrl(parameter);
      dl.setProperty("mainlink", parameter);
      dl.setProperty("videoid", video_id);
      decryptedLinks.add(dl);
    }

    if (fpName != null) {
      final FilePackage fp = FilePackage.getInstance();
      fp.setName(Encoding.htmlDecode(fpName.trim()));
      fp.addLinks(decryptedLinks);
    }

    return decryptedLinks;
  }
コード例 #20
0
ファイル: VivaTvDecrypt.java プロジェクト: sn0w/jdownloader
  @SuppressWarnings({"unchecked", "rawtypes"})
  private void decryptMtvGermanyPlaylists() throws Exception {
    br.getPage(parameter);
    fpName = br.getRegex("<title>([^<>\"]*?)</title>").getMatch(0);
    if (fpName == null) {
      /* Fallback to url-packagename */
      fpName = new Regex(this.parameter, "https?://[^/]+/(.+)").getMatch(0);
    }
    ArrayList<Object> ressourcelist = null;
    LinkedHashMap<String, Object> entries = null;
    try {
      final String json = this.br.getRegex("window\\.pagePlaylist = (\\[\\{.*?\\}\\])").getMatch(0);
      ressourcelist = (ArrayList) JavaScriptEngineFactory.jsonToJavaObject(json);

      for (final Object object : ressourcelist) {
        entries = (LinkedHashMap<String, Object>) object;
        final String path = (String) entries.get("path");
        final String url_mrss = (String) entries.get("mrss");
        final String title = (String) entries.get("title");
        final String subtitle = (String) entries.get("subtitle");
        final String video_token = (String) entries.get("video_token");
        final String mgid = jd.plugins.hoster.VivaTv.getMGIDOutOfURL(url_mrss);
        if (url_mrss == null || title == null || video_token == null || mgid == null) {
          throw new DecrypterException("Decrypter broken for link: " + parameter);
        }
        final String contenturl;
        if (path != null) {
          contenturl = "http://" + this.br.getHost() + path;
        } else {
          contenturl = this.parameter;
        }
        String temp_filename = title;
        if (subtitle != null) {
          temp_filename += " - " + subtitle;
        }
        temp_filename += jd.plugins.hoster.VivaTv.default_ext;

        final DownloadLink dl = mgidSingleVideoGetDownloadLink(mgid);
        dl.setLinkID(video_token);
        dl.setName(temp_filename);
        dl.setAvailable(true);
        dl.setContentUrl(contenturl);
        this.decryptedLinks.add(dl);
      }
    } catch (final Throwable e) {
      return;
    }
    final FilePackage fp = FilePackage.getInstance();
    fpName = Encoding.htmlDecode(fpName.trim());
    fp.setName(fpName);
    fp.addLinks(decryptedLinks);
  }
コード例 #21
0
ファイル: PollingAPIImpl.java プロジェクト: sn0w/jdownloader
  @SuppressWarnings("rawtypes")
  private PollingResultAPIStorable getDownloadProgress() {

    // get packageUUIDs who should be filled with download progress of the containing links e.g
    // because they are expanded in the
    // view
    List<Long> expandedPackageUUIDs = new ArrayList<Long>();
    if (!queryParams._getQueryParam("downloadProgress", List.class, new ArrayList()).isEmpty()) {
      List uuidsFromQuery =
          queryParams._getQueryParam("downloadProgress", List.class, new ArrayList());
      for (Object o : uuidsFromQuery) {
        try {
          expandedPackageUUIDs.add((Long) o);
        } catch (ClassCastException e) {
          continue;
        }
      }
    }

    PollingResultAPIStorable prs = new PollingResultAPIStorable();
    prs.setEventName("downloadProgress");

    List<PollingAPIFilePackageStorable> fpas = new ArrayList<PollingAPIFilePackageStorable>();

    for (FilePackage fp : dwd.getRunningFilePackages()) {
      PollingAPIFilePackageStorable fps = new PollingAPIFilePackageStorable(fp);
      fps.setSpeed(dwd.getDownloadSpeedbyFilePackage(fp));

      // if packages is expanded in view, current state of all running links inside the package
      if (expandedPackageUUIDs.contains(fp.getUniqueID().getID())) {
        boolean readL = fp.getModifyLock().readLock();
        try {
          for (DownloadLink dl : fp.getChildren()) {
            if (dwd.getRunningDownloadLinks().contains(dl.getDownloadLinkController())) {
              PollingAPIDownloadLinkStorable pdls = new PollingAPIDownloadLinkStorable(dl);
              fps.getLinks().add(pdls);
            }
          }
        } finally {
          fp.getModifyLock().readUnlock(readL);
        }
      }
      fpas.add(fps);
    }

    org.jdownloader.myjdownloader.client.json.JsonMap eventData =
        new org.jdownloader.myjdownloader.client.json.JsonMap();
    eventData.put("data", fpas);
    prs.setEventData(eventData);

    return prs;
  }
コード例 #22
0
ファイル: VivaTvDecrypt.java プロジェクト: sn0w/jdownloader
 /** This function is able to crawl content of most viacom/mtv websites. */
 private void vivaUniversalCrawler() throws IOException, DecrypterException {
   if (decryptVevo()) {
     return;
   }
   crawlDrupal();
   crawlMgids();
   if (fpName != null) {
     final FilePackage fp = FilePackage.getInstance();
     fpName = Encoding.htmlDecode(fpName.trim());
     fp.setName(fpName);
     fp.addLinks(decryptedLinks);
   }
 }
コード例 #23
0
 /**
  * return a list of all DownloadLinks controlled by this DownloadController
  *
  * @return
  */
 public java.util.List<DownloadLink> getAllDownloadLinks() {
   final java.util.List<DownloadLink> ret = new ArrayList<DownloadLink>();
   final boolean readL = readLock();
   try {
     for (final FilePackage fp : packages) {
       synchronized (fp) {
         ret.addAll(fp.getChildren());
       }
     }
   } finally {
     readUnlock(readL);
   }
   return ret;
 }
コード例 #24
0
 public static File getDownloadDirectory(AbstractNode node) {
   String directory = null;
   if (node instanceof DownloadLink) {
     FilePackage parent = ((DownloadLink) node).getFilePackage();
     if (parent != null) directory = parent.getDownloadDirectory();
   } else if (node instanceof FilePackage) {
     directory = ((FilePackage) node).getDownloadDirectory();
   } /* else if (node instanceof CrawledLink) {
         CrawledPackage parent = ((CrawledLink) node).getParentNode();
         if (parent != null) directory = parent.getDownloadFolder();
     } else if (node instanceof CrawledPackage) {
         directory = ((CrawledPackage) node).getDownloadFolder();
     }*/ else throw new WTFException("Unknown Type: " + node.getClass());
   return getDownloadDirectory(directory);
 }
コード例 #25
0
  @Override
  public void onDownloadControllerUpdatedData(FilePackage pkg, FilePackageProperty property) {

    if (property != null) {
      HashMap<String, Object> dls = null;
      // [DATA_UPDATE.extractionStatus, DATA_UPDATE.finished, DATA_UPDATE.priority,
      // DATA_UPDATE.speed, DATA_UPDATE.url,
      // DATA_UPDATE.enabled, DATA_UPDATE.skipped, DATA_UPDATE.running, DATA_UPDATE.bytesLoaded,
      // DATA_UPDATE.eta,
      // DATA_UPDATE.maxResults, DATA_UPDATE.packageUUIDs, DATA_UPDATE.host, DATA_UPDATE.comment,
      // DATA_UPDATE.bytesTotal,
      // DATA_UPDATE.startAt, DATA_UPDATE.status]

      switch (property.getProperty()) {
        case COMMENT:
          dls = new HashMap<String, Object>();
          dls.put("uuid", pkg.getUniqueID().getID());
          dls.put("comment", pkg.getComment());
          fire(
              BASIC_EVENT.PACKAGE_UPDATE,
              FilePackageProperty.Property.COMMENT.toString(),
              dls,
              pkg.getUniqueID());
          break;
        case FOLDER:
          break;
        case NAME:
          dls = new HashMap<String, Object>();
          dls.put("uuid", pkg.getUniqueID().getID());
          dls.put("name", pkg.getName());
          fire(
              BASIC_EVENT.PACKAGE_UPDATE.name() + ".name",
              dls,
              BASIC_EVENT.PACKAGE_UPDATE.name() + ".name." + pkg.getUniqueID().getID());
          break;
        case PRIORITY:
          dls = new HashMap<String, Object>();
          dls.put("uuid", pkg.getUniqueID().getID());
          dls.put(
              "priority",
              org.jdownloader.myjdownloader.client.bindings.PriorityStorable.valueOf(
                  pkg.getPriorityEnum().name()));
          fire(
              BASIC_EVENT.PACKAGE_UPDATE.name() + ".priority",
              dls,
              BASIC_EVENT.PACKAGE_UPDATE.name() + ".priority." + pkg.getUniqueID().getID());
      }
    }

    fire(BASIC_EVENT.REFRESH_CONTENT.name(), null, BASIC_EVENT.REFRESH_CONTENT.name());
    flushBuffer();
  }
コード例 #26
0
ファイル: DiskTomRu.java プロジェクト: Syn4ck/jdownloader
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    String uid = new Regex(parameter, "([a-z0-9]{7})$").getMatch(0);

    br.getPage(parameter);
    if (br.containsHTML("<div id=\"error\">пакет не найден<")) {
      logger.info("Wrong URL or the package no longer exists.");
      return decryptedLinks;
    }
    String title = br.getRegex("<title>(.*?)</title>").getMatch(0);
    if (title == null) title = "";

    /* Password protected package */
    if (br.containsHTML(">пакет защищен паролем<")) {
      for (int i = 0; i <= 3; i++) {
        final String passCode = Plugin.getUserInput("Enter password for: " + title, param);
        br.postPage(parameter, "put_pwd=" + Encoding.urlEncode(passCode));
        if (br.containsHTML(">пакет защищен паролем<")) continue;
        break;
      }
      if (br.containsHTML(">пакет защищен паролем<"))
        throw new DecrypterException(DecrypterException.PASSWORD);
      if (br.getRedirectLocation() != null) br.getPage(br.getRedirectLocation());
    }

    String domain = new Regex(br.getURL(), "(https?://[^/]+)").getMatch(0);

    String[] links = br.getRegex("href=\"(/download/" + uid + "/[^\"]+)").getColumn(0);
    if (links == null || links.length == 0) {
      logger.warning("Decrypter broken for link: " + parameter);
      return null;
    }

    for (String link : links) {
      decryptedLinks.add(createDownloadlink("directhttp://" + domain + link));
    }

    if (title != null || !title.equals("")) {
      FilePackage fp = FilePackage.getInstance();
      fp.setName(Encoding.htmlDecode(title.trim()));
      fp.addLinks(decryptedLinks);
    }

    return decryptedLinks;
  }
コード例 #27
0
 /**
  * checks if this DownloadController contains a DownloadLink with given url
  *
  * @param url
  * @return
  */
 public boolean hasDownloadLinkwithURL(final String url) {
   if (url != null) {
     final String correctUrl = url.trim();
     final boolean readL = readLock();
     try {
       for (final FilePackage fp : packages) {
         synchronized (fp) {
           for (DownloadLink dl : fp.getChildren()) {
             if (correctUrl.equalsIgnoreCase(dl.getDownloadURL())) return true;
           }
         }
       }
     } finally {
       readUnlock(readL);
     }
   }
   return false;
 }
コード例 #28
0
 public void setLinks(java.util.List<DownloadLinkStorable> links) {
   if (links != null) {
     this.links = links;
     synchronized (filePackage) {
       for (DownloadLinkStorable link : links) {
         filePackage.add(link._getDownloadLink());
       }
     }
   }
 }
コード例 #29
0
  @Override
  public void onAction(ActionEvent e) {
    if (!UserIO.isOK(
        UserIO.getInstance()
            .requestConfirmDialog(
                UserIO.DONT_SHOW_AGAIN | UserIO.DONT_SHOW_AGAIN_IGNORES_CANCEL,
                JDL.L(
                    "jd.gui.swing.jdgui.menu.actions.RemoveDisabledAction.message",
                    "Do you really want to remove all disabled DownloadLinks?")))) return;

    if (!LinkGrabberPanel.getLinkGrabber().isNotVisible()) {
      synchronized (LinkGrabberController.ControllerLock) {
        synchronized (LinkGrabberController.getInstance().getPackages()) {
          ArrayList<LinkGrabberFilePackage> selected_packages =
              new ArrayList<LinkGrabberFilePackage>(
                  LinkGrabberController.getInstance().getPackages());
          selected_packages.add(LinkGrabberController.getInstance().getFilterPackage());
          for (LinkGrabberFilePackage fp2 : selected_packages) {
            ArrayList<DownloadLink> links = new ArrayList<DownloadLink>(fp2.getDownloadLinks());
            for (DownloadLink dl : links) {
              if (!dl.isEnabled()) fp2.remove(dl);
            }
          }
        }
      }
    } else {
      DownloadController dlc = DownloadController.getInstance();
      ArrayList<DownloadLink> downloadstodelete = new ArrayList<DownloadLink>();
      synchronized (dlc.getPackages()) {
        for (FilePackage fp : dlc.getPackages()) {
          synchronized (fp.getDownloadLinkList()) {
            for (DownloadLink dl : fp.getDownloadLinkList()) {
              if (!dl.isEnabled()) downloadstodelete.add(dl);
            }
          }
        }
      }
      for (DownloadLink dl : downloadstodelete) {
        dl.getFilePackage().remove(dl);
      }
    }
  }
コード例 #30
0
ファイル: VivaTvDecrypt.java プロジェクト: sn0w/jdownloader
 private void decrypLogoTvCom() throws Exception {
   boolean isPlaylist = false;
   final String playlist_id = new Regex(this.parameter, "^.+#id=(\\d+)$").getMatch(0);
   String url_name = new Regex(this.parameter, "/([A-Za-z0-9\\-_]+)\\.j?html").getMatch(0);
   if (playlist_id != null) {
     /* Playlist */
     this.br.getPage(
         "http://www.logotv.com/global/music/videos/ajax/playlist.jhtml?id=" + playlist_id);
     decryptMtvComPlaylists();
     isPlaylist = this.decryptedLinks.size() > 0;
   }
   if (!isPlaylist) {
     /* Feed */
     /* We have no feed-url so let's use this */
     br.getPage(parameter);
     if (decryptVevo()) {
       return;
     }
     logger.info("Current link is NO VEVO link");
     if (!br.containsHTML("\"video\":")) {
       decryptedLinks.add(this.createOfflinelink(parameter));
       return;
     }
     this.mgid = br.getRegex("media\\.mtvnservices\\.com/(mgid[^<>\"]*?)\"").getMatch(0);
     if (this.mgid == null) {
       this.decryptedLinks = null;
       return;
     }
     final String feedURL = "http://www.logotv.com/player/includes/rss.jhtml?uri=" + this.mgid;
     br.getPage(feedURL);
     decryptFeed();
   }
   if (fpName == null) {
     fpName = url_name;
   }
   if (fpName != null) {
     final FilePackage fp = FilePackage.getInstance();
     fpName = Encoding.htmlDecode(fpName.trim());
     fp.setName(fpName);
     fp.addLinks(decryptedLinks);
   }
 }