Continue processing more OPDS entries if one ebook can't be parsed

This commit is contained in:
Alex Cabal 2020-10-13 14:48:57 -05:00
parent 73ba658a05
commit 1d56a06c79

View file

@ -22,20 +22,27 @@ foreach($contentFiles as $path){
if($path == '') if($path == '')
continue; continue;
$ebookWwwFilesystemPath = preg_replace('|/content\.opf|ius', '', $path) ?? ''; try{
$ebook = new Ebook($ebookWwwFilesystemPath); $ebookWwwFilesystemPath = preg_replace('|/content\.opf|ius', '', $path) ?? '';
$allEbooks[$ebook->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; $ebook = new Ebook($ebookWwwFilesystemPath);
$newestEbooks[$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
foreach($ebook->Tags as $tag){ $allEbooks[$ebook->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
// Add the book's subjects to the main subjects list $newestEbooks[$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
if(!in_array($tag->Name, $subjects)){
$subjects[] = $tag->Name; foreach($ebook->Tags as $tag){
// Add the book's subjects to the main subjects list
if(!in_array($tag->Name, $subjects)){
$subjects[] = $tag->Name;
}
// Sort this ebook by subject
$ebooksBySubject[$tag->Name][$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
} }
}
// Sort this ebook by subject catch(\Exception $ex){
$ebooksBySubject[$tag->Name][$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; print('Failed to generate OPDS entry for `' . $ebookWwwFilesystemPath . '`. Exception: ' . $ex->getMessage());
continue;
} }
} }