diff options
Diffstat (limited to 'read/views.py')
| -rw-r--r-- | read/views.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/read/views.py b/read/views.py index 77be1ed..e3820b5 100644 --- a/read/views.py +++ b/read/views.py @@ -1,18 +1,29 @@ from django.shortcuts import redirect, render -from read.utils import decode_chapter_info, get_chapter_pages +from read.utils import get_chapter_pages, get_manga_data # Create your views here. def index(request): return redirect("home:index") -def read(request, manga_encoded_string): - provider, chapter_id = decode_chapter_info(manga_encoded_string) - print(f"Reading: {provider} - {chapter_id}") - pages = get_chapter_pages(provider, chapter_id) +def read(request, manga_id, chapter_id): + manga = get_manga_data(manga_id) + + pages = get_chapter_pages(chapter_id) + + chapters = manga["chapters"] + current_chapter_index = next((i for i, chapter in enumerate(chapters) if chapter["id"] == chapter_id), None) + next_chapter = chapters[current_chapter_index + 1] if current_chapter_index is not None and current_chapter_index + 1 < len(chapters) else None + prev_chapter = chapters[current_chapter_index - 1] if current_chapter_index is not None and current_chapter_index - 1 >= 0 else None context = { "pages": pages, + "manga": manga, + "chapter_id": chapter_id, + "next_chapter": next_chapter, + "prev_chapter": prev_chapter, } return render(request, "read/read.html", context) + + |
