English > Scripts and Templates
Script: TheMovieDB People [ES] (Easy API Script)
VVV_Easy_Programing:
Thank you, Ivek23 for the alert.
I take the subject and I'll try to solve early ;D
VVV_Easy_Programing:
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)
Ivek23:
--- Quote from: VVV_Easy_Programing 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.
--- End quote ---
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: --- //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;
--- End code ---
Corrected part of the code:
--- 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;
--- End code ---
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.
VVV_Easy_Programing:
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.
VVV_Easy_Programing:
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.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version