Skip to content

Commit

Permalink
Handle empty descriptions gracefully. #8
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyhippo committed Dec 12, 2021
1 parent c048f86 commit 5c45eb8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions proxy/sources/mangadex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from concurrent.futures.thread import ThreadPoolExecutor
from datetime import datetime
import html
from typing import Dict
from typing import Dict, Union
from django.core.cache import cache

from django.http import HttpResponse
Expand Down Expand Up @@ -310,12 +310,19 @@ def md_api_common(self, meta_id):
title = title_metadata[title_precedence]
break

description_object: Union[list, Dict[str, str]] = main_data["data"][
"attributes"
]["description"]
description: str = (
description_object.get(SUPPORTED_LANG, "No English description.")
if len(description_object)
else "No description."
)

return {
"slug": meta_id,
"title": title,
"description": main_data["data"]["attributes"]["description"].get(
SUPPORTED_LANG, "No English description."
),
"description": description,
"author": "",
"artist": "",
"groups": groups_dict,
Expand Down

0 comments on commit 5c45eb8

Please sign in to comment.