Imdb\Title::title_year PHP Method

title_year() protected method

Setup title and year properties
protected title_year ( )
    protected function title_year()
    {
        $this->getPage("Title");
        if (@preg_match('!<title>(IMDb\\s*-\\s*)?(?<ititle>.*)(\\s*-\\s*IMDb)?</title>!', $this->page["Title"], $imatch)) {
            $ititle = $imatch['ititle'];
            if (preg_match('!(?<title>.*) \\((?<movietype>.*)(?<year>\\d{4}|\\?{4})((&nbsp;|–)(?<endyear>\\d{4})).*\\)(.*)!', $ititle, $match)) {
                // serial
                $this->main_movietype = trim($match['movietype']);
                $this->main_year = $match['year'];
                $this->main_endyear = $match['endyear'];
                $this->main_title = htmlspecialchars_decode($match['title']);
            } elseif (preg_match('!(?<title>.*) \\((?<movietype>.*)(?<year>\\d{4}|\\?{4}).*\\)(.*)!', $ititle, $match)) {
                $this->main_movietype = trim($match['movietype']);
                $this->main_year = $match['year'];
                $this->main_endyear = $match['year'];
                $this->main_title = htmlspecialchars_decode($match['title']);
            } elseif (preg_match('!<title>(?<title>.*) - IMDb</title>!', $this->page["Title"], $match)) {
                // not yet released, so no dates etc.
                $this->main_title = htmlspecialchars_decode($match['title']);
                $this->main_year = '0';
                $this->main_endyear = '0';
            }
            if (preg_match('!class="originalTitle">(.+?)<span!s', $this->page["Title"], $otitle)) {
                $this->original_title = trim($otitle[1]);
            }
            if (empty($this->main_movietype)) {
                $this->main_movietype = 'Movie';
            }
            if ($this->main_year == "????") {
                $this->main_year = "";
            }
        }
    }