kodjodevf / mangayomi-extensions

Source extensions for the Mangayomi app.
Apache License 2.0
87 stars 21 forks source link

Fix indexing error for madara sources #37

Closed resolritter closed 6 months ago

resolritter commented 6 months ago

We'll add the chapters to a single chapters array, instead of adding them to 3 different arrays as in:

https://github.com/kodjodevf/mangayomi-extensions/blob/1e6f245175e5716abcce9c10c48de79d3584c59a/manga/multisrc/madara/madara.dart#L184-L186

Doing so should get rid of indexing errors.

Please let me know if I need to bump the versions of madara sources in index.json. If so, I also need to know the next version number.


close #36

kodjodevf commented 6 months ago

Looks great, I modifier the code because for other sources it may be that the date of the chapter can be null due to the fact that these are chapters released recently you can add it on your side:

List<MChapter>` getChapters(MDocument chapDoc) {
    List<MChapter> chapters = [];
    for (MElement element in chapDoc.select("li.wp-manga-chapter") ?? []) {
      var ch = element.selectFirst("a");
      if (ch != null) {
        var url = ch.attr("href");
        if (url != null && url.isNotEmpty) {
          url = substringBefore(url, "?style=paged");
          if (url.endsWith("?style=paged")) {
            url = url + "?style=paged";
          }
          var chapter = MChapter();
          chapter.url = url;
          chapter.name = ch.text;
          if (source.dateFormat.isNotEmpty) {
            var chd = element.selectFirst("span.chapter-release-date");
            if (chd != null && chd.text.isNotEmpty) {
              var dates = parseDates(
                  [chd.text], source.dateFormat, source.dateFormatLocale);
              chapter.dateUpload = dates[0];
            } else {
              chapter.dateUpload =
                  DateTime.now().millisecondsSinceEpoch.toString();
            }
          }
          chapters.add(chapter);
        }
      }
    }
    return chapters;
  }
kodjodevf commented 6 months ago

Also for the next version go to madara sources file and change const madaraVersion = "0.0.85" to const madaraVersion = "0.0.86" after this go to sources_generator and run main() it will generate index.json

resolritter commented 6 months ago

Looks great, I modifier the code because for other sources it may be that the date of the chapter can be null due to the fact that these are chapters released recently you can add it on your side:

Done in a6462c9f5eb5450161461ce13c5a2082cc972a71.

Also for the next version go to madara sources file and change const madaraVersion = "0.0.85" to const madaraVersion = "0.0.86" after this go to sources_generator and run main() it will generate index.json

Done in f0d0e202c599b0885488e0535dd9f8c17b367723 and 80ed7b8f47969e04cf384846a9e5305cb80834ef.

The "Allow edits by maintainers" feature is enabled for this PR, so feel free to push any changes you want.