1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 | package Torello.HTML.Tools.NewsSite;
import static Torello.Java.C.RESET;
import static Torello.Java.C.BRED;
import static Torello.Java.C.YELLOW;
import Torello.HTML.TagNode;
import java.io.IOException;
class SkipBannerImages
{
static boolean run(final RECORD r) throws IOException
{
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Check the banner-situation. Count all images, and less that number by "banner-images"
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
//
// IMPORTANT NOTE: THIS ISN'T ALWAYS USEFUL OR USEABLE... IT IS **SOMETIMES**
// USEFUL
int imageCount = r.imageURLs.size();
if (r.bannerAndAdFinder != null)
for (int pos : r.imagePosArr)
if (r.bannerAndAdFinder
.test(((TagNode) r.article.elementAt(pos)).AV("src"))
)
imageCount--;
if (r.skipArticlesWithoutPhotos && (imageCount == 0))
{
r.log.append(
BRED + "\tAll images inside article were banner images" +
RESET + '\n'
);
r.ret.elementAt(r.outerCounter())
.add(DownloadResult.NO_IMAGES_FOUND_ONLY_BANNERS);
return false;
}
if (r.bannerAndAdFinder != null)
r.log.append(
"\tArticle contains (" + YELLOW + imageCount + RESET + ") " +
"non-banner image TagNodes.\n"
);
return true;
}
}
|