ArdaxHz / mdownloader

MangaDex downloader using python. Forked from the repo linked
https://gitlab.com/hitoribocchi/mdownloader
GNU General Public License v3.0
9 stars 1 forks source link

Inconsistent API chapter group format #12

Closed NLZ closed 3 years ago

NLZ commented 3 years ago

In the chapter API groups are usually listed like this, for example 1109980:

"groups": [{
    "id": 13145,
    "name": "FLAME-SCANS"
}, {
    "id": 12889,
    "name": "Vale Scanlation"
}]

But I found this chapter 1113458 which uses a different structure:

"groups": {
    "0": {
        "id": 13145,
        "name": "FLAME-SCANS"
    },
    "2": {
        "id": 12889,
        "name": "Vale Scanlation"
    }
}

This is a fairly new chapter from today, but checked an even newer chapter and that still uses the old format, so I'm not sure what happened. Asked #support on discord, maybe someone will tell why it's like this.

Anyway, here is the error trace for the unexpected format:

Traceback (most recent call last):
  File "C:\Users\nlz\Code\mdownloader\mdownloader.py", line 123, in <module>
    beforeMain(args.id, args.language, args.directory, args.type, args.save_format, args.folder, args.covers)
  File "C:\Users\nlz\Code\mdownloader\mdownloader.py", line 105, in beforeMain
    main(id, language, directory, type, save_format, folder, covers)
  File "C:\Users\nlz\Code\mdownloader\components\main.py", line 94, in main
    typeChecker(id, language, route, type, save_format, make_folder, covers)
  File "C:\Users\nlz\Code\mdownloader\components\main.py", line 18, in typeChecker
    downloadBatch(id, language, route, type, save_format, make_folder, covers)
  File "C:\Users\nlz\Code\mdownloader\components\downloader.py", line 236, in downloadBatch
    downloadChapter(chapter_id, title, route, type, save_format, make_folder, json_file)
  File "C:\Users\nlz\Code\mdownloader\components\downloader.py", line 122, in downloadChapter
    instance = ChapterSaver(title, chapter_data, series_route, save_format, make_folder)
  File "C:\Users\nlz\Code\mdownloader\components\exporter.py", line 106, in __init__
    super().__init__(series_title, chapter_data)
  File "C:\Users\nlz\Code\mdownloader\components\exporter.py", line 22, in __init__
    self.groups = self.groupNames()
  File "C:\Users\nlz\Code\mdownloader\components\exporter.py", line 83, in groupNames
    return self.name_regex.sub('_', html.unescape(', '.join([g["name"] for g in self.chapter_data["groups"]])))
  File "C:\Users\nlz\Code\mdownloader\components\exporter.py", line 83, in <listcomp>
    return self.name_regex.sub('_', html.unescape(', '.join([g["name"] for g in self.chapter_data["groups"]])))
TypeError: string indices must be integers
ArdaxHz commented 3 years ago

Bruh wtf

ArdaxHz commented 3 years ago

MD dev should have fixed it on the API.

NLZ commented 3 years ago

Issue solved on Mangadex's end: https://mangadex.org/thread/351011/1

  • Fixed the groups field in the chapter entity sometimes showing up as an object instead of an array (thanks to php's array_filter not working as I expected it to)