Probably fixed things by not really doing anything in particular?

This commit is contained in:
flash 2023-07-12 17:50:27 +00:00
parent fb9d9b02a0
commit d8e02e7f12
2 changed files with 25 additions and 11 deletions

View file

@ -3,6 +3,7 @@ namespace Uiharu;
use stdClass;
use Imagick;
use RuntimeException;
use Index\IO\Stream;
use Index\IO\ProcessStream;
@ -23,23 +24,35 @@ final class FFMPEG {
}
public static function probe(string $url): ?object {
return json_decode(
shell_exec(
sprintf(
'ffprobe -show_streams -show_format -print_format json -v quiet -i %s',
escapeshellarg($url)
)
)
$command = sprintf(
'ffprobe -show_streams -show_format -print_format json -v quiet -i %s',
escapeshellarg($url)
);
$ffprobe = proc_open($command, [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
if(!is_resource($ffprobe))
throw new RuntimeException('Could not open ffprobe.');
try {
$stderr = trim(stream_get_contents($pipes[2]));
if(!empty($stderr))
throw new RuntimeException('ffprobe: ' . $stderr);
$stdout = trim(stream_get_contents($pipes[1]));
if(empty($stdout))
throw new RuntimeException('ffprobe did not report any errors but exited without any output');
} finally {
proc_close($ffprobe);
}
return json_decode($stdout);
}
public static function cleanProbe(string $url): ?object {
return self::cleanProbeResult(self::probe($url));
}
public static function cleanProbeResult(?object $in): ?object {
if($in === null)
return null;
public static function cleanProbeResult(?object $in): object {
$out = new stdClass;
if(!empty($in->format)) {

View file

@ -4,6 +4,7 @@ namespace Uiharu\Lookup;
use Uiharu\AudioTags;
use Uiharu\Url;
use Index\MediaType;
use Index\Colour\Colour;
class WebLookupMediaResult extends WebLookupResult implements \Uiharu\IHasMediaInfo {
private object $mediaInfo;
@ -26,7 +27,7 @@ class WebLookupMediaResult extends WebLookupResult implements \Uiharu\IHasMediaI
public function hasColour(): bool {
return false;
}
public function getColour(): int {
public function getColour(): Colour {
throw new RuntimeException('Unsupported');
}