Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhenixScans Extension #234

Open
1 task done
ShiroIV opened this issue Apr 23, 2024 · 2 comments
Open
1 task done

PhenixScans Extension #234

ShiroIV opened this issue Apr 23, 2024 · 2 comments

Comments

@ShiroIV
Copy link

ShiroIV commented Apr 23, 2024

Source name

PhenixScans.fr

Source URL

https://phenixscans.fr

Package type

manga

Source language

fr

Other details

Can you add this Extension I tried to do it but impossible to adjust the 'watch' part it just won't load correctly and the response body was the main page

Acknowledgements

  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
@ShiroIV
Copy link
Author

ShiroIV commented May 22, 2024

There is my code

// ==MiruExtension==
// @name         PhenixScans
// @version      v0.1
// @author       Grand_K
// @lang         fr
// @license      MIT
// @icon         https://pbs.twimg.com/profile_images/1663318721878794247/bjV3Wrx4_400x400.jpg
// @package      phenixscans.fr
// @type         manga
// @webSite      https://phenixscans.fr/
// ==/MiruExtension==

export default class extends Extension {
    async req(url) {
        return this.request(url, {
            headers: {
                "Miru-Url": await this.getSetting("phenixscans"),
            },
        });
    }

    async load() {
        this.registerSetting({
            title: "PhenixScans Base URL",
            key: "phenixscans",
            type: "input",
            desc: "This is the URL where the comics are fetched from",
            defaultValue: "https://phenixscans.fr",
        });

        //Use From Asuratoon.com Extension
        this.registerSetting({
            title: "Reverse Order of Chapters",
            key: "reverseChaptersOrder",
            type: "toggle",
            description: "Reverse the order of chapters in ascending order",
            defaultValue: "true",
        });
    }

    async latest(page) {
        let res = await this.req(`/manga/?page=${page}&order=update`);

        let items = await this.querySelectorAll(res, "div.listupd > div.bs > div.bsx");

        let respItems = await Promise.all(items.map(async (item) => ({
            url: await this.getAttributeText(item.content, "a", "href"),
            cover: await this.getAttributeText(item.content, "img", "src"),
            title: await this.getAttributeText(item.content, "a", "title")
        })))

        return respItems
    }

    async search(kw, page) {
        let res = await this.req(`/page/${page}/?s=${kw}`);

        let items = await this.querySelectorAll(res, "div.listupd > div.bs > div.bsx");

        let respItems = await Promise.all(items.map(async (item) => ({
            url: await this.getAttributeText(item.content, "a", "href"),
            cover: await this.getAttributeText(item.content, "img", "src"),
            title: await this.getAttributeText(item.content, "a", "title")
        })))
        return respItems;
    }

    async detail(url) {
        // Implement the detail method to get details of a specific comic
        let res  = await this.request('',{
            headers: {
                "Miru-Url": url,
            }
        })

        let title = await this.querySelector(res, "title").text
        const cover = await this.querySelector(res, "img.wp-post-image").getAttributeText("src");

        const desclist = await this.querySelectorAll(res, "div.entry-content.entry-content-single > p");
        const desc = await Promise.all(desclist.map(async (element) => {
            const decHtml = await element.content;
            return await this.querySelector(decHtml, "p").text;
        })).then((texts) => texts.join(""));

        const epiList = await this.querySelectorAll(res, "#chapterlist > ul > li");
        const episodes = await Promise.all(epiList.map(async (element) => {
            const html = await element.content;
            const name = (await this.querySelector(html, "span.chapternum").text).trim().replace(/[\n\t]/g, '');;
            const url = await this.getAttributeText(html, "a", "href");
            return {
                name,
                url: url,
            };
        }));

        //Use From Asuratoon.com Extension
        if (await this.getSetting("reverseChaptersOrder") === "true") {
            episodes.reverse();
        }

        return {
            title,
            cover,
            desc,
            episodes: [
                {
                    title: "Chapitres",
                    url: episodes,
                },
            ],
        };
    }

    async watch(url) {
        const res = await this.request("", {
            headers: {
                "Miru-Url": url,
            },
        });

        const images = await Promise.all((await this.querySelectorAll(res, "div#readerarea > img")).map(async (element) => {
            const html = await element.content;
            return this.getAttributeText(html, "img", "src");
        }));

        return {
            urls: images,
        };
    }
}

@ShiroIV
Copy link
Author

ShiroIV commented May 22, 2024

I think the problem come from the img is lazy loaded and i don't know how to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant