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

@@ -4,17 +4,12 @@
// //
//////////////////////////////////////////
require("functions.php");
require("filetypes.php");
$prefs_file = "/Users/".get_current_user()."/Library/Preferences/yuba_prefs.php";
$p = unserialize(file_get_contents($prefs_file));
$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";
$mode = $argv[1];
$fid = $argv[2];
$pathname = $argv[3];
@@ -29,36 +24,42 @@ $dbp = new PDO("sqlite:".$bpath."/pool.sqlite3");
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbp->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
if (@!$dbp->query("SELECT EXISTS(SELECT 1 FROM icons WHERE fid='".$fid."')")->fetch()[0]) {
switch ($mode) {
$stmt = $dbp->prepare("INSERT INTO icons VALUES (:fid, :hash, :created, :relative_path, :tool)");
$cmd = $bin_qltool." di ".$shellpath." ".$p['thumb_size']." ".$p['thumb_size']." | base64 --decode | ".$bin_magick." convert - -scale 50% -strip -define png:compression-level=9 ".$tfile;
shell_exec($cmd);
case "icons":
$stmt->BindValue(":fid",$fid);
if (@filesize($tfile)) {
$hash = md5_file($tfile);
$stmt->BindValue(":hash",$hash);
if ($row = @$dbp->query("SELECT * FROM icons WHERE hash='".$hash."'")->fetchAll()[0]) {
$stmt->BindValue(":created",$row['created']);
$stmt->BindValue(":relative_path",$row['relative_path']);
$stmt->BindValue(":tool",$row['tool']);
} else {
$dfile = $bpath."/icons/".substr($hash, 0, 2)."/".$hash.".png";
if (!is_dir(dirname($dfile))) { mkdir(dirname($dfile)); }
rename($tfile,$dfile);
$stmt->BindValue(":created",time());
$stmt->BindValue(":relative_path",substr($dfile,strlen($bpath)));
$stmt->BindValue(":tool","qltool");
}
}
$stmt->execute();
if (@!$dbp->query("SELECT EXISTS(SELECT 1 FROM icons WHERE fid='".$fid."')")->fetch()[0]) {
$stmt = $dbp->prepare("INSERT INTO icons VALUES (:fid, :hash, :created, :relative_path, :tool)");
$cmd = $bin_qltool." di ".$shellpath." ".$p['thumb_size']." ".$p['thumb_size']." | base64 --decode | ".$bin_magick." convert - -scale 50% -strip -define png:compression-level=9 ".$tfile;
shell_exec($cmd);
$stmt->BindValue(":fid",$fid);
if (@filesize($tfile)) {
$hash = md5_file($tfile);
$stmt->BindValue(":hash",$hash);
if ($row = @$dbp->query("SELECT * FROM icons WHERE hash='".$hash."'")->fetchAll()[0]) {
$stmt->BindValue(":created",$row['created']);
$stmt->BindValue(":relative_path",$row['relative_path']);
$stmt->BindValue(":tool",$row['tool']);
} else {
$dfile = $bpath."/icons/".substr($hash, 0, 2)."/".$hash.".png";
if (!is_dir(dirname($dfile))) { mkdir(dirname($dfile)); }
rename($tfile,$dfile);
$stmt->BindValue(":created",time());
$stmt->BindValue(":relative_path",substr($dfile,strlen($bpath)));
$stmt->BindValue(":tool","qltool");
}
}
$stmt->execute();
}
break;
}
$stmt = $dbp->prepare("UPDATE counter SET count = count + 1 WHERE time='".$mytime."'");
$stmt->execute();
echo "\nPROGRESS: ".$dbp->query("SELECT count FROM counter WHERE time='".$mytime."'")->fetch()['count'];
echo "\nHelper: ".basename($pathname)."\n";
?>