Imdb\Title::parse_extcontent PHP Method

parse_extcontent() protected method

Parse segments of external information on "VideoSites"
protected parse_extcontent ( $title, &$res )
    protected function parse_extcontent($title, &$res)
    {
        $page = $this->getPage("VideoSites");
        if (empty($page)) {
            return array();
        }
        // no such page
        if (preg_match("!<h4 class=\"li_group\">{$title}\\s*</h4>\\s*(.+?)<(h4|div)!ims", $this->page["VideoSites"], $match)) {
            if (preg_match_all('!<li>(.+?)</li>!ims', $match[1], $matches)) {
                $mc = count($matches[0]);
                for ($i = 0; $i < $mc; ++$i) {
                    if (preg_match('!<a .*href="(?<url>.+?)".*?>(?<site>.*?) - (?<desc>.*) \\((?<type>.*?)\\)</a>!s', $matches[1][$i], $entry)) {
                        $entry['url'] = $this->convertIMDBtoRealURL($entry['url']);
                        $res[] = array('site' => $entry['site'], 'url' => $entry['url'], 'type' => $entry['type'], 'desc' => $entry['desc']);
                    } elseif (preg_match('!<a .*href="(?<url>.+?)".*?>(?<site>.*?) - (?<desc>.+)</a>!s', $matches[1][$i], $entry)) {
                        $entry['url'] = $this->convertIMDBtoRealURL($entry['url']);
                        $res[] = array('site' => $entry['site'], 'url' => $entry['url'], 'type' => '', 'desc' => $entry['desc']);
                    } elseif (preg_match('!<a .*href="(?<url>.+?)".*?>(?<desc>.+)</a>!s', $matches[1][$i], $entry)) {
                        $entry['url'] = $this->convertIMDBtoRealURL($entry['url']);
                        $res[] = array('site' => '', 'url' => $entry['url'], 'type' => '', 'desc' => $entry['desc']);
                    }
                }
            }
        }
    }