diff options
Diffstat (limited to 'protected/Cache.php')
| -rwxr-xr-x | protected/Cache.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/protected/Cache.php b/protected/Cache.php new file mode 100755 index 0000000..9a2d46e --- /dev/null +++ b/protected/Cache.php @@ -0,0 +1,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"; + + } + +}
\ No newline at end of file |
