]> _ Git - cubist_util.git/commitdiff
wip #7894 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 14 Jan 2026 18:00:46 +0000 (19:00 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 14 Jan 2026 18:00:46 +0000 (19:00 +0100)
src/CommandLine/Docling.php
src/Url.php

index ddeea8202c339f23a867ec15cba9f5869d9b50d3..b47b00055c4bc96f04577624c9f315bedccbda65 100644 (file)
@@ -3,6 +3,7 @@
 namespace Cubist\Util\CommandLine;
 
 use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
 
 class Docling extends CommandLine
 {
@@ -15,16 +16,21 @@ class Docling extends CommandLine
 
     public static function OCR($image, $locale = null)
     {
-        $out = $image . '.' . md5($locale) . '.md';
+        $f = new \SplFileInfo($image);
+
+        $out = $image . '.' . md5($locale) . '.html';
         if (!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__)) {
+            $tmp = Files::tmpdir();
             $cli = new self();
             $cli->setArg('to', 'md');
             if ($locale) {
                 $cli->setArg('ocr-lang', $locale);
             }
-            $cli->setArg('output', $out);
+            $cli->setArg('output', $tmp);
             $cli->setArg(null, $image);
             $cli->execute();
+
+            $md = $tmp . '/' . $f->getBasename('.md');
         }
         return file_get_contents($out);
     }
index d273c6e088fd0a481a704459377b75f51660febd..d95d25d155f582a20fe09a29421e40c9f249b024 100644 (file)
@@ -82,4 +82,14 @@ class Url
         return $str;
     }
 
+    public static function mtime($url){
+        $h = get_headers($url, 1);
+
+        $dt = NULL;
+        if (!($h || strstr($h[0], '200') === FALSE)) {
+            $dt = new \DateTime($h['Last-Modified']);
+            return $dt->getTimestamp();
+        }
+
+    }
 }