': $in_tag = false; $cleaned .= '>'; $stack = ''; break; default: if ($in_tag) $cleaned .= $html[$i]; else $stack .= $html[$i]; } } if (!$in_tag) $cleaned .= clean_tag_content($stack); return $cleaned; } // Fetch details page assert(isset($_GET['id'])); assert(is_numeric($_GET['id'])); $url = 'http://www.tvgids.nl/programma/' . $_GET['id']; $page = file_get_contents($url); // Parse detailed description, preserving a selected set of HTML tags assert(preg_match('%
\s*(.*?)\s*

'); $description = str_replace('showVideoPlaybutton()', '', $description); $description = clean_html($description); //$description = preg_replace('/\s+/', ' ', $description); //$description = htmlentities($description, ENT_COMPAT | ENT_HTML5 | ENT_SUBSTITUTE, 'ISO-8859-1'); //$description = str_replace(array('<', '>', '/'), array('<', '>', '/'), $description); // Parse properties list assert(preg_match('%\s*(.*?)\s*' . '(?:\s*\s*(.*?)\s*)?%s', $page, $m2)); assert(preg_match_all('%
  • ([\w ]+):(.*?)
  • %', $m2[1] . $m2[2], $m3)); $properties = array(); $movie_search_url = 'http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q='; $title = null; foreach ($m3[1] as $i => $name) { $value = $m3[2][$i]; // Add IMDB URL for movies if ($value == 'Film'/* || $value == 'Serie/Soap'*/) { $results = json_decode(file_get_contents($movie_search_url . urlencode($title)), true); if (count($results) > 0) { $lst = reset($results); $id = $lst[0]['id']; $value .= ' (
    IMDB)'; } } elseif ($name == 'Titel') { $title = $value; } $properties[] = array('name' => $name, 'value' => $value); } header('Content-Type: application/json; charset=utf-8'); echo json_encode(compact('description', 'properties'), JSON_UNESCAPED_SLASHES); ?>