Repos / pytaku / fc3e6a22cf
commit fc3e6a22cf24553610f41e7b9d2ebfba4a0d4ae0
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Sun Aug 2 10:25:46 2020 +0700
get all possible scan groups
diff --git a/src/mangoapi/__init__.py b/src/mangoapi/__init__.py
index ce64c4c..e83784e 100644
--- a/src/mangoapi/__init__.py
+++ b/src/mangoapi/__init__.py
@@ -20,6 +20,14 @@ def _parse_chapter_number(string):
return result
+def _extract_groups(chap):
+ return [
+ group.strip()
+ for group in [chap["group_name"], chap["group_name_2"], chap["group_name_3"]]
+ if group
+ ]
+
+
def get_title(title_id):
url = f"https://mangadex.org/api/?id={title_id}&type=manga"
md_resp = requests.get(url)
@@ -40,7 +48,7 @@ def get_title(title_id):
"id": chap_id,
"name": chap["title"],
"volume": int(chap["volume"]) if chap["volume"] else None,
- "group": chap["group_name"],
+ "groups": _extract_groups(chap),
**_parse_chapter_number(chap["chapter"]),
}
for chap_id, chap in md_json["chapter"].items()
@@ -66,7 +74,7 @@ def get_chapter(chapter_id):
"title_id": md_json["manga_id"],
"name": md_json["title"],
"pages": [f"{img_path}/{page}" for page in md_json["page_array"]],
- "group": md_json["group_name"],
+ "groups": _extract_groups(md_json),
**_parse_chapter_number(md_json["chapter"]),
}
return chapter
diff --git a/src/pytaku/templates/title.html b/src/pytaku/templates/title.html
index 6cf093f..700f6e2 100644
--- a/src/pytaku/templates/title.html
+++ b/src/pytaku/templates/title.html
@@ -32,10 +32,13 @@ <h1>{{ name }}</h1>
<tr>
<td>
<a href="{{ url_for('chapter_view', chapter_id=chapter['id']) }}">
- Ch.{{ chapter['number'] }} - {{ chapter['name'] }}
+ Chapter {{ chapter['number'] }}
+ {% if chapter['volume'] %}Volume {{ chapter['volume'] }} {% endif %}
+ {% if chapter['name'] %}- {{ chapter['name'] }} {% endif %}
+
</a>
</td>
- <td>{{ chapter['group'] }}</td>
+ <td>{{ ', '.join(chapter['groups']) }}</td>
</tr>
{% endfor %}
</table>