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

MangaDex sometimes returns None for translatedLanguages #2352

Closed
stranger-danger-zamu opened this issue Feb 28, 2022 · 1 comment
Closed
Labels

Comments

@stranger-danger-zamu
Copy link

Expected behavior

Download all the chapters without issues.

Actual Behavior

Fails to handle calling str.partition on None and exits instantly.

Steps to Reproduce

  1. Run the following command:
gallery-dl --verbose \
--chapter-filter 'lang == "en" and chapter >= 270' \
    https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu

Context Information

OS: Linux (5.16.10)
Python: 3.10.2
gallery-dl version: 1.20.5

Debugging Log

#gallery-dl --verbose --chapter-filter 'lang == "en" and chapter >= 270' https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu
[gallery-dl][debug] Version 1.20.5
[gallery-dl][debug] Python 3.10.2 - Linux-5.16.10-200.fc35.x86_64-x86_64-with-glibc2.34
[gallery-dl][debug] requests 2.27.1 - urllib3 1.26.8
[gallery-dl][debug] Starting DownloadJob for 'https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu'
[mangadex][debug] Using MangadexMangaExtractor for 'https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): api.mangadex.org:443
[urllib3.connectionpool][debug] https://api.mangadex.org:443 "GET /manga/a96676e5-8ae2-425e-b549-7f15dd34a6d8/feed?order%5Bvolume%5D=asc&order%5Bchapter%5D=asc&contentRating%5B%5D=safe&contentRating%5B%5D=suggestive&contentRating%5B%5D=erotica&contentRating%5B%5D=pornographic&includes%5B%5D=scanlation_group&offset=0 HTTP/1.1" 200 None
[urllib3.connectionpool][debug] https://api.mangadex.org:443 "GET /manga/a96676e5-8ae2-425e-b549-7f15dd34a6d8?includes%5B%5D=artist&includes%5B%5D=author HTTP/1.1" 200 2450
[mangadex][error] An unexpected error occurred: AttributeError - 'NoneType' object has no attribute 'partition'. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[mangadex][debug]
Traceback (most recent call last):
  File "/home/user/.local/pipx/venvs/gallery-dl/lib64/python3.10/site-packages/gallery_dl/job.py", line 76, in run
    for msg in extractor:
  File "/home/user/.local/pipx/venvs/gallery-dl/lib64/python3.10/site-packages/gallery_dl/extractor/mangadex.py", line 41, in items
    data = self._transform(chapter)
  File "/home/user/.local/pipx/venvs/gallery-dl/lib64/python3.10/site-packages/gallery_dl/extractor/mangadex.py", line 56, in _transform
    lang = cattributes["translatedLanguage"].partition("-")[0]
AttributeError: 'NoneType' object has no attribute 'partition'

Additional Information

#line 56 in gallery_dl/extractor/mangadex.py
lang = cattributes["translatedLanguage"].partition("-")[0]

to

_lang = cattributes.get('translatedLanguage') or ''
lang = _lang.partition('-')[0]
@mikf
Copy link
Owner

mikf commented Mar 14, 2022

Filtering by language using mangadex's lang option would have also prevented this crash.

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

No branches or pull requests

2 participants