leotaku / kojirou

Generate perfectly formatted Kindle e-books from MangaDex manga
MIT License
94 stars 9 forks source link

Discontinuities that aren't reflected in Mangadex UI #5

Closed Colin1224 closed 2 years ago

Colin1224 commented 2 years ago

I've noticed that some manga produces weird discontinuities that aren't present when looking at the same manga on the Mangadex website. Example:

PS C:\repos\kojirou> go run .\kojirou.go ec514ef4-fb77-43b9-b9b4-528229de1308 -l en --dry-run
Title: Enen no Shouboutai
Author: Atsushi Ookubo
Groups: Mangastream, /a/nonymous, Pusu Pusu Scans
Chapters: 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 132, 133, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 296, 298, 299
Discontinuities: 0..0, 8..11, 28..30, 31..33, 36..38, 62..64, 65..67, 69..71, 78..80, 90..92, 95..97, 130..132, 138..140, 164..167, 168..170, 183..185, 210..212, 236..238, 253..255, 288..290, 294..296, 296..298

Notice that the CLI is showing that there are discontinuities at 8 to 11 and others, but if you look on the actual page here, there are no discontinuities and the supposedly missing chapters are there and can be loaded fine.

leotaku commented 2 years ago

This was caused by a change in the MangaDex API, where chapters are now returned in semi-random order when no ordering is given. The latest commit fixes the issue by always adding an order parameter to the URL.

leotaku commented 2 years ago

Unfortunately there seems to be another issue here, as I still observe seemingly random discontinuities.

Colin1224 commented 2 years ago

I noticed that for every manga there always shows a Discontinuities: 0..0. Maybe looking into why this is occurring could help?

leotaku commented 2 years ago

Thanks for the idea, I've already fixed the 0..0 issue in a newer commit. It was caused by the discontinuity visualization function expecting 1 as the first chapter.

The issue I'm now experiencing seems to be a bug in the actual MangaDex API. I'm looking at the raw MangaDex API responses and sometimes specific chapters are missing, having been replaced by other, duplicate chapters.

Switching to the updatedAt ordering seems to fix the issue for all cases I have tested, but this might just be because of random chance.

Regardless, I'll commit the change. If you notice any other weird discontinuities after that commit, please comment here.

Colin1224 commented 2 years ago

Whoops missed that 0..0 commit. Another unnecessary discontinuity is when looking at a specific volume. Example:

PS C:\repos\kojirou> go run .\kojirou.go ec514ef4-fb77-43b9-b9b4-528229de1308 -l en -V 10 --dry-run
Title: Enen no Shouboutai
Author: Atsushi Ookubo
Groups: Pusu Pusu Scans
Chapters: 79, 80, 81, 82, 83, 84, 85, 86, 87
Discontinuities: 0..79

Displaying Discontinuities: 0..79 probably isn't necessary as the first chapter in volume 10 of this manga is chapter 79, but doesn't actually hurt anything. (You might've already fixed this in that commit) Just checked, not fixed.

As for the API issue, maybe a workaround until Mangadex fixes that issue is just pulling the chapter list twice then constructing the most complete list from that? Like saving which chapters were missing from the first query then trying again and seeing if they're present the second time. I noticed that when I would get a random discontinuity that it would go away if I just ran the query one more time.

leotaku commented 2 years ago

Displaying Discontinuities: 0..79 probably isn't necessary as the first chapter in volume 10 of this manga is chapter 79, but doesn't actually hurt anything. (You might've already fixed this in that commit)

Good point, I will look into implementing this.

As for the API issue, maybe a workaround...

I don't think this would actually help, as with my testing, the API often returns the exact same incorrect results multiple times in a row.

leotaku commented 2 years ago

I've now implemented the suggestion of not reporting "missing" chapters at the beginning as discontinuities. Also, the bug related to the API not returning all list items no longer seems to appear.

If you find a case where we are still missing chapters that are present on the website, feel free to reopen this issue. Thank you for your help!