Only extract comic if it isn't already extracted (muuuuch faster for large comics)
This commit is contained in:
parent
ee02a15182
commit
6460cfca37
|
|
@ -47,41 +47,52 @@ if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
|
|||
}
|
||||
$data["startindex"] = $currentpage;
|
||||
|
||||
$extracted = false;
|
||||
if ( !is_dir($comicoutputfull) ) {
|
||||
mkdir($comicoutputfull, 0755, true);
|
||||
} else {
|
||||
touch($comicoutputfull);
|
||||
$extracted = true;
|
||||
}
|
||||
|
||||
$files = array();
|
||||
if ( $ext == "cbz" ) {
|
||||
$zip = new ZipArchive();
|
||||
$opened = $zip->open($comicfull);
|
||||
for ( $i=0; $i<$zip->numFiles; $i++ ) {
|
||||
$imgname = basename($zip->getNameIndex($i));
|
||||
//$myext = substr($imgname, -3);
|
||||
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($imgname)['extension']);
|
||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||
$imgname = str_replace("#", "", $imgname);
|
||||
$imgcontents = $zip->getFromIndex($i);
|
||||
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
||||
if ( $written ) $files[] = $imgname;
|
||||
}
|
||||
if ( $extracted ) {
|
||||
$contents = glob($comicoutputfull . "*");
|
||||
foreach ( $contents as $i ) {
|
||||
$files[] = basename($i);
|
||||
}
|
||||
} elseif ( $ext == "cbr" ) {
|
||||
$rar = RarArchive::open($comicfull);
|
||||
$entries = $rar->getEntries();
|
||||
foreach ( $entries as $entry ) {
|
||||
$outfile = str_replace("#", "", basename($entry->getName()));
|
||||
$entry->extract(false, $comicoutputfull . $outfile);
|
||||
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($outfile)['extension']);
|
||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||
$files[] = basename($outfile);
|
||||
}
|
||||
}
|
||||
unset($entry);
|
||||
} else {
|
||||
exit();
|
||||
if ( $ext == "cbz" ) {
|
||||
$zip = new ZipArchive();
|
||||
$opened = $zip->open($comicfull);
|
||||
for ( $i=0; $i<$zip->numFiles; $i++ ) {
|
||||
$imgname = basename($zip->getNameIndex($i));
|
||||
//$myext = substr($imgname, -3);
|
||||
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($imgname)['extension']);
|
||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||
$imgname = str_replace("#", "", $imgname);
|
||||
$imgcontents = $zip->getFromIndex($i);
|
||||
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
||||
if ( $written ) $files[] = $imgname;
|
||||
}
|
||||
}
|
||||
} elseif ( $ext == "cbr" ) {
|
||||
$rar = RarArchive::open($comicfull);
|
||||
$entries = $rar->getEntries();
|
||||
foreach ( $entries as $entry ) {
|
||||
$outfile = str_replace("#", "", basename($entry->getName()));
|
||||
$entry->extract(false, $comicoutputfull . $outfile);
|
||||
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($outfile)['extension']);
|
||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||
$files[] = basename($outfile);
|
||||
}
|
||||
}
|
||||
unset($entry);
|
||||
} else {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
natsort($files);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user