PHP get a Youtube video duration

To make this work you need to go to Google Developers Console, create a project, enable the YouTube Data API v3, and get a key in authentication key in credentials. This is pretty much the difficult part.

Now the easy part, so easy and keystroke economic to do this in PHP… just a couple of lines, and it’s done:

define("API_KEY", ""); // Fill in your Google API Key
function getYoutubeDurationV3($id) { 
  $json = json_decode(
            file_get_contents('https://www.googleapis.com/youtube/v3/videos'.
                              '?part=contentDetails&d='.$id.'&key='.API_KEY)
          ); 

  $start   = new DateTime('@0');
  $youtube = new DateTime('@0'); 
  $youtube->add(new DateInterval($json->items[0]->contentDetails->duration));
    
  return $youtube->getTimestamp() - $start->getTimestamp();
}

Continue reading “PHP get a Youtube video duration”

Hands on the MK809II

mk809iiI bought myself a MK809II, a Chinese TV stick running Android that connects to the HDMI port of your dumb TV and transforms it in a smart TV. It’s pretty inexpensive, going for about 50 euros and pretty power efficient:

at 5V-1.5A = 7.5W maximum load * 24h = 180W/h max per day, at 0.15€ average KW/h results in a total of 0.027€ per day (around 10€/year in electric bill) if one was to use it day and night….

The specs are okay, with the RK3066 chip, dual core A9 cortex 1.6Ghz CPU and Quad core Mali 400Mhz GPU, 1GB DDR 3 RAM, 8GB internal memory (SD card expandable), WiFi b/g/n and Bluetooth 2.1. Talking about incredible bang for the buck… but as always the main question is, does it deliver?

Continue reading “Hands on the MK809II”