0.7.11.5
This commit is contained in:
98
Yuba.php
98
Yuba.php
@@ -3,7 +3,7 @@
|
||||
// Yuba
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
$version = "0.7.10.3";
|
||||
$version = "0.7.11.5";
|
||||
|
||||
ini_set('memory_limit', '10240M');
|
||||
date_default_timezone_set("America/Los_Angeles");
|
||||
@@ -11,23 +11,22 @@ date_default_timezone_set("America/Los_Angeles");
|
||||
// Includes & Prefs
|
||||
//////////////////////////////////////////
|
||||
|
||||
$p = unserialize(file_get_contents("prefs.php"));
|
||||
|
||||
require("functions.php");
|
||||
require("filetypes.php");
|
||||
|
||||
$wopt_noprofile = 0;
|
||||
$wopt_steps = 10;
|
||||
$wopt_currstep = 1;
|
||||
|
||||
$parser = new plistParser();
|
||||
|
||||
$p = unserialize(file_get_contents("prefs.php"));
|
||||
|
||||
// Path & application variables
|
||||
//////////////////////////////////////////
|
||||
|
||||
$stamp = date("Y-m-d_H-i-s", time());
|
||||
|
||||
if (!isset($argv[1])) { echo "Input error"; die; }
|
||||
if (!isset($argv[1])) { echo "No input"; die; }
|
||||
$zpath = realpath(@$argv[1]);
|
||||
if (@$argv[2]) { $bdest = realpath($argv[2]); } else { $bdest = realpath($p['bdest']); }
|
||||
if (!is_dir($zpath) | !is_dir($bdest)) { echo "Filepath error"; die; }
|
||||
@@ -41,38 +40,6 @@ if (!is_dir($bpath)) { mkdir($bpath); }
|
||||
if (!is_dir($bpath."/thumbs")) { mkdir($bpath."/thumbs"); }
|
||||
if (!is_dir($bpath."/contents")) { mkdir($bpath."/contents"); }
|
||||
|
||||
// Treat these directories as files
|
||||
$p['bundles'] = array( "app",
|
||||
"bundle",
|
||||
"sparsebundle",
|
||||
"photoslibrary",
|
||||
"aplibrary",
|
||||
"apvault",
|
||||
"abbu",
|
||||
"calendar",
|
||||
"framework",
|
||||
"plugin",
|
||||
"kext",
|
||||
"rtfd"
|
||||
);
|
||||
|
||||
foreach ($p['bundles'] as $bundle) {
|
||||
$p['nodescend'][] = "*.".$bundle;
|
||||
}
|
||||
|
||||
// Ignore matching files and directories
|
||||
$p['ignore'] = array( ".DS_Store",
|
||||
".Trashes",
|
||||
".DocumentRevisions-V100",
|
||||
".Spotlight-V100",
|
||||
".TemporaryItems",
|
||||
".apdisk",
|
||||
".com.apple.timemachine.donotpresent",
|
||||
".fseventsd",
|
||||
".metadata-never-index",
|
||||
".neofinder.abemeda.volinfo.xml"
|
||||
);
|
||||
|
||||
// Metadata tools
|
||||
$bin_gfi = __DIR__."/bin/GetFileInfo";
|
||||
$bin_mediainfo = __DIR__."/bin/mediainfo";
|
||||
@@ -187,11 +154,11 @@ if ($type == "Disk image") {
|
||||
$image_file = false;
|
||||
}
|
||||
|
||||
if ($wopt_noprofile) {
|
||||
$profile = "disabled";
|
||||
} else {
|
||||
if ($p['profile']) {
|
||||
echo msg("system_profiler");
|
||||
$profile = shell_exec("system_profiler SPHardwareDataType SPStorageDataType SPThunderboltDataType SPUSBDataType 2>&1");
|
||||
} else {
|
||||
$profile = "disabled";
|
||||
}
|
||||
$qlmanage = shell_exec("qlmanage -m 2>&1");
|
||||
$sysvers = shell_exec("sw_vers 2>&1");
|
||||
@@ -460,10 +427,7 @@ echo ProgressBar::finish();
|
||||
// Thow permissions error
|
||||
|
||||
if (count($noread)) {
|
||||
echo msg("Current user (".posix_getuid().") does not have read access to the following files:");
|
||||
foreach ($noread as $file) {
|
||||
echo $file."\n";
|
||||
}
|
||||
echo msg("Current user (".posix_getuid().") does not have read access to the following files:\n").implode("\n",$noread);
|
||||
if ($p['readability']) {
|
||||
echo msg("Exiting...");
|
||||
die;
|
||||
@@ -546,7 +510,7 @@ if ($p['thumbs']) {
|
||||
$tfile = $tpath."/".$fid.".jpg";
|
||||
|
||||
// HACK for ql-thumbnail bug
|
||||
$t_skip = array("emlx");
|
||||
$t_skip = array("emlx","flac");
|
||||
if (count($t_skip) && in_array($ext, $t_skip)) {
|
||||
echo ProgressBar::next("Skipping ".shortlabel($pathname));
|
||||
continue;
|
||||
@@ -571,13 +535,13 @@ if ($p['thumbs']) {
|
||||
|
||||
// first try to make a thumb with external tools
|
||||
$cmd = null;
|
||||
if (in_array($ext, $t_files['sips'])) {
|
||||
if (in_array($ext, $p['t_files']['sips'])) {
|
||||
//$cmd = $bin_tv." ".$shellpath." -o ".$tfile."[Q=90,optimize_coding] --size=".$p['thumb_size'];
|
||||
$cmd = "sips -s format jpeg -s formatOptions 80 --resampleHeightWidthMax ".$p['thumb_size']." ".$shellpath." --out ".$tfile;
|
||||
$stmt->BindValue(":tool","sips");
|
||||
} elseif (in_array($ext, $t_files['ffmpeg'])) {
|
||||
} elseif (in_array($ext, $p['t_files']['ffmpeg'])) {
|
||||
//$cmd = $bin_tf." -i ".$shellpath." -o ".$tfile." -s ".$p['thumb_size']." -c jpg -q 8.5";
|
||||
$cmd = $bin_ffmpeg." -ss $(( $(".$bin_mediainfo." --Inform='Video;%Duration%' ".$shellpath.") / 10000 )) -i ".$shellpath." -vframes 1 -filter:v scale='400:-1' -q:v 3 ".$tfile;
|
||||
$cmd = $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;
|
||||
$stmt->BindValue(":tool","ffmpeg");
|
||||
}
|
||||
|
||||
@@ -592,7 +556,8 @@ if ($p['thumbs']) {
|
||||
}
|
||||
|
||||
// success, move thumb into the bundle
|
||||
if (file_exists($tfile) && @filesize($tfile)) {
|
||||
// ignore generic music icon thumbs (7133)
|
||||
if (file_exists($tfile) && @filesize($tfile) && @filesize($tfile) != 7133) {
|
||||
$stmt->BindValue(":relative_path",substr($tfile, strlen($bpath)));
|
||||
list($width, $height) = getimagesize($tfile);
|
||||
$stmt->BindValue(":width",$width);
|
||||
@@ -622,7 +587,7 @@ if ($p['contents']) {
|
||||
$ext = pathinfo($pathname,PATHINFO_EXTENSION);
|
||||
$cpath = $bpath."/contents/".substr($fid, 0, 2);
|
||||
$cfile = $cpath."/".$fid.".zip";
|
||||
if (in_array($ext, $c_files)) {
|
||||
if (in_array($ext, $p['c_files'])) {
|
||||
if (!is_dir($cpath)) { mkdir($cpath); }
|
||||
if (!file_exists($cfile) && filesize($pathname) < 25000) {
|
||||
|
||||
@@ -663,12 +628,12 @@ if ($p['meta']) {
|
||||
$ext = pathinfo($pathname,PATHINFO_EXTENSION);
|
||||
$found = 1;
|
||||
|
||||
if (!in_array($ext, $e_files) && !in_array($ext, $m_files)) {
|
||||
if (!in_array($ext, $p['e_files']) && !in_array($ext, $p['m_files'])) {
|
||||
echo ProgressBar::next("Not a media file: ".shortlabel($pathname));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($ext, $e_files)) {
|
||||
if (in_array($ext, $p['e_files'])) {
|
||||
$check = $dbp->query("SELECT EXISTS(SELECT 1 FROM exiftool WHERE fid='".$fid."')")->fetch()[0];
|
||||
if (!$check) {
|
||||
$arrstring = shell_exec($bin_exiftool." -php ".$shellpath);
|
||||
@@ -685,13 +650,14 @@ if ($p['meta']) {
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($ext, $m_files)) {
|
||||
if (in_array($ext, $p['m_files'])) {
|
||||
$check = $dbp->query("SELECT EXISTS(SELECT 1 FROM mediainfo WHERE fid='".$fid."')")->fetch()[0];
|
||||
if (!$check) {
|
||||
$stmt = $dbp->prepare("INSERT INTO mediainfo VALUES (:fid, :info)");
|
||||
$stmt->BindValue(":fid",$fid);
|
||||
//$stmt->BindValue(":info",serialize(parseMediaInfo(shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"))));
|
||||
$stmt->BindValue(":info",shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"));
|
||||
//$stmt->BindValue(":info",shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1"));
|
||||
$stmt->BindValue(":info",shell_exec($bin_mediainfo." --Output=JSON ".$shellpath." 2>&1"));
|
||||
$stmt->execute();
|
||||
$found = 0;
|
||||
}
|
||||
@@ -1005,8 +971,10 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
$yes_contents = $dbp->query("SELECT relative_path FROM contents WHERE fid='".$fid."'")->fetch()[0];
|
||||
$stmt->BindValue(":contents_filename",$yes_contents);
|
||||
|
||||
$fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$fid."'")->fetch();
|
||||
|
||||
if (!in_array($extension, $t_skip)) {
|
||||
$fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$fid."'")->fetch();
|
||||
}
|
||||
if (@$fetch_thumb['relative_path']) {
|
||||
$stmt->BindValue(":thumb_filename",$fetch_thumb['relative_path']);
|
||||
$stmt->BindValue(":thumb_width",$fetch_thumb['width']);
|
||||
@@ -1137,14 +1105,18 @@ while ($row_a = $loop->fetch()) {
|
||||
if (isset($row_a['has_mediainfo'])) {
|
||||
|
||||
$row_d = $dbp->query("SELECT * FROM mediainfo WHERE (rowid='".$row_a['has_mediainfo']."')")->fetch();
|
||||
$decoded = @json_decode(json_encode(simplexml_load_string($row_d['info'])),true);
|
||||
$m['m'] = $decoded['File']['track'][0];
|
||||
if (substr($row_d['info'],0,5) == "<?xml") {
|
||||
$decoded = @json_decode(json_encode(simplexml_load_string($row_d['info'])),true);
|
||||
$m_base = $decoded['File']['track'];
|
||||
$m['m'] = $decoded['File']['track'][0];
|
||||
} else {
|
||||
$decoded = @json_decode($row_d['info'],true);
|
||||
$m_base = $decoded['media']['track'];
|
||||
$m['m'] = $decoded['media']['track'][0];
|
||||
}
|
||||
|
||||
//custom values
|
||||
|
||||
$m['m']['SkimTrackCount'] = @count($decoded['File']['track']);
|
||||
|
||||
foreach (@$decoded['File']['track'] as $track) {
|
||||
$m['m']['SkimTrackCount'] = @count($m_base);
|
||||
foreach (@$m_base as $track) {
|
||||
if (!@$m['m']['SkimDims'] && @$track['Width'] && @$track['Height']) {
|
||||
$m['m']['SkimDims'] = sanitize($track['Width'],"i").$display_delimiter.sanitize($track['Height'],"i");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user