示例#1
0
 @Override
 public boolean canHandle(Uri link, Page page, String mime) {
   log.debug("CanHandle", link);
   if (link.getDomain().equalsIgnoreCase("furaffinity.net") && "text/html".equals(mime)) {
     return true;
   }
   return false;
 }
示例#2
0
 @Override
 protected boolean processPage(
     Page source, Uri page, Uri referer, String title, String basehref, int depth) {
   login(Session.conCont);
   if (page.getPath().startsWith("/view/") || page.getPath().startsWith("/full/")) {
     List<Tag> tags = source.getTags("script");
     int index = 0;
     boolean fHasContent = false;
     for (Tag tag : tags) {
       String content = tag.getChild(0).getContent();
       index = content.indexOf("full_url");
       if (index != -1) {
         index = content.indexOf('"', index) + 1;
         Uri url =
             new Uri(content.substring(index, content.indexOf('"', index)), page.getScheme());
         session.addLink(url, page, false);
         fHasContent = true;
         break;
       }
     }
     if (!fHasContent) {
       tags = source.getTags("object");
       for (Tag tag : tags) {
         if ("application/x-shockwave-flash".equals(tag.getProperty(Constants.atr_type))) {
           if (tag.hasProperty(Constants.atr_data))
             session.addLink(
                 new Uri(tag.getProperty(Constants.atr_data), page.getScheme()), page, false);
         }
       }
     }
   } else if (page.getPath().startsWith("/gallery/")
       || page.getPath().startsWith("/scraps/")
       || page.getPath().startsWith("/favorites/")) {
     boolean fHasContent = false;
     List<Tag> tags;
     tags = source.getTags("a");
     for (Tag tag : tags) {
       if (tag.getProperty(Constants.atr_href) != null
           && tag.getProperty(Constants.atr_href).startsWith("/view/")) {
         addToReadQueue(
             new Uri(createURL(tag.getProperty(Constants.atr_href), page, basehref)), page, depth);
         fHasContent = true;
       }
     }
     // * TODO: make this possible in the page read
     /* only search for the next button if this page has content.
      * FurAffinity will produce a page even if it is past the number of images available
      */
     if (fHasContent) {
       tags = source.getTags("button");
       for (Tag tag : tags) {
         if (tag.getChild(0).getContent().equalsIgnoreCase("Next")) {
           addToReadQueue(
               new Uri(
                   createURL(tag.getParent().getProperty(Constants.atr_action), page, basehref)),
               page,
               depth == 0 ? depth : depth - 1);
           break;
         }
       }
     }
     // */
   }
   return true;
 }