-
-
Save djonatanb/2345646 to your computer and use it in GitHub Desktop.
Personal projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function admin_reup() | |
{ | |
$videos = $this->Video->find('all', array( | |
'conditions' => array('Video.type' => '1'), | |
) | |
); | |
foreach ($videos as &$video) { | |
$video['Video']['duration'] = $this->duration($video['Video']['youtube']); | |
$video['Video']['duration2'] = $this->duration($video['Video']['youtube2']); | |
$video['Video']['duration3'] = $this->duration($video['Video']['youtube3']); | |
} | |
debug($videos); | |
// if ($this->Media->saveAll($videos)) { | |
// $this->Session->setFlash(__('Media has been updated')); | |
// } else { | |
// $this->Session->setFlash(__('The media could not be saved. Please, try again.')); | |
// } | |
$this->set('videos', $videos); | |
$videosnew = $this->Video->find('all', array( | |
'conditions' => array('Video.type' => '1'), | |
) | |
); | |
$this->set('videosnew', $videosnew); | |
} | |
public function duration($yttoken = null){ | |
if (!empty($yttoken)) { | |
$xml = file_get_contents('http://gdata.youtube.com/feeds/api/videos/' . $yttoken); | |
$search = preg_match("<yt:duration seconds=\'(.*?)\'\/>", $xml, $seconds); | |
$floor = floor($seconds[1] / 60); | |
return sprintf("%02.2d:%02.2d:%02.2d", floor($floor / 60), $floor, $seconds[1] % 60); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment