Witness-senpai / fakku-downloader

Script that allows download manga directly from fakku.net.
MIT License
53 stars 12 forks source link

Some content doesn't download properly #44

Open shinji257 opened 1 year ago

shinji257 commented 1 year ago

Example: https://www.fakku.net/hentai/cat-studio-r18-part-1-english

For some reason it gets the wrong width and height for these pages. There are a bunch of others that are affected as well.

If I remove (comment) the block then it grabs the whole image but it is getting more canvas than it should (because it isn't resizing anymore). The image sizes it detects for the pages is 300x150 for the cover and 300x424 for the other pages.

If I load the doujin in a normal login session it gives appropriate data that I'd expect.

Platform: Windows 11 Python: 3.10.5 ChromeDriver 110.0.5481.77

shinji257 commented 1 year ago

After some digging replacing

                        width = self.browser.execute_script(
                            f"return document.getElementsByTagName('canvas')[{n-2}].width"
                        )
                        height = self.browser.execute_script(
                            f"return document.getElementsByTagName('canvas')[{n-2}].height"
                        )

With

                        width = self.browser.execute_script(
                            f"return document.getElementsByClassName('layer')[{n-2}].firstChild.width"
                        )
                        height = self.browser.execute_script(
                            f"return document.getElementsByClassName('layer')[{n-2}].firstChild.height"
                        )

in downloader.py may be viable. Currently testing but it seems to work. When looking in Firefox (and Chrome) the former gave the values for the wrong element for some reason (not your scripts fault!) but the latter seemed to give the correct size. You may know better than me on this.

Testing: (Known good -- https://www.fakku.net/hentai/1-on-5-english) image (Problem example) image

shinji257 commented 1 year ago

May be the same issue as #13 but hard to say since they indicate it is random. I was able to reproduce consistently.

12 seems to have the same idea on the fix from 2021 but theirs is more complicated.