tboothman / imdbphp

PHP library for retrieving film and tv information from IMDb
252 stars 85 forks source link

For some persons has redirection to other page #182

Closed Thomasdouscha closed 2 years ago

Thomasdouscha commented 4 years ago

for example: when enter this url : https://www.imdb.com/name/nm8484559/ redirect to: https://www.imdb.com/name/nm2092886/

For this reason is there any function for getting real_id?

jreklund commented 4 years ago

The function you are looking for got the name real_id().

Thomasdouscha commented 4 years ago

I found it in source files. But as i understood this is for ttxxxxxxx of movie page. I need that similar function for nmxxxxxxx of person page. Or is there any way as alternative?

jreklund commented 4 years ago

Sorry about that, I read it wrong. There aren't one for persons.

Just checked on how it works. You specify that you want nm8484559, and after the redirect (imdbphp handles it automatically). You need to check real_id() and see if it matches the one you wanted. And that way you know if it have been changed. There are no way of getting the previous id.

The same data are available on nm pages. <meta property="pageId" content="nm2092886" />

Thomasdouscha commented 4 years ago

Do you suggest me that i will check the code of real_id() of title cards and I use this way and code real_id() of person cards? interesting :) Ok i ll try it. But in my opinion imdbphp should have real_id() of person pages. Am i wrong? I wanna notice that i used your imdbphp on my website. It is really very useful. Thanks for that. And secondly you have swedish name surname, maybe it is nickname. I dont know. I was born in sweden and after 5 years old my family moved to Turkey / istanbul. My Mother is swedish from goteborg. Thatswhy name & surname was interesting. Thanks for replies and suggestion.

Thomasdouscha commented 4 years ago

In Class Person of Person.php i added codes: public function real_id() { $page = $this->getPage('Name'); if (preg_match('#<meta property="pageId" content="nm(\d+)"#', $page, $matches) && !empty($matches[1])) { return $matches[1]; } } Result is in my database for example which i wrote in my first message: image

As you see imdb_id is not equal to real_id so it works perfectly. I suggest that this code should be added in person.php

Thomasdouscha commented 4 years ago

And my suggestion?

tboothman commented 4 years ago

Make a PR for it: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork or https://www.youtube.com/embed/dSl_qnWO104

Thomasdouscha commented 4 years ago

I don't know anything about github. I ll check the links.

Thomasdouscha commented 3 years ago
public function real_id()
    {
        $page = $this->getPage('Name');
        if (preg_match('#<meta property="pageId" content="nm(\d+)"#', $page, $matches) && !empty($matches[1])) {
        return $matches[1];
        }
    }

This code works. May be somebody can pull request it. I don't know how to do.