Author Topic: Script: TheMovieDB People [ES] (Easy API Script)  (Read 19686 times)

0 Members and 1 Guest are viewing this topic.

Offline VVV_Easy_Programing

  • Older Power User
  • *****
  • Posts: 199
    • View Profile
Script: TheMovieDB People [ES] (Easy API Script)
« on: January 15, 2017, 07:35:25 pm »
Hello,
it's really difficult to find scripts for retrieve information for people.
Well, I make a little one which get the basic info (photo included) in Spanish (but easy to adapt for English or French, see down) from TheMovieDB.
It has an important feature: Store the URL of the person photo in ~transname~ for send to KODI in a Template (see in the forum)..

---------------------------------------------
SCRIPT:     TheMovieDB_[ES]_People
API URL:    http://docs.themoviedb.apiary.io/
CO-AUTHORS: VVV
Contact Web: http://contactbyweb.com/vvv-easy
---------------------------------------------
CHANGE LOG (15/01/2017):
            v 0.1.0.0   VVV: initial release
---------------------------------------------
FIELD USE:
  This is a script designed to be easy to understand and to adapt. For this reason may be missing some fields and
  the programming may not be smart. It's a only "One Pass" Script and get data in API SEQUENTIAL ORDER.
  The Personal Video DataBase field names in comments are enclosed in "~" so they are easier to find in the script.
  The WEB_SPECIFIC commentary points out the specific text for Web fields.
  Use Log PVdB debug Window for looking search errors.
  (Due a PVdB "GET" scripts funtions seems doesn't work with 'https' URL de v.0.2.0.0 works with API web dialog.
   See 'TheMovieDB_[ES]' script for no API (take information direct from web page) scraper.)
  If desired (PHOTO_URL_IN_TRANSNAME=True), it use the Field ~transname~ for storing the URL to the person photo, for send to KODI in a Template.   
KNOWN ISSUES:
  1. For compiling cuestions functions must be defined in the script before use (not in order of execution).
  2. For the search texts for locating the fields in Web page Null '' value it's not valid. You must replaces all
     escaped HTML characters (like &lt;&gt;&amp;&quot;) with normal characters (like <, >,$, ").
  3. It's a only "One Pass" Script: It DOES NOT makes several calls to the main program to scrape information from various pages of
     the movie in the same site. It only do that for searching mode in a movie list results.
  4. It has a Rondabout in BASE_URL (BASE_URL_TRUE,BASE_URL_RONDABOUT) for "cheat" GET PVdB funtion and rondabout the "https" fail.
  5. Get the ~orating~ (Popularity). It's not documented in PVB Scripting Manual and in the script don't work even working in the skin.
  5. In People database, PVdB don't download automaticaly the photo like in Movie database but using ListSearch it do.
     Set PHOTO_DWN_RONDABOUT  = True to activate the the ImageListSearch as RONDABOUT for download Photos. Because there is not choice (because its
     only one photo) normaly it download without asking but if PVdB begin to ask then with PVdB preference/Plugin/Silent Enable would be
     more confortable for large databases.
---------------------------------------------
//User Options
  BYPASS_SILENT        = False; //Set to True to ensure ShowMessage alerts (then bypass Silent PVdB preferences)
  PHOTO_DWN_RONDABOUT  = True;  (*Set to True to activate the the ImageListSearch as RONDABOUT for download Photos.
                                  Because there is not choice (because its only one photo) normaly it download without asking but if PVdB begin to ask then
                                  with PVdB preference/Plugin/Silent Enable would be more confortable for large databases.*)
  PHOTO_URL_IN_TRANSNAME = True; //Set to False to disable to avoid use the Field ~transname~ for storing the URL to the person photo, for send to KODI in a Template.

  LANG_API_STR         = '&language=es';                                  //WEB_SPECIFIC
  //LANG_API_STR       = '&language=en';                                  //WEB_SPECIFIC
  //LANG_API_STR       = '&language=fr';                                  //WEB_SPECIFIC

(Edito: New version down)
« Last Edit: July 28, 2017, 03:41:08 pm by VVV_Easy_Programing »

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2746
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #1 on: January 21, 2017, 09:38:10 am »
Thanks, encouragingly, script tested in the near future, when I will find time for it.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2746
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #2 on: July 16, 2017, 04:22:34 pm »
Thanks, encouragingly, script tested in the near future, when I will find time for it.

I managed to do some tests and add corrections to the TheMovieDB_People_ [ES] test script, which is also the author of the script for testing. These fixes can be added to the original TheMovieDB_People_ [ES] script.

TheMovieDB_People_ [ES] test script is attached.



Also included is the TheMovieDB_People_ [ES] test 1 7z file, which contains 4 test scripts with different code snippets when searching for results. These scripts are helpful when TheMovieDB_People_ [ES] test script does not find the correct search results in search results for certain persons. I hope that the author of the script also finds the right solution for this with the help of these scripts.

TheMovieDB_People_ [ES] test 1 7z file is attached.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2746
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #3 on: July 21, 2017, 08:39:36 pm »
The script incorrectly transfers the url address
Quote
http://www.themoviedb.org/person/nm0572132
and therefore does not transfer almost any information.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2746
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #4 on: July 23, 2017, 05:58:40 am »
The script incorrectly transfers the url address
Quote
http://www.themoviedb.org/person/nm0572132
and therefore does not transfer almost any information.

Changes in source code on API pages for Peoples. 
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline VVV_Easy_Programing

  • Older Power User
  • *****
  • Posts: 199
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #5 on: July 25, 2017, 08:35:42 am »
Thank you, Ivek23 for the alert.
I take the subject and I'll try to solve early ;D

Offline VVV_Easy_Programing

  • Older Power User
  • *****
  • Posts: 199
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #6 on: July 28, 2017, 03:42:08 pm »
CHANGE LOG (27/07/2017):
            v 0.2.0.0   VVV: Search improvements for API order independence.

Attached the new versión.

(Edito: New version down)
« Last Edit: September 27, 2017, 08:49:01 pm by VVV_Easy_Programing »

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2746
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #7 on: August 08, 2017, 05:18:11 pm »
CHANGE LOG (27/07/2017):
            v 0.2.0.0   VVV: Search improvements for API order independence.

It works, but there is still an error in finding results when there are multiple hits for one person. This is the case, for example, for a person (John Wayne), who does not show the first hit with John Wayne.
The error is in the part of the code:
PersonId is the original version under PhotoURL - it's not correct
PersonId is the original version of PhotoURL - correctly

At the same time, the correction of the first line of code in Get the first item '' curPos: = PosFrom ('{' popularity ':', HTML, curPos) ''


Original  part of the code:
Code: [Select]
          //Get first item
          curPos:=PosFrom('{',HTML,curPos)                       //String which opens the Web Result List data. WEB_SPECIFIC
          while curPos>0 do begin
            NumbResult:=NumbResult+1;         
            LogMessage('Parsing search Persons |'+IntToStr(NumbResult)+'| results in '+IntToStr(curPos)+' ...');
            //Get information
            PhotoURL:='';                                 
            PersonId:='';
            PersonURL:='';
            Name:='';
            ItemValue:=TextBetWeen(HTML,'"profile_path":',',',false,curPos);    //WEB_SPECIFIC
            if ((0=Pos('null',ItemValue)) and (2<Length(ItemValue))) then begin      //WEB_SPECIFIC
               ItemValue:=StringReplace(ItemValue,'\','',True,True,False);      //Eliminate '\'
               ItemValue:=StringReplace(ItemValue,'"','',True,True,False);      //Eliminate '"'
               PhotoURL:='http://image.tmdb.org/t/p/w92'+ItemValue;             //WEB_SPECIFIC. w45,w92,w185,w300,w342,original.
               LogMessage('      Parse Results PreviewURL:'+PhotoURL+'||');
            end;
            PersonId:=TextBetWeen(HTML,'"id":',',',false,curPos);              //WEB_SPECIFIC
            PersonURL:=BASE_API_URL_PREFIX+PersonId+BASE_API_URL_SUFIX+LANG_API_STR;
            LogMessage('      Parse Results MovieURL:'+PersonURL+'||');
            ItemValue:=TextBetWeen(HTML,'"name":',',',false,curPos);                 //WEB_SPECIFIC
            if ((0=Pos('null',ItemValue)) and (2<Length(ItemValue))) then begin      //WEB_SPECIFIC
               Name:=StringReplace(ItemValue,'"','',True,True,False);      //Eliminate ""
               LogMessage('      Parse Results Name:'+Name+'||');
            end;
            AddSearchResult(Name,'','',PersonURL,PhotoURL); 
            //Just to check the website (Only to check the web page) not PVdB valid result.
            AddSearchResult('  Just to check the website (not PVdB valid) '+#8729+'  '+Name,'','',BASE_URL_TRUE+PersonId,'');
            curPos:=PosFrom('{',HTML,curPos)                                     //WEB_SPECIFIC
          end;

Corrected part of the code:
Code: [Select]
          //Get first item
          curPos:=PosFrom('{"popularity":',HTML,curPos)                       //String which opens the Web Result List data. WEB_SPECIFIC
          while curPos>0 do begin
            NumbResult:=NumbResult+1;         
            LogMessage('Parsing search Persons |'+IntToStr(NumbResult)+'| results in '+IntToStr(curPos)+' ...');
            //Get information                               
            PersonId:='';
            PersonURL:='';
            PhotoURL:='';
            Name:='';
            PersonId:=TextBetWeen(HTML,'"id":',',',false,curPos);              //WEB_SPECIFIC
            PersonURL:=BASE_API_URL_PREFIX+PersonId+BASE_API_URL_SUFIX+LANG_API_STR;
            LogMessage('      Parse Results MovieURL:'+PersonURL+'||');
            ItemValue:=TextBetWeen(HTML,'"profile_path":',',',false,curPos);    //WEB_SPECIFIC
            if ((0=Pos('null',ItemValue)) and (2<Length(ItemValue))) then begin      //WEB_SPECIFIC
               ItemValue:=StringReplace(ItemValue,'\','',True,True,False);      //Eliminate '\'
               ItemValue:=StringReplace(ItemValue,'"','',True,True,False);      //Eliminate '"'
               PhotoURL:='http://image.tmdb.org/t/p/w92'+ItemValue;             //WEB_SPECIFIC. w45,w92,w185,w300,w342,original.
               LogMessage('      Parse Results PreviewURL:'+PhotoURL+'||');
            end;
            //PersonId:=TextBetWeen(HTML,'"id":',',',false,curPos);              //WEB_SPECIFIC
            //PersonURL:=BASE_API_URL_PREFIX+PersonId+BASE_API_URL_SUFIX+LANG_API_STR;
            //LogMessage('      Parse Results MovieURL:'+PersonURL+'||');
            ItemValue:=TextBetWeen(HTML,'"name":',',',false,curPos);                 //WEB_SPECIFIC
            if ((0=Pos('null',ItemValue)) and (2<Length(ItemValue))) then begin      //WEB_SPECIFIC
               Name:=StringReplace(ItemValue,'"','',True,True,False);      //Eliminate ""
               LogMessage('      Parse Results Name:'+Name+'||');
            end;
            AddSearchResult(Name,'','',PersonURL,PhotoURL); 
            //Just to check the website (Only to check the web page) not PVdB valid result.
            AddSearchResult('  Just to check the website (not PVdB valid) '+#8729+'  '+Name,PersonId,'',BASE_URL_TRUE+PersonId,'');
            curPos:=PosFrom('{"popularity":',HTML,curPos)                                     //WEB_SPECIFIC
          end;

Corrected part of the code now also finds the first hit, and at the same time locates (displays) all the hits for the person in the search for results.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline VVV_Easy_Programing

  • Older Power User
  • *****
  • Posts: 199
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #8 on: August 17, 2017, 03:46:56 pm »
Thank you very much Ivek for your work.
I don't especially pride of the search subroutine.
Because I planned change all the subroutine and the bug is easily "roundabout-ed" I wait to change de subroutine to correct it.
Stay tuned.

Offline VVV_Easy_Programing

  • Older Power User
  • *****
  • Posts: 199
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #9 on: September 27, 2017, 08:52:40 pm »
CHANGELOG (23/09/2017):
            V 1.0.0.0   VVV: Completely redone.
                            Ivek32: Biography text format improvements (Wikipedia, IMDb, etc)

Attached the new versión.
« Last Edit: June 16, 2018, 10:15:32 am by VVV_Easy_Programing »

Offline VVV_Easy_Programing

  • Older Power User
  • *****
  • Posts: 199
    • View Profile
Re: Script: TheMovieDB People [ES] (Easy API Script)
« Reply #10 on: June 16, 2018, 10:15:41 am »
Happily, we have finished the "Beta" phase in the PVD MOD and move on to "Release" state.
So, we closed this topic now and we continue in the new topic:

Personal Video Database 1.0.2.7 MOD
http://www.videodb.info/forum_en/index.php/topic,4134.0.html

See you all there.  ;D