Skip to content

[ BUG ] no webp support, includes fix #181

@KawaiiUser-chan

Description

@KawaiiUser-chan

Describe the Bug

Can't download webp images


Steps To Reproduce

try to get images from #538703

System Information

OS Name Build No. Python Version App Version
REDACTED REDACTED REDACTED REDACTED

Error message & warnings

  File "d:\prg\saveArt\server\hentai.py", line 788, in image_urls
    return [image.url for image in self.pages]
                                   ^^^^^^^^^^
  File "d:\prg\saveArt\server\hentai.py", line 781, in pages
    return [Page(image_url(num + 1), Extension.convert(_['t']), _['w'], _['h']) for num, _ in enumerate(pages)]
                 ^^^^^^^^^^^^^^^^^^
  File "d:\prg\saveArt\server\hentai.py", line 780, in <lambda>
    image_url = lambda num: f"https://i.nhentai.net/galleries/{self.media_id}/{num}{extension(num-1)}"
                                                                                    ^^^^^^^^^^^^^^^^
  File "d:\prg\saveArt\server\hentai.py", line 779, in <lambda>
    extension = lambda num: Extension.convert(pages[num]['t'])
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\prg\saveArt\server\hentai.py", line 401, in convert
    return f".{cls(key).name.lower()}"
               ^^^^^^^^
  File "C:\Python312\Lib\enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'w' is not a valid Extension

Code samples

    for u in doujin.image_urls:
        nh_img_url.append(u)

Expected behavior

Images download like usual with jpg, png formats

Additional context

Just add WEBP = 'w' to line 385 like this:

@unique
class Extension(Enum):
"""
Known file extensions used by nhentai images.
"""
JPG = 'j'
PNG = 'p'
GIF = 'g'
WEBP = 'w'

...

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions