Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shahednur/b7c4e99ca2a445dbaff61e7a8c64ba7f to your computer and use it in GitHub Desktop.
Save shahednur/b7c4e99ca2a445dbaff61e7a8c64ba7f to your computer and use it in GitHub Desktop.
function getVideoUrl($link){
$data = explode('.mp4', $link);
$decode = urldecode($data[0]);
$linkDownload = array();
$v1080p = $decode.'_hd.mp4';
$v720p = $decode.'_dvd.mp4';
$v360p = $decode.'_fmt1.ogv';
$linkDownload['1080p'] = $v1080p;
$linkDownload['720p'] = $v720p;
$linkDownload['360p'] = $v360p;
$files = '';
foreach ($linkDownload as $key => $l){
$files .= '["type"=> "video/mp4", "label"=> "'.$key.'", "file"=> "'.$l.'"],';
}
if(@!$files) $files = '["type"=> "video/mp4", "label"=> "HD", "file"=> "'.$decode .'=m18'.'"]';
return '['.rtrim($files, ',').']';
}
//url in html
<input type="text" name="url" />
//url in php
$url = $_POST['url'];
//usages of this function
$linkdown = getVideoUrl($url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment