Skip to content

Commit

Permalink
feat(kobo) Remove epub3 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusa87 committed May 31, 2024
1 parent df4e941 commit 2f6fb93
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 deletions.
28 changes: 0 additions & 28 deletions src/Kobo/DownloadHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public function getCoverSize(Book $book): int
return $this->fileSystemManager->getCoverSize($book) ?? 0;
}

public function isEpub3(Book $book): bool
{
return $book->getExtension() === 'epub3' || $this->readEpubVersionIs3($book) === true;
}

public function getUrlForKoboDevice(Book $book, KoboDevice $kobo): string
{
return $this->urlGenerator->generate('app_kobodownload', [
Expand Down Expand Up @@ -118,29 +113,6 @@ public function getResponse(Book $book): StreamedResponse
return $response;
}

private function readEpubVersionIs3(Book $book): ?bool
{
$zip = new \ZipArchive();

if ($zip->open($this->getBookFilename($book)) !== true) {
$this->logger->debug('Unable to open epub file to detect the format', ['book' => $book->getId()]);

return null;
}
try {
// Check for EPUB version
if ($zip->locateName('metadata.opf') !== false) {
return false; // v2
} elseif ($zip->locateName('package.opf') !== false) {
return true; // v3
}

return null;
} finally {
$zip->close();
}
}

public function coverExist(Book $book): bool
{
return $this->fileSystemManager->coverExist($book);
Expand Down
3 changes: 1 addition & 2 deletions src/Kobo/Response/MetadataResponseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ protected function getDownloadUrls(Book $book, KoboDevice $kobo, ?array $filters

$response = [];

// $formats = $this->downloadHelper->isEpub3($book) ? ['EPUB3'] : ['EPUB'];
$formats = ['EPUB3', 'EPUB']; // EPUB3 is required for Kobo
$formats = ['EPUB3']; // EPUB3 is required for Kobo
foreach ($formats as $format) { // and ... EPUB3FL ?;
$response[] = [
'Format' => $format,
Expand Down

0 comments on commit 2f6fb93

Please sign in to comment.