Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 061a3e1

Browse files
author
Joshua Moon
committed
Fixed deprecated function.
1 parent ef4da77 commit 061a3e1

File tree

3 files changed

+59
-66
lines changed

3 files changed

+59
-66
lines changed

src/Detectives/ffmpegDetective.php

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,43 @@
66
class ffmpegDetective implements DetectiveContract
77
{
88
use DetectiveTrait;
9-
9+
1010
/**
1111
* Format types detected by ffprobe.
1212
*
1313
* @var array
1414
*/
1515
private $formats;
16-
16+
1717
/**
1818
* Runs an ffprobe on the file or returns cached information.
1919
*
2020
* @return array|false
2121
*/
22-
private function ffprobe()
22+
private function ffprobe($binary = "ffmpeg")
2323
{
2424
if (!isset($this->metadata))
2525
{
26-
$cmd = env('LIB_FFPROBE', "ffprobe") . " -v quiet -print_format json -show_format -show_streams {$this->file}";
27-
26+
$cmd = "{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}";
27+
2828
exec($cmd, $output, $returnvalue);
29-
29+
3030
$json = json_decode( implode("\n", $output), true );
31-
31+
3232
if (!is_array($json))
3333
{
3434
$json = false;
3535
}
36-
36+
3737
$this->metadata = $json;
38-
38+
3939
if ($this->ffprobeHasFormat())
4040
{
4141
$this->formats = array_filter(explode(",", $json['format']['format_name']));
4242
}
4343
}
4444
}
45-
45+
4646
/**
4747
* Checks requested format against what formats ffprobe returned.
4848
*
@@ -53,25 +53,25 @@ private function ffprobe()
5353
private function ffprobeFormat($format)
5454
{
5555
$this->ffprobe();
56-
56+
5757
if (count($this->formats) > 0)
5858
{
5959
$args = func_get_args();
60-
60+
6161
foreach ($args as $arg)
6262
{
6363
if (in_array($arg, $this->formats))
6464
{
6565
return true;
6666
}
6767
}
68-
68+
6969
return null;
7070
}
71-
71+
7272
return false;
7373
}
74-
74+
7575
/**
7676
* Check our metadata for format name.
7777
*
@@ -83,10 +83,10 @@ private function ffprobeHasFormat()
8383
{
8484
return $this->metadata['format']['format_name'] ?: false;
8585
}
86-
86+
8787
return false;
8888
}
89-
89+
9090
/**
9191
* Check our metadata for a video stream.
9292
*
@@ -104,10 +104,10 @@ private function ffprobeHasVideo()
104104
}
105105
}
106106
}
107-
107+
108108
return false;
109109
}
110-
110+
111111
/**
112112
* Check our metadata for an audio stream.
113113
*
@@ -125,10 +125,10 @@ private function ffprobeHasAudio()
125125
}
126126
}
127127
}
128-
128+
129129
return false;
130130
}
131-
131+
132132
/**
133133
* Checks if the file is a 3GP.
134134
*
@@ -137,15 +137,15 @@ private function ffprobeHasAudio()
137137
protected function lead3GP()
138138
{
139139
$lead = $this->ffprobeFormat("3gp");
140-
140+
141141
if ($lead === true)
142142
{
143143
return $this->closeCase("3gp", "video/3gp", $this->metadata);
144144
}
145-
145+
146146
return null;
147147
}
148-
148+
149149
/**
150150
* Checks if the file is a AAC
151151
*
@@ -154,15 +154,15 @@ protected function lead3GP()
154154
protected function leadAAC()
155155
{
156156
$lead = $this->ffprobeFormat("aac");
157-
157+
158158
if ($lead === true)
159159
{
160160
return $this->closeCase("aac", "audio/aac", $this->metadata);
161161
}
162-
162+
163163
return null;
164164
}
165-
165+
166166
/**
167167
* Checks if the file is a FLV.
168168
*
@@ -171,15 +171,15 @@ protected function leadAAC()
171171
protected function leadFLV()
172172
{
173173
$lead = $this->ffprobeFormat("flv");
174-
174+
175175
if ($lead === true)
176176
{
177177
return $this->closeCase("flv", "video/x-flv", $this->metadata);
178178
}
179-
179+
180180
return null;
181181
}
182-
182+
183183
/**
184184
* Checks if the file is a MP3
185185
*
@@ -188,15 +188,15 @@ protected function leadFLV()
188188
protected function leadMP3()
189189
{
190190
$lead = $this->ffprobeFormat("mp1", "mp2", "mp3", "mpg", "mpeg");
191-
191+
192192
if ($lead === true)
193193
{
194194
return $this->closeCase("mp3", "audio/mpeg", $this->metadata);
195195
}
196-
196+
197197
return null;
198198
}
199-
199+
200200
/**
201201
* Checks if the file is a MP4.
202202
*
@@ -205,7 +205,7 @@ protected function leadMP3()
205205
protected function leadMP4()
206206
{
207207
$lead = $this->ffprobeFormat("mp4", "m4a");
208-
208+
209209
if ($lead === true)
210210
{
211211
if ($this->ffprobeHasVideo() !== false)
@@ -221,10 +221,10 @@ protected function leadMP4()
221221
return false;
222222
}
223223
}
224-
224+
225225
return null;
226226
}
227-
227+
228228
/**
229229
* Checks if the file is a MKA.
230230
*
@@ -233,7 +233,7 @@ protected function leadMP4()
233233
protected function leadMKA()
234234
{
235235
$lead = $this->ffprobeFormat("matroska", "webm");
236-
236+
237237
if ($lead === true)
238238
{
239239
if ($this->ffprobeHasAudio() !== false)
@@ -245,10 +245,10 @@ protected function leadMKA()
245245
return false;
246246
}
247247
}
248-
248+
249249
return null;
250250
}
251-
251+
252252
/**
253253
* Checks if the file is a MKV.
254254
*
@@ -257,7 +257,7 @@ protected function leadMKA()
257257
protected function leadMKV()
258258
{
259259
$lead = $this->ffprobeFormat("matroska", "webm");
260-
260+
261261
if ($lead === true)
262262
{
263263
if ($this->ffprobeHasVideo() !== false)
@@ -269,10 +269,10 @@ protected function leadMKV()
269269
return false;
270270
}
271271
}
272-
272+
273273
return null;
274274
}
275-
275+
276276
/**
277277
* Checks if the file is a OGG Audio-only (OGA).
278278
*
@@ -281,7 +281,7 @@ protected function leadMKV()
281281
protected function leadOGG()
282282
{
283283
$lead = $this->ffprobeFormat("ogg", "oga", "ogv");
284-
284+
285285
if ($lead === true)
286286
{
287287
if ($this->ffprobeHasVideo() !== false)
@@ -297,10 +297,10 @@ protected function leadOGG()
297297
return false;
298298
}
299299
}
300-
300+
301301
return null;
302302
}
303-
303+
304304
/**
305305
* Checks if the file is a WAV
306306
*
@@ -309,15 +309,15 @@ protected function leadOGG()
309309
protected function leadWAV()
310310
{
311311
$lead = $this->ffprobeFormat("wav");
312-
312+
313313
if ($lead === true)
314314
{
315315
return $this->closeCase("wav", "audio/wave", $this->metadata);
316316
}
317-
317+
318318
return null;
319319
}
320-
320+
321321
/**
322322
* Checks if the file is a WEBM.
323323
*
@@ -326,7 +326,7 @@ protected function leadWAV()
326326
protected function leadWEBM()
327327
{
328328
$lead = $this->ffprobeFormat("webm");
329-
329+
330330
if ($lead === true)
331331
{
332332
if ($this->ffprobeHasVideo() !== false)
@@ -342,10 +342,10 @@ protected function leadWEBM()
342342
return false;
343343
}
344344
}
345-
345+
346346
return null;
347347
}
348-
348+
349349
/**
350350
* Can this file type potentially cause damage or intrude on a user's privacy?
351351
* This means executable programs, or file formats that can contact remote servers in any way (even SVGs).
@@ -356,10 +356,10 @@ protected function leadWEBM()
356356
public function isRisky()
357357
{
358358
parent::isRisky();
359-
359+
360360
return false;
361361
}
362-
362+
363363
/**
364364
* Can the system run this Detective?
365365
*
@@ -369,7 +369,7 @@ public function on()
369369
{
370370
$ffmpeg = shell_exec("which ffmpeg");
371371
$ffprobe = shell_exec("which ffprobe");
372-
372+
373373
return (empty($ffmpeg) ? false : true) && (empty($ffprobe) ? false : true);
374374
}
375-
}
375+
}

src/Providers/SleuthServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ class SleuthServiceProvider extends ServiceProvider
1212
* @var bool
1313
*/
1414
protected $defer = true;
15-
15+
1616
/**
1717
* Register the service provider.
1818
*
1919
* @return void
2020
*/
2121
public function register()
2222
{
23-
$this->app->bindShared('sleuth', function() {
23+
$this->app->singleton('sleuth', function() {
2424
return new FileSleuth();
2525
});
26-
26+
2727
$this->app->alias('sleuth', 'InfinityNext\Sleuth\FileSleuth');
2828
}
29-
29+
3030
/**
3131
* Get the services provided by the provider.
3232
*

tests/AudioOGGTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,4 @@ public function testOGG()
1010
$detective->check(__DIR__ . "/files/normal.ogg");
1111
$this->assertEquals('ogg', $detective->getExtension());
1212
}
13-
14-
public function testOGG()
15-
{
16-
$detective = new AudioDetective;
17-
$detective->check(__DIR__ . "/files/normal.ogg");
18-
$this->assertEquals('ogg', $detective->getExtension());
19-
}
2013
}

0 commit comments

Comments
 (0)