Add @full_title to MangaDex::Chapter

This commit is contained in:
Alex Ling 2020-02-28 17:14:38 +00:00
parent 77864afa67
commit e3d505d62b

View File

@ -30,6 +30,7 @@ module MangaDex
property manga : Manga property manga : Manga
property time = Time.local property time = Time.local
property id : String property id : String
property full_title = ""
property language = "" property language = ""
property pages = [] of {String, String} # filename, url property pages = [] of {String, String} # filename, url
property groups = [] of {Int32, String} # group_id, group_name property groups = [] of {Int32, String} # group_id, group_name
@ -41,7 +42,7 @@ module MangaDex
JSON.build do |json| JSON.build do |json|
json.object do json.object do
{% for name in ["id", "title", "volume", "chapter", {% for name in ["id", "title", "volume", "chapter",
"language"] %} "language", "full_title"] %}
json.field {{name}}, @{{name.id}} json.field {{name}}, @{{name.id}}
{% end %} {% end %}
json.field "time", @time.to_unix.to_s json.field "time", @time.to_unix.to_s
@ -71,6 +72,13 @@ module MangaDex
gname = obj["group_name#{s}"].as_s gname = obj["group_name#{s}"].as_s
@groups << {gid, gname} @groups << {gid, gname}
end 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 rescue e
raise "failed to parse json: #{e}" raise "failed to parse json: #{e}"
end end