postaddictme / instagram-java-scraper

Instagram Java Scraper. Get account information, photos, videos and comments.
449 stars 150 forks source link

Issue with "ModelMapper.java" #62

Closed Saddamko closed 6 years ago

Saddamko commented 6 years ago

In this code section: return getUnmarshallerCache().computeIfAbsent(mappingFile, mapping -> ThreadLocal.withInitial(() -> getUnmarshaller(mapping))); compiler show error Cannot find symbol: getUnmarshallerCache().

What is the getUnmarshallerCache() method? Where it is defined? Tnx!

igor-suhorukov commented 6 years ago

Hi @Saddamko,

getUnmarshallerCache() bytecode generated by https://projectlombok.org in compile time. If you try to compile it in IntelliJ Idea install plugin. In case of Eclipse follow instruction

 @Getter(AccessLevel.PROTECTED)
    private final ConcurrentHashMap<String, ThreadLocal<Unmarshaller>> unmarshallerCache = new ConcurrentHashMap<>();

Gradle script build code without any issues.

Saddamko commented 6 years ago

Thanks! It's right idea! I'm use Netbean 8.2, and next instruction is help me: The Netbeans editor is compatible with lombok. Add lombok.jar to the project libraries. In the project properties, in the section Build – Compiling, check the 'Enable Annotation Processing in Editor' checkbox.

Saddly, I'm stuck with some another troubles (all project is fine, but with earlies releases I got more success:) After last update, just part of code is working. For example, it's not working now: instagram.addMediaComment("Bb605TuhIEG", "test");

run: line 1:0 no viable alternative at character '<' line 1:1 no viable alternative at character '!' line 1:2 no viable alternative at character 'D'

Can You check this sample? (instagram.addMediaComment("Bb605TuhIEG", "test");)

igor-suhorukov commented 6 years ago

Thanks @Saddamko Vladimir! Your error looks like response in html/xml (<!DOCTYPE>) is not in JSON format. May be you temporary blocked by service... For me all works fine on another posts. Could you please capture response (value of responseBody.string() ) in debug mode on line return mapper.mapMediaCommentResponse(responseBody.byteStream()); of class me.postaddict.instagram.scraper.Instagram

We need to extend error handling for such cases in instagram-java-scraper

igor-suhorukov commented 6 years ago

@Saddamko this is not mapping issue. Try to configure http client in following way

HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

OkHttpClient httpClient = new OkHttpClient.Builder()
        .addNetworkInterceptor(loggingInterceptor)
        .addInterceptor(new ErrorInterceptor())
        .cookieJar(new DefaultCookieJar(new CookieHashSet()))
        .build();
igor-suhorukov commented 6 years ago

Hi Vladimir @Saddamko , any updates?

Saddamko commented 6 years ago

Sorry for delay with my answer! It's OK now. For my shame, I did't know, what is happened, but my code now is working w/o problems. Thanks!

igor-suhorukov commented 6 years ago

@Saddamko good news! In case of similar issue try to configure HttpClient with following interceptors:

OkHttpClient httpClient = new OkHttpClient.Builder()
        .addNetworkInterceptor(loggingInterceptor)
        .addInterceptor(new ErrorInterceptor())