-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from ragusa87/convert-epub
Transform ebook on the fly (while syncing) using kebubify and synchronous messengers
- Loading branch information
Showing
20 changed files
with
581 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Kobo; | ||
|
||
class BookDownloadInfo | ||
{ | ||
public function __construct(private int $size, private string $url) | ||
{ | ||
} | ||
|
||
public function getSize(): int | ||
{ | ||
return $this->size; | ||
} | ||
|
||
public function getUrl(): string | ||
{ | ||
return $this->url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Kobo\Kepubify; | ||
|
||
class KebpubifyCachedData implements \JsonSerializable | ||
{ | ||
private string $content; | ||
private int $size; | ||
|
||
public function __construct(string $filename) | ||
{ | ||
$this->size = (int) filesize($filename); | ||
$this->content = (string) file_get_contents($filename); | ||
} | ||
|
||
public function getSize(): int | ||
{ | ||
return $this->size; | ||
} | ||
|
||
public function getContent(): string | ||
{ | ||
return $this->content; | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return [ | ||
'size' => $this->size, | ||
'content' => $this->content, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Kobo\Kepubify; | ||
|
||
class KepubifyConversionFailed extends \RuntimeException | ||
{ | ||
public function __construct(string $originalPath, ?\Throwable $previous = null) | ||
{ | ||
parent::__construct(sprintf('Conversion failed for book %s', $originalPath), 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Kobo\Kepubify; | ||
|
||
use Symfony\Component\DependencyInjection\Attribute\Autowire; | ||
|
||
class KepubifyEnabler | ||
{ | ||
public function __construct( | ||
#[Autowire(param: 'KEPUBIFY_BIN')] | ||
private string $kepubifyBinary, | ||
) { | ||
} | ||
|
||
public function setKepubifyBinary(string $kepubifyBinary): void | ||
{ | ||
$this->kepubifyBinary = $kepubifyBinary; | ||
} | ||
|
||
public function isEnabled(): bool | ||
{ | ||
return trim($this->kepubifyBinary) !== ''; | ||
} | ||
|
||
public function getKepubifyBinary(): string | ||
{ | ||
return $this->kepubifyBinary; | ||
} | ||
|
||
public function disable(): string | ||
{ | ||
$lastValue = $this->kepubifyBinary; | ||
$this->kepubifyBinary = ''; | ||
|
||
return $lastValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Kobo\Kepubify; | ||
|
||
/** | ||
* Convert an ebook with kepubify binary | ||
* The destination property will be set to the path of the converted file, | ||
*/ | ||
class KepubifyMessage | ||
{ | ||
/** | ||
* @var string|null Path of the destination file (which aim to be a temporary file). Null if the conversion failed. | ||
*/ | ||
public ?string $destination = null; | ||
/** | ||
* @var int|null File size of the destination file | ||
*/ | ||
public ?int $size = null; | ||
|
||
public function __construct( | ||
/** Path of the source ebook to convert */ | ||
public string $source, | ||
) { | ||
} | ||
} |
Oops, something went wrong.