Skip to content

Commit 87e7ac5

Browse files
committed
add coveroffset for mobi
#3
1 parent 803d713 commit 87e7ac5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Driver/MobiDriver.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/**
1515
* @see https://wiki.mobileread.com/wiki/MOBI
1616
* @see https://github.com/choccybiccy/mobi
17+
* @see https://github.com/rodzyk/readiverse
1718
*/
1819
final class MobiDriver extends AbstractDriver
1920
{
@@ -183,7 +184,7 @@ public function getMeta(): MobiMeta
183184
}
184185

185186
/**
186-
* @return array{author: string|null, publisher: string|null, description: string|null, isbn: string|null, language: string|null, license: string|null, publishDate: \DateTimeInterface|null}
187+
* @return array{author: string|null, publisher: string|null, description: string|null, isbn: string|null, language: string|null, license: string|null, publishDate: \DateTimeInterface|null, coveroffset: string|null}
187188
*/
188189
protected function parseExth(\SplFileObject $f): array
189190
{
@@ -203,6 +204,7 @@ protected function parseExth(\SplFileObject $f): array
203204
'publishDate' => null,
204205
'language' => null,
205206
'license' => null,
207+
'coveroffset' => null,
206208
];
207209
for ($i = 0; $i < $records; ++$i) {
208210
$rawType = $f->fread(4);
@@ -214,8 +216,8 @@ protected function parseExth(\SplFileObject $f): array
214216
throw new ParserException();
215217
}
216218

217-
$type = (int) \hexdec(\bin2hex($rawType));
218-
$length = (int) \hexdec(\bin2hex($rawLength));
219+
$type = \hexdec(\bin2hex($rawType));
220+
$length = \hexdec(\bin2hex($rawLength));
219221

220222
if ($length > 0) {
221223
$data = $f->fread($length - 8);
@@ -246,6 +248,9 @@ protected function parseExth(\SplFileObject $f): array
246248
case 524:
247249
$meta['language'] = $data;
248250
break;
251+
case 201:
252+
$meta['coveroffset'] = $data;
253+
break;
249254
}
250255
}
251256

0 commit comments

Comments
 (0)