RicterZ / nhentai

nhentai doujinshi downloader
http://nhentai.net
MIT License
824 stars 115 forks source link

cbz creatin error #216

Closed SomeRandomDude870 closed 2 years ago

SomeRandomDude870 commented 3 years ago

Hi, I have downloaded six galleries and for two of them there could not be an .cbz created.

`Traceback (most recent call last):
  File "C:\myProgramme\Python\Scripts\nhentai-script.py", line 11, in <module>
    load_entry_point('nhentai==0.4.0', 'console_scripts', 'nhentai')()
  File "C:\myProgramme\Python\lib\site-packages\nhentai-0.4.0-py3.8.egg\nhentai\command.py", line 88, in main
    generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir)
  File "C:\myProgramme\Python\lib\site-packages\nhentai-0.4.0-py3.8.egg\nhentai\utils.py", line 186, in generate_cbz
    with zipfile.ZipFile(cbz_filename, 'w') as cbz_pf:
  File "C:\myProgramme\Python\lib\zipfile.py", line 1250, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: "

Not sure why I get this error. The directory is there.

RicterZ commented 3 years ago

Please provide the full command which you ran

On Fri, May 21, 2021 at 9:57 AM SomeRandomDude870 @.***> wrote:

Hi, I have downloaded six galleries and for two of them there could not be an .cbz created.

`Traceback (most recent call last): File "C:\myProgramme\Python\Scripts\nhentai-script.py", line 11, in load_entry_point('nhentai==0.4.0', 'console_scripts', 'nhentai')() File "C:\myProgramme\Python\lib\site-packages\nhentai-0.4.0-py3.8.egg\nhentai\command.py", line 88, in main generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir) File "C:\myProgramme\Python\lib\site-packages\nhentai-0.4.0-py3.8.egg\nhentai\utils.py", line 186, in generate_cbz with zipfile.ZipFile(cbz_filename, 'w') as cbz_pf: File "C:\myProgramme\Python\lib\zipfile.py", line 1250, in init self.fp = io.open(file, filemode) FileNotFoundError: [Errno 2] No such file or directory: "

Not sure why I get this error. The directory is there.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RicterZ/nhentai/issues/216, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIJXR5LPVIICHIKE5EOT7TTOW4Z7ANCNFSM45IHAD2Q .

-- Regards, Ricter Zheng

SomeRandomDude870 commented 3 years ago

Don´t know what produced it. But this one does too: nhentai -D -o D:\test -C --id=359744

RicterZ commented 3 years ago
[16:50:30] [INFO] Starting to download https://i.nhentai.net/galleries/1914591/20.jpg ...
[16:50:32] [INFO] Writing CBZ file to path: D:\test\[359744][chilt][(C95) [Aohimo Familia (Chilt Aohimo)] Kanojo no Imouto ga Kyonyuu MiniSkir JK de Koa…\..\[359744][chilt][(C95) [Aohimo Familia (Chilt Aohimo)] Kanojo no Imouto ga Kyonyuu MiniSkir JK de Koa….cbz
[16:50:32] [INFO] Comic Book CBZ file has been written to 'D:\test\[359744][chilt][(C95) [Aohimo Familia (Chilt Aohimo)] Kanojo no Imouto ga Kyonyuu MiniSkir JK de Koa…'
[16:50:32] [INFO] All done.

Cannot reproduct it. Anyway if it's a problem of filename, try:

nhentai -D -o D:\test -C --id=359744  --format='%i'
SomeRandomDude870 commented 3 years ago

With: nhentai --id 355670 -D -o D:\test -C --format='%i'

I still get:


Traceback (most recent call last):
  File "C:\myProgramme\Python\Scripts\nhentai-script.py", line 11, in <module>
    load_entry_point('nhentai==0.4.16', 'console_scripts', 'nhentai')()
  File "c:\myprogramme\python\lib\site-packages\nhentai\command.py", line 102, in main
    generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir)
  File "c:\myprogramme\python\lib\site-packages\nhentai\utils.py", line 177, in generate_cbz
    serialize_comicxml(doujinshi_obj, doujinshi_dir)
  File "c:\myprogramme\python\lib\site-packages\nhentai\serializer.py", line 42, in serialize_comicxml
    xml_write_simple_tag(f, 'Summary', doujinshi.info.subtitle)
  File "c:\myprogramme\python\lib\site-packages\nhentai\serializer.py", line 75, in xml_write_simple_tag
    f.write('{}<{}>{}</{}>\n'.format(' ' * indent, name, escape(str(val)), name))
  File "c:\myprogramme\python\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 11-16: character maps to <undefined>```
SomeRandomDude870 commented 3 years ago

It seems that you just have to add "encoding="utf-8"" to the f.write in xml_write_simple.

RicterZ commented 3 years ago

What's your python version?

ghost commented 2 years ago

+1 on this issue.

Sauccery commented 2 years ago

Related Issue with the command nhentai --id 359744 --cbz:

Traceback (most recent call last):
  File "C:\Python310\Scripts\nhentai-script.py", line 33, in <module>
    sys.exit(load_entry_point('nhentai==0.4.16', 'console_scripts', 'nhentai')())
  File "C:\Python310\lib\site-packages\nhentai\command.py", line 102, in main
    generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir)
  File "C:\Python310\lib\site-packages\nhentai\utils.py", line 177, in generate_cbz
    serialize_comicxml(doujinshi_obj, doujinshi_dir)
  File "C:\Python310\lib\site-packages\nhentai\serializer.py", line 42, in serialize_comicxml
    xml_write_simple_tag(f, 'Summary', doujinshi.info.subtitle)
  File "C:\Python310\lib\site-packages\nhentai\serializer.py", line 75, in xml_write_simple_tag
    f.write('{}<{}>{}</{}>\n'.format(' ' * indent, name, escape(str(val)), name))
  File "C:\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 17-25: character maps to <undefined>

Seems to be an XML encoding issue: https://github.com/RicterZ/nhentai/blob/4b15744cebc124e50796dbd12ce64d839429b42a/nhentai/serializer.py#L43

Sauccery commented 2 years ago

Might be off topic, but it seems https://github.com/RicterZ/nhentai/blob/4b15744cebc124e50796dbd12ce64d839429b42a/nhentai/parser.py#L114 (line involved in this issue) fetches doujinshi information from nhentai.net/g/359744 and then parses the html. Why is this preferred over directly fetching the api https://nhentai.net/api/gallery/359744?

RicterZ commented 2 years ago

Seems it works now:

[16:32:17] [INFO] Writing CBZ file to path: ./[359744][chilt][(C95) [Aohimo Familia (Chilt Aohimo)] Kanojo no Imouto ga Kyonyuu MiniSkir JK de Koa…/../[359744][chilt][(C95) [Aohimo Familia (Chilt Aohimo)] Kanojo no Imouto ga Kyonyuu MiniSkir JK de Koa….cbz
[16:32:17] [INFO] Comic Book CBZ file has been written to './[359744][chilt][(C95) [Aohimo Familia (Chilt Aohimo)] Kanojo no Imouto ga Kyonyuu MiniSkir JK de Koa…'
[16:32:17] [INFO] 🍻 All done.