blob: 9a2d46ed8a2d54724d4fb991163eef44ad50fdb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
/**
* Created by IntelliJ IDEA.
* User: root
* Date: 8/15/13
* Time: 11:17 AM
* To change this template use File | Settings | File Templates.
*/
class Cache {
public function isCached($id){
$cachePath = Settings::$CachePath;
$result = (file_exists($cachePath. DIRECTORY_SEPARATOR .$id)) ? true : false;
return $result;
}
public function urlToId($url){
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $url);
//$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", '_', $clean);
return $clean;
}
public function CacheHttpVideo($url){
$id = $this->urlToId($url);
if(file_exists(Settings::$CachePath . $id . ".part")){
return false;
}
$speed = Settings::$CacheDownloadMaxSpeed;
$r = "";
if($speed){
$r = " -r $speed ";
}
$command = Settings::$YoutubeDlCommand . " $r -o '" . Settings::$CachePath . "$id" . "' $url";
$output = exec($command);
echo "$output";
}
}
|