Added:
- manga import - read from cbz - save cbz from scrapping - menu interactions
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Entity\Manga;
|
||||
use App\Message\DownloadChapter;
|
||||
use App\Repository\ChapterRepository;
|
||||
use App\Repository\MangaRepository;
|
||||
use App\Service\CbzService;
|
||||
use App\Service\MangaExportService;
|
||||
use App\Service\LelScansProviderService;
|
||||
use App\Service\MangaScraperServiceOld;
|
||||
@@ -19,19 +20,20 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\String\Slugger\AsciiSlugger;
|
||||
|
||||
class MangaController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly MangaScraperServiceOld $mangaScraperService,
|
||||
private readonly MangaExportService $mangaExportService,
|
||||
private readonly LelScansProviderService $mangaProviderService,
|
||||
private readonly MangaRepository $mangaRepository,
|
||||
private ChapterRepository $chapterRepository,
|
||||
private MangaUpdatesMetadataProvider $mangaUpdatesDbProvider,
|
||||
private MessageBusInterface $bus
|
||||
private readonly MangaScraperServiceOld $mangaScraperService,
|
||||
private readonly MangaExportService $mangaExportService,
|
||||
private readonly LelScansProviderService $mangaProviderService,
|
||||
private readonly MangaRepository $mangaRepository,
|
||||
private readonly ChapterRepository $chapterRepository,
|
||||
private readonly MangaUpdatesMetadataProvider $mangaUpdatesDbProvider,
|
||||
private readonly MessageBusInterface $bus,
|
||||
private readonly CbzService $cbzService
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -39,6 +41,7 @@ class MangaController extends AbstractController
|
||||
#[Route('/manga', name: 'app_manga')]
|
||||
public function index(): Response
|
||||
{
|
||||
// phpinfo();
|
||||
$mangas = $this->mangaRepository->findAll();
|
||||
return $this->render('manga/index.html.twig', [
|
||||
'controller_name' => 'MangaController',
|
||||
@@ -49,7 +52,7 @@ class MangaController extends AbstractController
|
||||
/**
|
||||
* @throws NonUniqueResultException
|
||||
*/
|
||||
#[Route('/manga/{mangaSlug}', name: 'manga_show')]
|
||||
#[Route('/manga/chapters/{mangaSlug}', name: 'app_manga_show')]
|
||||
public function showChapters(string $mangaSlug): Response
|
||||
{
|
||||
// $manga = $this->mangaRepository->findOneWithChapterBy(['slug' => $mangaSlug]);
|
||||
@@ -88,8 +91,8 @@ class MangaController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/manga/{mangaSlug}/{chapterNumber}/{pageNumber}', name: 'read_chapter_page')]
|
||||
public function readChapterPage(string $mangaSlug, float $chapterNumber, int $pageNumber = 0): Response
|
||||
#[Route('/manga/read/{mangaSlug}/{chapterNumber}/{pageNumber}', name: 'app_manga_read')]
|
||||
public function readChapterPage(string $mangaSlug, float $chapterNumber, int $pageNumber = 1): Response
|
||||
{
|
||||
$manga = $this->mangaRepository->findOneBy(['slug' => $mangaSlug]);
|
||||
if (!$manga) {
|
||||
@@ -101,20 +104,37 @@ class MangaController extends AbstractController
|
||||
throw $this->createNotFoundException("Le chapitre demandé n'existe pas.");
|
||||
}
|
||||
|
||||
$currentPage = $chapter->getPageByNumber($pageNumber);
|
||||
if (!$currentPage) {
|
||||
if (is_null($chapter->getCbzPath())) {
|
||||
$currentPage = $chapter->getPageByNumber($pageNumber);
|
||||
if (!$currentPage) {
|
||||
throw $this->createNotFoundException("La page demandée n'existe pas.");
|
||||
}
|
||||
|
||||
return $this->render('manga/manga_reader.html.twig', [
|
||||
'manga' => $manga,
|
||||
'chapter' => $chapter,
|
||||
'pages' => $chapter->getPagesLink(),
|
||||
'currentPage' => $currentPage,
|
||||
]);
|
||||
}
|
||||
|
||||
$pageContent = $this->cbzService->getPageContent($chapter->getCbzPath(), $pageNumber);
|
||||
if (!$pageContent) {
|
||||
throw $this->createNotFoundException("La page demandée n'existe pas.");
|
||||
}
|
||||
|
||||
$totalPages = $this->cbzService->getPageCount($chapter->getCbzPath());
|
||||
|
||||
return $this->render('manga/manga_reader.html.twig', [
|
||||
'manga' => $manga,
|
||||
'chapter' => $chapter,
|
||||
'pages' => $chapter->getPagesLink(),
|
||||
'currentPage' => $currentPage,
|
||||
'currentPage' => $pageNumber,
|
||||
'totalPages' => $totalPages,
|
||||
'pageContent' => base64_encode($pageContent),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/addNew/{query}', name: 'add_new_manga')]
|
||||
#[Route('/manga/new/{query}', name: 'app_manga_new')]
|
||||
public function addNew(string $query = ''): Response
|
||||
{
|
||||
return $this->render('manga/add_new.html.twig', [
|
||||
@@ -137,7 +157,7 @@ class MangaController extends AbstractController
|
||||
$chapter = $this->chapterRepository->find($id);
|
||||
if (!$chapter) {
|
||||
return new JsonResponse(['error' => 'Chapter Not Found.'], 400);
|
||||
} elseif ($chapter->getLocalPath() !== null) {
|
||||
} elseif ($chapter->getCbzPath() !== null) {
|
||||
return new JsonResponse(['error' => 'Chapter already scraped.'], 400);
|
||||
}
|
||||
|
||||
@@ -198,7 +218,7 @@ class MangaController extends AbstractController
|
||||
|
||||
$availableChapters = $this->mangaProviderService->getChapterList($mangaSlug);
|
||||
|
||||
return $this->redirectToRoute('manga_show', ['mangaSlug' => $mangaSlug, 'availableChapters' => $availableChapters]);
|
||||
return $this->redirectToRoute('app_manga_show', ['mangaSlug' => $mangaSlug, 'availableChapters' => $availableChapters]);
|
||||
}
|
||||
|
||||
#[Route('/manga/exportFrom/{mangaSlug}/{chapterNumber}', name: 'manga_export')]
|
||||
|
||||
Reference in New Issue
Block a user