From e3d505d62b05e541ae5978b34474a646e4a2f4e9 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Fri, 28 Feb 2020 17:14:38 +0000 Subject: [PATCH] Add @full_title to `MangaDex::Chapter` --- src/mangadex/api.cr | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mangadex/api.cr b/src/mangadex/api.cr index ead5c0a..22cc0dd 100644 --- a/src/mangadex/api.cr +++ b/src/mangadex/api.cr @@ -30,6 +30,7 @@ module MangaDex property manga : Manga property time = Time.local property id : String + property full_title = "" property language = "" property pages = [] of {String, String} # filename, url property groups = [] of {Int32, String} # group_id, group_name @@ -41,7 +42,7 @@ module MangaDex JSON.build do |json| json.object do {% for name in ["id", "title", "volume", "chapter", - "language"] %} + "language", "full_title"] %} json.field {{name}}, @{{name.id}} {% end %} json.field "time", @time.to_unix.to_s @@ -71,6 +72,13 @@ 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 rescue e raise "failed to parse json: #{e}" end