FabianBeiner / PHP-IMDB-Grabber

This PHP library enables you to scrape data from IMDB.com.
MIT License
271 stars 160 forks source link

getTVInfo stoped working #191

Closed FLIKI closed 1 year ago

FLIKI commented 1 year ago

Due to a change in IMDB the getTVInfo function is not working...

I have a few suggestions for a fix:

LINE 2064: $fullEpisodes = sprintf('https://www.imdb.com/title/tt%s/episodes?season=%d', $this->iId, $page); should now be -> $fullEpisodes = sprintf('https://www.imdb.com/title/tt%s/episodes/?season=%d', $this->iId, $page); If hte "/" is missing imdb makes a redirect with status code 308.

LINE 2076: $aSplit = IMDBHelper::matchRegex($sSource, '~<meta itemprop="episodeNumber"(.*?)<div class="wtw-option-standalone".data-tconst="(.*?)".data-watchtype="minibar".data-baseref="ttep">~s'); should be changed to -> $aSplit = IMDBHelper::matchRegex($sSource, '~<article class=.+?episode-item-wrapper(.+?)ipc-rating-star--rate">Rate</span>~s'); The new html design of the seasons and episodes page needs a new regex to split the episodes

LINE 2079: $aReturned = IMDBHelper::matchRegex($aSplit[1][$i], '~content="(.*?)"(?:.*)"airdate">\s+(.*?)\s+<\/div>(?:.*)<strong><a.href="\/title\/(tt\d{6,})(?:.*?)"\s+?title="(.*?)".itemprop="name">(?:.*)"ipl-rating-star__rating">(.*?)<\/span>\s+<span.class="ipl-rating-star__total-votes">\((.*?)\)<\/span>(?:.*)itemprop="description">(.*?)<\/div>~s'); must be -> $aReturned = IMDBHelper::matchRegex($aSplit[1][$i], '~h4.+/title/(tt\d+)/[?]ref_.+ttep_ep(\d+).+?S\d+\.E\d+ ∙ (.+)</a></h4><span class=".+?">(.+?)</span>.+?<div class="ipc-html-content-inner-div">(.+?)</div>.+?ratingGroup--imdb-rating.+?</svg>(.+?)<span.+?ipc-rating-star--voteCount">.+?>(.+?)<~s'); Extracting data for every episode also needs new regex

Due to the new order of the episode data regex lines 2084-2090: 'episode' => IMDBHelper::cleanString($aReturned[1][$n]), 'title' => IMDBHelper::cleanString($aReturned[4][$n]), 'rating' => IMDBHelper::cleanString($aReturned[5][$n]), 'votes' => IMDBHelper::cleanString($aReturned[6][$n]), 'airdate' => IMDBHelper::cleanString($aReturned[2][$n]), 'plot' => IMDBHelper::cleanString($aReturned[7][$n]), 'id' => IMDBHelper::cleanString($aReturned[3][$n]), must be reorder ->

'episode' => IMDBHelper::cleanString($aReturned[2][$n]), 'title' => IMDBHelper::cleanString($aReturned[3][$n]), 'rating' => IMDBHelper::cleanString($aReturned[6][$n]), 'votes' => IMDBHelper::cleanString($aReturned[7][$n]), 'airdate' => IMDBHelper::cleanString($aReturned[4][$n]), 'plot' => IMDBHelper::cleanString($aReturned[5][$n]), 'id' => IMDBHelper::cleanString($aReturned[1][$n]),

FabianBeiner commented 1 year ago

Added to 6.2.0. Thanks!