Komikku: update to 0.32.0.

This commit is contained in:
Lorem 2021-09-20 11:08:05 +05:30 committed by Michal Vasilek
parent 84747ec214
commit 55af2f7242
2 changed files with 3 additions and 85 deletions

View file

@ -1,82 +0,0 @@
Taken from upstream commit: https://gitlab.com/valos/Komikku/-/commit/35393c0
diff --git a/komikku/servers/mangadex/__init__.py b/komikku/servers/mangadex/__init__.py
index 22bfbe96ce48b45b035cb715c3ec478f73eb6939..c7250b4cb5f847d8edc67e8f577710a7676f2e29 100644
--- a/komikku/servers/mangadex/__init__.py
+++ b/komikku/servers/mangadex/__init__.py
@@ -82,6 +82,26 @@ class Mangadex(Server):
return None
+ def _manga_title_from_attributes(self, attributes):
+ if self.lang_code in attributes['title']:
+ return attributes['title'][self.lang_code]
+ elif 'en' in attributes['title']:
+ return attributes['title']['en']
+
+ else:
+ lang_code_alt_name = None
+ en_alt_name = None
+
+ for alt_title in attributes['altTitles']:
+ if not lang_code_alt_name and self.lang_code in alt_title:
+ lang_code_alt_name = alt_title['en']
+
+ if not en_alt_name and 'en' in alt_title:
+ en_alt_name = alt_title['en']
+
+ return lang_code_alt_name or en_alt_name
+
+
def get_manga_data(self, initial_data):
"""
Returns manga data from API
@@ -117,7 +137,9 @@ class Mangadex(Server):
attributes = resp_json['data']['attributes']
# FIXME: Should probably be lang_code, but the API returns weird stuff
- data['name'] = html.unescape(attributes['title']['en'])
+ _name = self._manga_title_from_attributes(attributes)
+ data['name'] = html.unescape(_name)
+ assert data['name'] is not None
for relationship in resp_json['relationships']:
if relationship['type'] == 'author':
@@ -137,8 +159,14 @@ class Mangadex(Server):
elif attributes['status'] == 'hiatus':
data['status'] = 'hiatus'
- # FIXME: lang_code
- data['synopsis'] = html.unescape(attributes['description']['en'])
+ if self.lang_code in attributes['description']:
+ data['synopsis'] = html.unescape(attributes['description'][self.lang_code])
+ elif 'en' in attributes['description']:
+ # Fall back to english synopsis
+ data['synopsis'] = html.unescape(attributes['description']['en'])
+ else:
+ logger.warn('{}: No synopsis', data['name'])
+
data['chapters'] += self.resolve_chapters(data['slug'])
@@ -280,11 +308,16 @@ class Mangadex(Server):
if result['type'] != 'manga':
continue
- results.append(dict(
- slug=result['id'],
- # FIXME: lang_code
- name=result['attributes']['title']['en'],
- ))
+ name = self._manga_title_from_attributes(result['attributes'])
+
+ if name:
+ results.append(dict(
+ slug=result['id'],
+ # FIXME: lang_code
+ name=name,
+ ))
+ else:
+ logger.warn("ignoring result {}, missing name".format(result['id']))
return results

View file

@ -1,7 +1,7 @@
# Template file for 'Komikku'
pkgname=Komikku
version=0.30.0
revision=2
version=0.32.0
revision=1
wrksrc=Komikku-v${version}
build_style=meson
hostmakedepends="gettext glib-devel gobject-introspection pkg-config"
@ -16,4 +16,4 @@ maintainer="Lorem <notloremipsum@protonmail.com>"
license="GPL-3.0-or-later"
homepage="https://gitlab.com/valos/Komikku"
distfiles="https://gitlab.com/valos/Komikku/-/archive/v${version}/Komikku-v${version}.tar.gz"
checksum=07c45f458a485d50220c71028f71ab27e86058fce1bfd9334b9859e601b7f7e6
checksum=2c980fbe9139cb2eadb7ad2deb7a92e088afbc61a02c9a3e3cb7143bb94ca1a2