diff options
| author | Bobby <[email protected]> | 2024-09-05 02:17:04 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-09-05 02:17:04 -0400 |
| commit | 87d8d83d247a44d04c6523dfcce25cd3ab6ad0e9 (patch) | |
| tree | 42482244aba6d19b8365240b4f7333c91a9850eb /detail | |
| parent | c476bc0b08b9441b63327a3b8768ef11f7176b27 (diff) | |
| download | yugen-87d8d83d247a44d04c6523dfcce25cd3ab6ad0e9.tar.xz yugen-87d8d83d247a44d04c6523dfcce25cd3ab6ad0e9.zip | |
update MAL from detail page
Diffstat (limited to 'detail')
| -rw-r--r-- | detail/views.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/detail/views.py b/detail/views.py index a3495ad..d62c9e0 100644 --- a/detail/views.py +++ b/detail/views.py @@ -3,6 +3,7 @@ import os from django.shortcuts import render import requests from functools import lru_cache +from authentication.utils import get_single_anime_mal from watch.utils import get_all_episode_metadata, get_from_redis_cache, store_in_redis_cache def detail(request, anime_id): @@ -15,11 +16,18 @@ def detail(request, anime_id): if anime_episodes: attach_episode_metadata(anime_data, anime_episodes) + if request.user.mal_access_token and anime_data.get("malId"): + mal_data = get_single_anime_mal(request.user.mal_access_token, anime_data["malId"]) + context = { "anime": anime_data, "episodes": anime_episodes, } + if mal_data: + context["mal_data"] = mal_data + context["mal_episode_range"] = range(1, mal_data["num_episodes"] + 1) + return render(request, "detail/detail.html", context) @lru_cache(maxsize=100) |
