public boolean checkHoster(CrawledLink link) throws NoDownloadLinkException {
   if (getHosterRule() != null) {
     if (link.getDownloadLink() == null) {
       throw new NoDownloadLinkException();
     }
     return getHosterRule().matches(link.getURL());
   }
   return true;
 }
Example #2
0
 protected List<DownloadLink> loadContainerFile(File file) {
   final LinkCrawler lc = LinkCrawler.newInstance();
   lc.crawl(file.toURI().toString());
   lc.waitForCrawling();
   final ArrayList<DownloadLink> ret = new ArrayList<DownloadLink>(lc.getCrawledLinks().size());
   for (final CrawledLink link : lc.getCrawledLinks()) {
     DownloadLink dl = link.getDownloadLink();
     if (dl == null) {
       final String url = link.getURL();
       if (url != null) {
         dl = new DownloadLink(null, null, null, url, true);
       }
     }
     if (dl != null) {
       ret.add(dl);
     }
   }
   return ret;
 }
Example #3
0
 @Override
 public Boolean isSupported(final ArchiveFactory factory, final boolean allowDeepInspection) {
   if (splitType.matches(factory.getFilePath())) {
     if (factory instanceof DownloadLinkArchiveFactory) {
       for (final DownloadLink link : ((DownloadLinkArchiveFactory) factory).getDownloadLinks()) {
         final ExtensionsFilterInterface hint =
             CompiledFiletypeFilter.getExtensionsFilterInterface(link.getMimeHint());
         if (hint != null
             && !hint.isSameExtensionGroup(CompiledFiletypeFilter.ArchiveExtensions.NUM)) {
           return false;
         }
       }
     } else if (factory instanceof CrawledLinkFactory) {
       for (final CrawledLink link : ((CrawledLinkFactory) factory).getLinks()) {
         final DownloadLink dlLink = link.getDownloadLink();
         if (dlLink != null) {
           final ExtensionsFilterInterface hint =
               CompiledFiletypeFilter.getExtensionsFilterInterface(dlLink.getMimeHint());
           if (hint != null
               && !hint.isSameExtensionGroup(CompiledFiletypeFilter.ArchiveExtensions.NUM)) {
             return false;
           }
         }
       }
     }
     if (allowDeepInspection) {
       try {
         return SplitType.createArchive(factory, splitType, allowDeepInspection) != null;
       } catch (ArchiveException e) {
         getLogger().log(e);
       }
     } else {
       return true;
     }
   }
   return false;
 }