diff --git a/src/mangadex/api.cr b/src/mangadex/api.cr index 72ead4d..30e5c69 100644 --- a/src/mangadex/api.cr +++ b/src/mangadex/api.cr @@ -1,6 +1,7 @@ require "http/client" require "json" require "csv" +require "../rename" macro string_properties(names) {% for name in names %} @@ -72,13 +73,10 @@ module MangaDex gname = obj["group_name#{s}"].as_s @groups << {gid, gname} end - @full_title = @title - unless @chapter.empty? - @full_title = "Ch.#{@chapter} " + @full_title - end - unless @volume.empty? - @full_title = "Vol.#{@volume} " + @full_title - end + + rename_rule = Rename::Rule.new \ + Config.current.mangadex["chapter_rename_rule"].to_s + @full_title = rename rename_rule rescue e raise "failed to parse json: #{e}" end diff --git a/src/mangadex/downloader.cr b/src/mangadex/downloader.cr index 8e77e45..53c6776 100644 --- a/src/mangadex/downloader.cr +++ b/src/mangadex/downloader.cr @@ -313,7 +313,9 @@ module MangaDex end @queue.set_pages chapter.pages.size, job lib_dir = @library_path - manga_dir = File.join lib_dir, chapter.manga.title + rename_rule = Rename::Rule.new \ + Config.current.mangadex["manga_rename_rule"].to_s + manga_dir = File.join lib_dir, chapter.manga.rename rename_rule unless File.exists? manga_dir Dir.mkdir_p manga_dir end