ivkos / wallhaven4j

Wallhaven API for Java
MIT License
18 stars 1 forks source link

sometimes could not parse favorites count in thumbnail of Wallpaper #1

Closed JoeyLearnsToCode closed 7 years ago

JoeyLearnsToCode commented 7 years ago

Hi, I'm using your api, so above all, thank you for what you did :) Here is my problem: some time it work normal, but sometimes it goes wrong, and throw exception below:

Exception in thread "Thread-6" com.ivkos.wallhaven4j.util.exceptions.ParseException: Could not parse favorites count in thumbnail of Wallpaper
    at com.ivkos.wallhaven4j.util.exceptions.DescriptiveParseExceptionSupplier.lambda$forResource$1(DescriptiveParseExceptionSupplier.java:26)
    at com.ivkos.wallhaven4j.util.exceptions.DescriptiveParseExceptionSupplier$$Lambda$2.get(Unknown Source)
    at com.ivkos.wallhaven4j.util.exceptions.DescriptiveParseExceptionSupplier.get(DescriptiveParseExceptionSupplier.java:34)
    at com.ivkos.wallhaven4j.util.exceptions.DescriptiveParseExceptionSupplier.get(DescriptiveParseExceptionSupplier.java:8)
    at com.ivkos.wallhaven4j.util.htmlparser.OptionalSelector.orElseThrow(OptionalSelector.java:45)
    at com.ivkos.wallhaven4j.util.pagecrawler.thumbnailpage.ThumbnailTransformer.transform(ThumbnailTransformer.java:72)
    at com.ivkos.wallhaven4j.util.pagecrawler.thumbnailpage.ThumbnailPageCrawler$$Lambda$1.apply(Unknown Source)
    at com.google.common.collect.Lists$TransformingRandomAccessList$1.transform(Lists.java:640)
    at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
    at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
    at java.util.Collections$UnmodifiableCollection.toArray(Collections.java:1033)
    at java.util.ArrayList.addAll(ArrayList.java:577)
    at com.ivkos.wallhaven4j.util.pagecrawler.thumbnailpage.ThumbnailPageCrawler.getPageSequence(ThumbnailPageCrawler.java:94)
    at com.ivkos.wallhaven4j.Wallhaven.search(Wallhaven.java:171)
    at cn.dalin.WallhavenFetcherController.lambda$startDownloadOnClick$7(WallhavenFetcherController.java:114)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.ivkos.wallhaven4j.util.exceptions.ParseException: No such element: a.wall-favs
    at com.ivkos.wallhaven4j.util.htmlparser.OptionalSelector.orElseThrow(OptionalSelector.java:48)

Actually, I know what dose that means, I'm just wondering if it's due to I am in China and my connection to Wallhaven is not fast enough? Is there any other possible reason?

ivkos commented 7 years ago

Hey @hahadalin Glad you find the library useful. It's not your connection that's causing this issue, but rather a parsing problem. I'll look into it. Thanks for the report!

ivkos commented 7 years ago

Fixed. Please update to v1.1.3 Cheers!