Archive for January, 2008

Why don’t they use Opera

Monday, January 21st, 2008

I’ve made a simple pool for my blog readers. I ask them why don’t they use Opera as their main browser, and here came across some answers:

  • At first time they used Opera, they found that Opera’s cache is too strong. And it’s a problem for a web developer because they can’t see the change right away. Well, if they know about Shift+F5, it’s not a problem at all.
     
  • They wonder if they can found something like Firefox’s plugins. They don’t want to switch to Opera because they afraid of loosing the plugin’s benefit.
     
  • Some people using glubble to protect their kids from unwanted page, and Opera doesn’t have this such thing.
     
  • Because Opera is not open source. Well, they don’t really need the source code but they afraid if someday Opera company will be closed. Thus, Opera users will be dumped away. But if Opera were open source, there will be another group who would give Opera a re-birth.
     
  • A friend was afraid of intergalactic law violation when using a little trick to open Google Docs

Last but not least, a little sweet girl was saying that this question is the same as “Why Mac users aren’t as many as Windows users”.

From this pool, now I have idea why don’t they use Opera: because they don’t know much about Opera. Then it’s a task for Opera company to spread more information about Opera and its benefits.

I also wrote this at My Opera blog and forward to Daniel Goldman.

Design Inspirations and Opera Mini 5?

Wednesday, January 9th, 2008

Opera MiniI have a plan to re-design my other blog but still have no idea what to do with the color, placement etc. Until I reached Smashing Magazine and found two posts related to design. I also read a news from Opera Watch about an Indian magazine, My Mobile, that wrote about Opera Mini 5.

Here they are the links:

Happy reading, everyone!

Youtube Downloader using PHP

Monday, January 7th, 2008

This short tutorial will show you how to download videos from Youtube using PHP. CURL is needed for this script because many webhosting now prohibit remote_fopen.

First function, get HTML content from an URL: function get_content_of_url($url){
$ohyeah = curl_init();
curl_setopt($ohyeah, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ohyeah, CURLOPT_URL, $url);
$data = curl_exec($ohyeah);
curl_close($ohyeah);
return $data;
}
?>

Second function, get string that contain the clue of where the video file is located: function get_flv_link($string) {
if (eregi("watch_fullscreen\?video_id=(.*)&title=", $string, $out)) {
$outdata = $out[1];
}
return 'http://youtube.com/get_video.php?video_id='.$outdata;
}
?>

Next function, “visit” the link that we got from second function above. We will read the header and find out the real file location: function get_http_header($url){
$uh = curl_init();
curl_setopt($uh, CURLOPT_URL, $url);
curl_setopt($uh, CURLOPT_HEADER, 1);
curl_setopt($uh, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($uh);
curl_close($uh);
return $res;
}
?>

Function above will return a bunch of HTTP headers and we don’t need them all. This function will parse the HTTP headers and only return the video location: function show_url($http_header){
$arai = explode("\n",$http_header);
foreach($arai as $ini){
if(eregi("location",$ini)) $url = $ini;
}
list($sampah,$hasil) = explode("Location:",$url);
return str_replace("\n","",trim($hasil));
}
?>

Last thing to do, is bundle all functions above: function download_youtube($url){
$data = get_content_of_url($url);
$next_url = get_flv_link($data);
$data = get_http_header($next_url);
return show_url($data);
}
?>

Wait, how to use the youtube downloader? It’s very simple: $url = "http://youtube.com/watch?v=SAQZ0BDXn48";
echo download_youtube($url);
?>

That’s all folks. It’s a very interesting and chalenging moment when I wrote any kind of grabbing scripts. Hope it helps yo all.

Veoh’s Video Downloader

Sunday, January 6th, 2008

Here is the script that you can use to download videos from veoh.com. I wrote this script to bid a project at rentacoder.com and finished the code within half an hour. Consist of three functions and you can put them all into a class. But I prefer let them apart.

// this is used to get url content
function get_url_content($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}// this function used to retrieve value inbetween specific delimiter
function get_inbetween($tag1,$tag2,$string) {
if (eregi(”$tag1(.*)$tag2″, $string, $out)) {
$outdata = $out[1];
}
return $outdata;
}

// this function used to download music from veoh.com
// URL: http://www.veoh.com/videos/v1734061jbnYFjPj
function get_veoh($url){

// get the music_id
$ari = explode(”/”,$url);
$v_id = array_pop($ari);

// retrieve xml files
$data = get_url_content(”http://www.veoh.com/rest/video/”.$v_id.”/details”);

// retrieve path into music files
$hasil = get_inbetween(”fullPreviewHashPath”,”fullPreviewToken=”,$data);
$hasil = str_replace(array(’”‘,’='),”",$hasil);

// yell it loud
return trim($hasil);
}

echo get_veoh(”http://www.veoh.com/videos/v1734061jbnYFjPj”);
?>