package me.devsaki.hentoid.parsers.images;

import androidx.annotation.NonNull;

import org.jsoup.nodes.Document;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import me.devsaki.hentoid.database.domains.Content;

import static me.devsaki.hentoid.util.network.HttpHelper.getOnlineDocument;

public class ASMHentaiParser extends BaseParser {

    @Override
    protected List<String> parseImages(@NonNull Content content) throws IOException {
        List<String> result = new ArrayList<>();

        // Fetch the reader page
        Document doc = getOnlineDocument(content.getReaderUrl());
        if (doc != null) {
            String imgUrl = "https:" +
                    doc.select("div.full_image")
                            .select("a")
                            .select("img")
                            .attr("src");

            String ext = imgUrl.substring(imgUrl.lastIndexOf('.'));

            for (int i = 0; i < content.getQtyPages(); i++) {
                String img = imgUrl.substring(0, imgUrl.lastIndexOf('/') + 1) + (i + 1) + ext;
                result.add(img);
            }
        }

        return result;
    }
}

@@ -102,24 +102,58 @@
 es.Document;
+%0Aimport org.jsoup.select.Elements;
 %0A%0Aimport jav
@@ -695,83 +695,299 @@
     
-String imgUrl = %22https:%22 +%0A                    doc.select(%22div.full_image%22)
+Elements imgContainer = doc.select(%22div.full_image%22); // New ASM layout%0A            if (imgContainer.isEmpty())%0A                imgContainer = doc.select(%22div.full_gallery%22); // Old ASM layout; current ASM Comics layout%0A            String imgUrl = %22https:%22 +%0A                    imgContainer
 %0A   

Align with ASM Comics layout (which is the old ASM Hentai Layout...)