Skip to content

Commit

Permalink
Update v2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AbyssMorgan committed Jun 30, 2024
1 parent c8345ee commit 359d57c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AVE-PHP.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "AVE-PHP"
#define MyAppVersion "2.2.1"
#define MyAppVersion "2.2.2"
#define MyAppPublisher "Abyss Morgan"
#define MyAppURL "https://github.com/AbyssMorgan"
#define MyAppExeName "AVE-PHP.cmd"
Expand Down
2 changes: 1 addition & 1 deletion includes/AVE.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AVE extends Core {
public string $app_data;
public bool $abort = false;
public string $app_name = "AVE-PHP";
public string $version = "2.2.1";
public string $version = "2.2.2";

private array $folders_to_scan = [
'bin',
Expand Down
18 changes: 15 additions & 3 deletions includes/avecore/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Core {

public int $core_version = 11;
public int $core_version = 12;

public IniFile $config;

Expand Down Expand Up @@ -665,12 +665,13 @@ public function is_text_file(string $path) : bool {
}

public function exec(string $program, string $command, array &$output = null, int &$result_code = null) : string|false {
if(is_null($this->core_path)) return false;
if($this->windows && is_null($this->core_path)) return false;
if($this->windows) $program = $this->get_file_path("$this->core_path/$program.exe");
return exec("\"$program\" $command", $output, $result_code);
}

public function is_admin() : bool {
if(!$this->windows) return false;
return exec('net session 1>NUL 2>NUL || (ECHO NO_ADMIN)') != 'NO_ADMIN';
}

Expand Down Expand Up @@ -760,7 +761,10 @@ public function trash(string $path) : bool {
}
}
} else {
return $this->delete($path);
$output = [];
$returnVar = 0;
exec("gio trash ".escapeshellarg($path), $output, $returnVar);
return ($returnVar === 0);
}
$this->write_error("FAILED TRASH \"$path\"");
return false;
Expand Down Expand Up @@ -802,6 +806,14 @@ public function clean_file_extension(string $extension) : string {
return strtolower(preg_replace("/\s/is", "", $extension));
}

public function get_output_null(){
if($this->windows){
return 'nul';
} else {
return '/dev/null';
}
}

}

?>
20 changes: 10 additions & 10 deletions includes/services/MediaFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,50 +77,50 @@ public function is_gif_animated(string $path) : bool {
}

public function get_video_info(string $path): array {
$this->ave->exec("ffprobe", "-v error -show_entries format -show_streams -of json \"$path\" 2>nul", $output);
$this->ave->exec("ffprobe", "-v error -show_entries format -show_streams -of json \"$path\" 2>".$this->ave->get_output_null(), $output);
$info = json_decode(implode('', $output), true);
return $info;
}

public function get_video_fps(string $path) : float {
$this->ave->exec("ffprobe", "-v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate \"$path\" 2>nul", $output);
$this->ave->exec("ffprobe", "-v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate \"$path\" 2>".$this->ave->get_output_null(), $output);
eval('$fps = '.trim(preg_replace('/[^0-9.\/]+/', "", $output[0])).';');
return $fps;
}

public function get_video_codec(string $path) : string {
$this->ave->exec("ffprobe", "-v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 \"$path\" 2>nul", $output);
$this->ave->exec("ffprobe", "-v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 \"$path\" 2>".$this->ave->get_output_null(), $output);
return trim($output[0]);
}

public function get_video_resolution(string $path) : string {
$this->ave->exec("ffprobe", "-v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 \"$path\" 2>nul", $output);
$this->ave->exec("ffprobe", "-v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 \"$path\" 2>".$this->ave->get_output_null(), $output);
return rtrim($output[0] ?? '0x0', 'x');
}

public function get_video_color_primaries(string $path): string {
$this->ave->exec("ffprobe","-v error -select_streams v:0 -show_entries stream=color_primaries -of default=noprint_wrappers=1:nokey=1 \"$path\" 2>nul", $output);
$this->ave->exec("ffprobe","-v error -select_streams v:0 -show_entries stream=color_primaries -of default=noprint_wrappers=1:nokey=1 \"$path\" 2>".$this->ave->get_output_null(), $output);
return trim($output[0] ?? '');
}

public function get_video_duration(string $path) : string {
$this->ave->exec("ffprobe", "-i \"$path\" -show_entries format=duration -v quiet -of csv=\"p=0\" -sexagesimal 2>nul", $output);
$this->ave->exec("ffprobe", "-i \"$path\" -show_entries format=duration -v quiet -of csv=\"p=0\" -sexagesimal 2>".$this->ave->get_output_null(), $output);
$file_duration = trim($output[0]);
$h = $m = $s = 0;
sscanf($file_duration,"%d:%d:%d", $h, $m, $s);
return sprintf("%02d:%02d:%02d", $h, $m, $s);
}

public function get_video_duration_seconds(string $path) : int {
$this->ave->exec("ffprobe", "-i \"$path\" -show_entries format=duration -v quiet -of csv=\"p=0\" -sexagesimal 2>nul", $output);
$this->ave->exec("ffprobe", "-i \"$path\" -show_entries format=duration -v quiet -of csv=\"p=0\" -sexagesimal 2>".$this->ave->get_output_null(), $output);
$file_duration = trim($output[0]);
$h = $m = $s = 0;
sscanf($file_duration,"%d:%d:%d", $h, $m, $s);
return (intval($h) * 3600) + (intval($m) * 60) + intval($s);
}

public function get_video_languages(string $path) : array {
$this->ave->exec("ffprobe", "-i \"$path\" -show_entries stream=index:stream_tags=language -select_streams a -of compact=p=0:nk=1 2> nul", $output);
$this->ave->exec("ffprobe", "-i \"$path\" -show_entries stream=index:stream_tags=language -select_streams a -of compact=p=0:nk=1 2> ".$this->ave->get_output_null(), $output);
$data = [];
foreach($output as $language){
$parts = explode("|", $language);
Expand All @@ -130,7 +130,7 @@ public function get_video_languages(string $path) : array {
}

public function get_audio_channels(string $path) : int {
$this->ave->exec("ffprobe", "-v error -select_streams a:0 -show_entries stream=channels -of default=noprint_wrappers=1:nokey=1 \"$path\" 2>nul", $output);
$this->ave->exec("ffprobe", "-v error -select_streams a:0 -show_entries stream=channels -of default=noprint_wrappers=1:nokey=1 \"$path\" 2>".$this->ave->get_output_null(), $output);
return (int)trim($output[0] ?? '0');
}

Expand Down Expand Up @@ -182,7 +182,7 @@ public function get_video_thumbnail(string $path, string $output, int $w, int $r
$output_file = $this->ave->get_file_path("$output/".pathinfo($path, PATHINFO_BASENAME).".webp");
if(file_exists($output_file)) return true;
if(!file_exists($input_file)){
$this->ave->exec("mtn", "-w $w -r $r -c $c -P \"$path\" -O \"$output\" >nul 2>nul", $out);
$this->ave->exec("mtn", "-w $w -r $r -c $c -P \"$path\" -O \"$output\" >".$this->ave->get_output_null()." 2>".$this->ave->get_output_null(), $out);
if(!file_exists($input_file)) return false;
}
$image = new Imagick();
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.1
2.2.2

0 comments on commit 359d57c

Please sign in to comment.