Imdb\Person::filmograf PHP Method

filmograf() protected method

Get filmography
protected filmograf ( &$res, $type )
    protected function filmograf(&$res, $type)
    {
        $page = $this->getPage("Name");
        preg_match("!<a name=\"{$type}\"(.*?(<div id=\"filmo|<script))!msi", $page, $match);
        if (empty($type)) {
            $match[1] = $page;
        } elseif (empty($match[1])) {
            $pos = strpos($page, '<a name="' . ucfirst($type) . '"');
            if ($pos) {
                $epos = strpos($page, '<div id=', $pos);
                $match[1] = substr($page, $pos, $epos - $pos);
            }
        }
        if (!empty($match) && preg_match_all('!<div class="filmo-row.*?>\\s*(.*?)\\s*</div!ims', $match[1], $matches)) {
            $mc = count($matches[0]);
            for ($i = 0; $i < $mc; ++$i) {
                $year = '';
                $type = Title::MOVIE;
                if (!preg_match('!href="/title/tt(\\d{7})/[^"]*"\\s*>(.*?)</a>\\s*</b>\\n?(.*)!ims', $matches[1][$i], $mov)) {
                    continue;
                }
                if (preg_match('!<br/>\\s*([^>]+)\\s*</div!', $matches[0][$i], $char)) {
                    $chname = trim($char[1]);
                }
                $char = array();
                if (preg_match('!<span class="year_column">[^<]*(\\d{4})(.*?)</span>!ims', $matches[1][$i], $ty)) {
                    $year = $ty[1];
                }
                if (preg_match('!href="/character/ch(\\d{7})[^"]*"\\s*>(.*?)</a>!ims', $matches[1][$i], $char)) {
                    $chid = $char[1];
                    $chname = $char[2];
                } else {
                    $chid = '';
                    if (preg_match('!<br/>\\s*([^>]+)\\s*</*div!', $matches[0][$i], $char)) {
                        $chname = trim($char[1]);
                    } else {
                        $chname = '';
                    }
                }
                if (empty($chname)) {
                    switch ($type) {
                        case 'director':
                            $chname = 'Director';
                            break;
                        case 'producer':
                            $chname = 'Producer';
                            break;
                    }
                }
                if (preg_match("!\\(([^\\)]+)\\)!", $mov[3], $typeMatch)) {
                    foreach ($this->titleTypeMap as $originalType => $trueType) {
                        if ($typeMatch[1] == $originalType) {
                            $type = $trueType;
                            break;
                        }
                    }
                }
                $addons = array();
                if (preg_match_all("!\\((.+)\\)!", $chname, $addonMatches)) {
                    $addons = $addonMatches[1];
                    $chname = trim(preg_replace("!\\((.+)\\)!", '', $chname));
                }
                $res[] = array("mid" => $mov[1], "name" => $mov[2], "year" => $year, "title_type" => $type, "chid" => $chid, "chname" => trim($chname), "addons" => $addons);
            }
        }
    }