manga-py/manga-py

Mangadex json error

toprak opened this issue · 7 comments

toprak commented

Bug report

Environment (please complete the following information):

Description Data
OS Arch Linux
Python version Python 3.10.9
Pip version pip 23.0.1
Manga-py version 1.33.2
URL https://mangadex.org/title/687abfb8-6b36-42e5-bf97-a3853de172eb/itsukasei-metsubou-syndrome

To Reproduce:

Steps to reproduce the behavior:

  1. open terminal
  2. python3 -m manga_py https://mangadex.org/title/687abfb8-6b36-42e5-bf97-a3853de172eb/itsukasei-metsubou-syndrome --name 'Manga Name' -z and enter
  3. see the error

Additional context

  File "/home/tbb/.local/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           │                 │            └ {}
           │                 └ <Response [410]>
           └ <module 'json' from '/usr/lib/python3.10/json/__init__.py'>
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           │                       └ '<!doctype html>\n<html lang="en">\n<head>\n  <meta charset="utf-8">\n  <meta name="viewport" content="width=device-width, initi...
           └ <json.decoder.JSONDecoder object at 0x7fab67528040>
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               │               │      │  └ '<!doctype html>\n<html lang="en">\n<head>\n  <meta charset="utf-8">\n  <meta name="viewport" content="width=device-width, initi...
               │               │      └ <built-in method match of re.Pattern object at 0x7fab673abe00>
               │               └ '<!doctype html>\n<html lang="en">\n<head>\n  <meta charset="utf-8">\n  <meta name="viewport" content="width=device-width, initi...
               └ <json.decoder.JSONDecoder object at 0x7fab67528040>
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
          │                                  └ '<!doctype html>\n<html lang="en">\n<head>\n  <meta charset="utf-8">\n  <meta name="viewport" content="width=device-width, initi...
          └ <class 'json.decoder.JSONDecodeError'>
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
         │     └ {'__name__': '__main__', '__doc__': None, '__package__': 'manga_py', '__loader__': <_frozen_importlib_external.SourceFileLoader ...
         └ <code object <module> at 0x7fab6767ed90, file "/home/tbb/.local/lib/python3.10/site-packages/manga_py/__main__.py", line 1>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/__main__.py", line 3, in <module>
    main()
    └ <function main at 0x7fab65fc11b0>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/util.py", line 124, in main
    exit(run_util(args))
    │    │        └ {'url': 'https://mangadex.org/title/687abfb8-6b36-42e5-bf97-a3853de172eb/itsukasei-metsubou-syndrome', 'name': 'Manga Name', 'de...
    │    └ <function run_util at 0x7fab65fc1090>
    └ <built-in function exit>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/util.py", line 82, in run_util
    _info = _run_util(args)
            │         └ {'url': 'https://mangadex.org/title/687abfb8-6b36-42e5-bf97-a3853de172eb/itsukasei-metsubou-syndrome', 'name': 'Manga Name', 'de...
            └ <function _run_util at 0x7fab65fc0f70>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/util.py", line 42, in _run_util
    Cli(args, _info).start()
    │   │     └ <manga_py.info.Info object at 0x7fab65f9f580>
    │   └ {'url': 'https://mangadex.org/title/687abfb8-6b36-42e5-bf97-a3853de172eb/itsukasei-metsubou-syndrome', 'name': 'Manga Name', 'de...
    └ <class 'manga_py.cli.Cli'>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/cli/__init__.py", line 53, in start
    self.parser.start()
    └ <manga_py.cli.Cli object at 0x7fab65f9f430>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/parser.py", line 54, in start
    self.provider.process(self.params['url'], self.params)
    │                     │                   └ <manga_py.parser.Parser object at 0x7fab65f9f790>
    │                     └ <manga_py.parser.Parser object at 0x7fab65f9f790>
    └ <manga_py.parser.Parser object at 0x7fab65f9f790>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/provider.py", line 88, in process
    self.prepare_download(params)
    │                     └ {'url': 'https://mangadex.org/title/687abfb8-6b36-42e5-bf97-a3853de172eb/itsukasei-metsubou-syndrome', 'name': 'Manga Name', 'de...
    └ <manga_py.providers.mangadex_org_v2.MangaDexOrg object at 0x7fab65f9f820>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/provider.py", line 124, in prepare_download
    info('Manga name: %s' % self.manga_name)
    │                       └ <manga_py.providers.mangadex_org_v2.MangaDexOrg object at 0x7fab65f9f820>
    └ <function info at 0x7fab670e8670>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/base_classes/params.py", line 17, in manga_name
    name = self.get_manga_name()
    │      └ <manga_py.providers.mangadex_org_v2.MangaDexOrg object at 0x7fab65f9f820>
    └ None
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/providers/mangadex_org_v2.py", line 77, in get_manga_name
    self.__content = self._get('manga/{}').get('data', {})
    │                └ <manga_py.providers.mangadex_org_v2.MangaDexOrg object at 0x7fab65f9f820>
    └ <manga_py.providers.mangadex_org_v2.MangaDexOrg object at 0x7fab65f9f820>
  File "/home/tbb/.local/lib/python3.10/site-packages/manga_py/providers/mangadex_org_v2.py", line 60, in _get
    ).json()
  File "/home/tbb/.local/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
          └ <class 'requests.exceptions.JSONDecodeError'>
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)```

Confirming that issue is happening on my end as well.

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           │                 │            └ {}
           │                 └ <Response [410]>
           └ <module 'simplejson' from '/usr/lib/python3/dist-packages/simplejson/__init__.py'>
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)

When running manga-py without the -m parameter.

1271 commented

Yeah
I'll deal with this issue tomorrow. Sorry it's taking so long

1271 commented

@toprak @dgbrewer1989
you can use manga-py from source (download archive or use git)
The fix is already ready, but not uploaded to pypi (will be in the near future)

toprak commented

@1271 I do not know how to use it from source, I could not find it on repo to how to do it so can you tell me how?

1271 commented

@toprak
If you have a PC (or Mac):

Download repo (https://github.com/manga-py/manga-py/archive/refs/heads/stable_1.x.zip)
Unpack to directory (your choice).
Create venv:
python3 -m venv venv
Activate this:
. venv/bin/activate
Or for windows:
venv\scripts\activate

Install requirements:
pip install -ur requirements.txt

And it's all. Everything should be work:

python main.py --help

1271 commented

P.S. in any case, I will try to deal with the releases as soon as possible