0.7.12.5 (Work)

Icon batch work
This commit is contained in:
2019-06-10 22:04:25 -07:00
parent cf2e8885da
commit 052e089f1d
22 changed files with 20851 additions and 91 deletions

View File

@@ -76,20 +76,7 @@ $bpath = chop($bdest,"/")."/".substr(crc32($zpath),0,3)."_".$blabel.".bundle";
if (!is_dir($bpath)) { mkdir($bpath); }
if (!is_dir($bpath."/thumbs")) { mkdir($bpath."/thumbs"); }
if (!is_dir($bpath."/icons")) { mkdir($bpath."/icons"); }
if (!is_dir($bpath."/contents")) { mkdir($bpath."/contents"); }
// Metadata tools
$bin_gfi = __DIR__."/bin/GetFileInfo";
$bin_mediainfo = __DIR__."/bin/mediainfo";
$bin_exiftool = __DIR__."/bin/exiftool";
$bin_ffmpeg = __DIR__."/bin/ffmpeg";
$bin_qlthumb = __DIR__."/bin/ql-thumbnail";
$bin_qltool = __DIR__."/bin/qltool";
$bin_magick = __DIR__."/bin/magick";
$bin_sox = __DIR__."/bin/sox";
$bin_pngcrush = __DIR__."/bin/pngcrush";
$bin_parallel = __DIR__."/bin/parallel";
$bin_vips = "vipsthumbnail";
if (!is_dir($bpath."/contents")) { mkdir($bpath."/contents"); }
// Logfile
$messages_log_file = $bpath."/".$stamp."_messages.log";
@@ -291,6 +278,7 @@ $dbo->exec("CREATE TABLE files (
thumb_width INTEGER,
thumb_height INTEGER,
thumb_tool TEXT,
icon_filename TEXT,
contents_filename TEXT
)");
@@ -402,7 +390,6 @@ $dbp->exec("CREATE TABLE IF NOT EXISTS mediainfo (fid TEXT, info TEXT)");
$dbp->exec("CREATE TABLE IF NOT EXISTS thumbs (fid TEXT, created INTEGER, relative_path TEXT, width INTEGER, height INTEGER, tool TEXT)");
$dbp->exec("CREATE TABLE IF NOT EXISTS icons (fid TEXT, hash TEXT, created INTEGER, relative_path TEXT, tool TEXT)");
$dbp->exec("CREATE TABLE IF NOT EXISTS contents (fid TEXT, created INTEGER, relative_path TEXT)");
$dbp->exec("CREATE TABLE IF NOT EXISTS counter (time INTEGER, pass TEXT, count INTEGER)");
// Prescan
//////////////////////////////////////////
@@ -411,6 +398,8 @@ $i = 0;
$family = array();
$fids = array();
$noread = array();
$fx = new SplFixedArray($passed_file); // splFixedArray for performance (?)
$splcount = 0;
echo ProgressBar::start($passed_total,"Prescan (".stepString().")");
@@ -436,8 +425,9 @@ foreach ($files as $splFileInfo) {
$fid = md5($splFileInfo->getSize().$splFileInfo->getMtime().$splFileInfo->getBasename());
$dx[$fid][] = $pathname;
$fx[] = array($fid, $pathname);
$fx[$splcount] = array($fid, $pathname);
$family[$key]['fid'] = $fid;
$splcount++;
}
@@ -470,9 +460,6 @@ foreach ($files as $splFileInfo) {
}
// Convert $fx to splFixedArray for performance (?)
//$fx = SplFixedArray::fromArray($fx);
echo ProgressBar::finish();
// Thow permissions error
@@ -565,33 +552,25 @@ $p['icons'] = 1;
if ($p['icons']) {
$stmt = $dbp->prepare("INSERT INTO counter VALUES (:time, :pass, :count)");
$stmt->BindValue(":time",$mytime);
$stmt->BindValue(":pass","icons");
$stmt->BindValue(":count",0);
$stmt->execute();
echo ProgressBar::start(count($fx),"Creating icon batch (".stepString().")");
echo ProgressBar::start($passed_file,"Creating icon batch (".stepString().")",1);
if (!is_dir("/tmp/Yuba/")) { mkdir("/tmp/Yuba/"); }
if (!is_dir("/tmp/Yuba/".$mytime)) { mkdir("/tmp/Yuba/".$mytime); }
$batchfile = "/tmp/Yuba/".$mytime."/batch.sh";
$helper = realpath("helper.php");
foreach ($fx as $array) {
foreach ($fx as $count => $array) {
$fid = $array[0];
$pathname = $array[1];
$icmd = $p['phpbin']." ".$helper." icons ".$fid." ".escapeshellarg($pathname)." ".escapeshellarg($bpath)." ".$mytime;
$icmd = $p['phpbin']." ".$helper." icons ".$fid." ".escapeshellarg($pathname)." ".escapeshellarg($bpath)." ".$mytime."; echo ".ProgressBar::next();
msg($icmd);
$line[] = $icmd;
echo ProgressBar::next();
}
file_put_contents($batchfile,implode("\n", $line));
echo ProgressBar::finish();
echo ProgressBar::start(count($fx),"Running icon batch (".stepString().")");
echo ProgressBar::next();
echo ProgressBar::start($passed_file,"Running icon batch (".stepString().")");
passthru($bin_parallel." < ".$batchfile);
@@ -657,7 +636,7 @@ if ($p['thumbs']) {
$fmt['qlmanage'] = $tpfile;
$fmt['vips'] = $tfile;
$cmd['sox'] = $bin_sox." ".$shellpath." -n trim 00:10 00:30 spectrogram -o - | ".$bin_magick." convert - -crop 800x515+58+30 -scale 515x515! +dither -colors 16 ".$tpfile;
$cmd['sox'] = $bin_sox." ".$shellpath." -n trim 0 $(".$bin_exiftool." -s -s -s -duration# ".$shellpath." | awk '{print $1/10}') spectrogram -o - | ".$bin_magick." convert - -crop 800x515+58+30 -scale 515x515! +dither -colors 16 ".$tpfile;
$cmd['sips'] = "sips -s format jpeg -s formatOptions 80 --resampleHeightWidthMax ".$p['thumb_size']." ".$shellpath." --out ".$tfile;
$cmd['ffmpeg'] = $bin_ffmpeg." -ss $(( $(".$bin_mediainfo." --Inform='Video;%Duration%' ".$shellpath." | cut -d'.' -f1) / 10000 )) -i ".$shellpath." -vframes 1 -filter:v scale='400:-1' -q:v 3 ".$tfile;
$cmd['ql-thumbnail'] = $bin_qlthumb." ".$shellpath." ".$tfile." public.jpeg ".$p['thumb_size']." ".$p['thumb_size']." .8";
@@ -986,7 +965,7 @@ foreach ($files as $splFileInfo) {
// DB
$stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Size, :Inode, :Perms, :Owner, :ATime, :MTime, :CTime, :LinkTarget, :RealPath, :stat, :items, :newest, :fkind, :gfi_type, :gfi_attr, :gfi_created, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :thumb_tool, :contents_filename)");
$stmt = $dbo->prepare("INSERT INTO files VALUES (:pid, :fid, :Pathname, :Path, :Filename, :Extension, :Type, :Size, :Inode, :Perms, :Owner, :ATime, :MTime, :CTime, :LinkTarget, :RealPath, :stat, :items, :newest, :fkind, :gfi_type, :gfi_attr, :gfi_created, :has_exif, :has_mediainfo, :has_hash, :thumb_filename, :thumb_width, :thumb_height, :thumb_tool, :icon_filename, :contents_filename)");
// Identify dir, file, link or bundle dir
@@ -1139,6 +1118,13 @@ foreach ($files as $splFileInfo) {
$stmt->BindValue(":thumb_filename",null);
}
$fetch_icon = $dbp->query("SELECT * FROM icons WHERE fid='".$fid."'")->fetch();
if (@$fetch_icon['relative_path']) {
$stmt->BindValue(":icon_filename",$fetch_icon['relative_path']);
} else {
$stmt->BindValue(":icon_filename",null);
}
} elseif ($type == "dir") {
if (@is_array($dpreview) && $dpreview[$pathname]) {