Posted by Crio on Mon 8 Jun 19:03
report abuse | download | new post
- <?php
- class vbox7{
- public $url = null;
- public $code = null;
- public $title = null;
- public $thumbnail = null;
- public $flvUrl = null;
- public $subtitles = null;
- public $subtitlesExtension = 'srt';
- public function __construct($url, $subs = 'srt'){
- $this->url = $match[0];
- $this->code = $match[1];
- $this->title = $found[1];
- }
- if(preg_match("/&flv_addr=(.*?)&jpg_addr=(.*?)&subsEnabled=(?:true&subsData=)?(.*?)$/", $src, $parts)){
- $this->flvUrl = "http://".$parts[1];
- $this->thumbnail = "http://".$parts[2];
- if($parts[3]){
- if($subs == 'srt'){
- $subs = new SRTFile(json_decode($parts[3]));
- }else{
- $subs = new SUBFile(json_decode($parts[3]));
- $this->subtitlesExtension = 'sub';
- }
- $this->subtitles = $subs->parse();
- }
- }
- }else{
- throw new Exception("Невалиден линк");
- }
- }
- }
- /**
- * SRT File Class
- * 1\r\n
- * 00:00:04,680 --> 00:00:08,500\r\n
- * Кой даде идеята?\r\n
- * - Ти.\r\n
- * \r\n
- *
- */
- class SRTFile{
- private $source = null;
- public function __construct($src){
- if($src)
- $this->source = $src;
- }
- public function parse(){
- $number = 1;
- $return = "";
- for($i=0; $i<sizeof($this->source);$i++){
- $return .= ($i+1) . "\r\n";
- $return .= $this->formatTime($this->source[$i]->f) . " --> " . $this->formatTime($this->source[$i]->t) . "\r\n";
- $return .= $this->source[$i]->s . "\r\n";
- $return .= "\r\n";
- }
- return $return;
- }
- private function leadingNull($number){
- if($number < 10) return "0".$number;
- return $number;
- }
- private function formatTime($seconds){
- $hours = $this->leadingNull((int)($seconds/360));
- $minutes =$this->leadingNull((int)($seconds/60));
- $seconds = $this->leadingNull($seconds - (((int)($seconds/360))*360 + ((int)($seconds/60))*60));
- return $hours.":".$minutes.":".$seconds.",000";
- }
- }
- /**
- * SUB File Class
- * {from*fps}{to*fps}Content(nl as |)\r\n
- *
- */
- class SUBFile{
- private $source = NULL;
- public function __construct($src){
- if($src)
- $this->source = $src;
- }
- public function parse($fps = 30){
- //Свалих 2-3 клипа от vbox7 и всичките бяха с FPS 30.0 така, че го оставям така по подразбиране.
- $return = "";
- for($i=0; $i<sizeof($this->source);$i++){
- $return .= "{". $fps * $this->source[$i]->f ."}{" . $fps * $this->source[$i]->t . "}" . $this->newLineFix($this->source[$i]->s) . "\r\n";
- }
- return $return;
- }
- public function newLineFix($string){
- }
- }
- ?>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.