Personal Video Database
English => Development => Scripts and Templates => Topic started by: VVV_Easy_Programing 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 <>&") 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)
-
Thanks, encouragingly, script tested in the near future, when I will find time for it.
-
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.
-
The script incorrectly transfers the url address
http://www.themoviedb.org/person/nm0572132
and therefore does not transfer almost any information.
-
The script incorrectly transfers the url address http://www.themoviedb.org/person/nm0572132
and therefore does not transfer almost any information.
Changes in source code on API pages for Peoples.
-
Thank you, Ivek23 for the alert.
I take the subject and I'll try to solve early ;D
-
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)
-
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:
//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:
//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.
-
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.
-
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.
-
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 (http://www.videodb.info/forum_en/index.php/topic,4134.0.html)
See you all there. ;D