Function ParsePage_IMDBPeopleBIO(CombinedHTML:String; ShouldParseBio, ShouldParseCareer: Boolean):Cardinal; //BlockOpen
//Returns:
// Result:=prFinished; Script has finished gathering data
// Result:=prError; If any big problem with exit;
//Retrieve: ~bio~ Biography from "Mini Bio" IMDB section
Var
curPos,endPos,debug_pos1:Integer;
ItemValue:String;
PersonID,ItemValue0,ItemValue10,ItemValue1,ItemValue11:String;
ItemList,ItemList00,ItemList0,ItemList1,ItemList11,ItemList12:String;
FinalValue: String;
ItemList2,ItemList10,ItemList20,ItemValue3:String;
BirthNameValue, BioList: String;
DeathAge, AltNames1, ItemListBase, ItemListBase1, ItemValueBase, ItemValueBase0, ItemValueBase1:String;
IsBioFieldInitiallyEmpty: Boolean;
BioFieldEmptyStr: String;
Begin
LogMessage('ParsePage_IMDBPeopleBIO: Starting processing.');
LogMessage('CombinedHTML length: ' + IntToStr(Length(CombinedHTML)));
LogMessage('Function ParsePage_IMDBPeopleBIO BEGIN=====================||');
Result:=prFinished; //It will change to prError if any big problem with exit;
//LogMessage('Result set to prFinished'); //Log the initial result setting
Result := prFinished;
// Check if the 'bio' field is empty
IsBioFieldInitiallyEmpty := Length(GetFieldValueXML('bio')) = 0;
(*
// Convert the Boolean result to a string for logging
If IsBioFieldInitiallyEmpty Then
BioFieldEmptyStr := 'True'
Else
BioFieldEmptyStr := 'False';
LogMessage('IsBioFieldEmpty: ' + BioFieldEmptyStr);
//*)
//First to get data from Base page by parsing FileNameMain
If ShouldParseCareer Then Begin
//~jobTitle~ (Profession)
//Begin of scrap the json container.
ItemListBase1:=TextBetWeenFirst(CombinedHTML,'');
//LogMessage(' Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList: '+'', CombinedHTML);
LogMessage('curPos after finding Alternative Names curPos: ' + IntToStr(curPos));
If curPos > 0 Then Begin
EndPos := curPos;
//LogMessage('EndPos set to curPos: ' + IntToStr(EndPos));
// Extract values between the specified tags
AltNames1 := HTMLValues(CombinedHTML, '', '"feature_contribution_header":"Contribute to this page"', '{"node":{"displayableProperty":{"value":{"plainText":"', '","__typename":"Markdown"},"__typename":"DisplayableNameAkaProperty"},"__typename":"NameAka"},"', ', ', EndPos);
//LogMessage(' * Parsed Result Alternative Name: ' + AltNames1);
//AltNames1:=HTMLValues(CombinedHTML,'Alternate Names:','','','','
',EndPos);
//AltNames1:=StringReplace(ItemValue1,' | ','
',True,False,True);
//AltNames1:=StringReplace(AltNames1,' | ',#13,True,False,True);
AltNames1:=StringReplace(AltNames1,'\u0026',#38,True,False,True);
If AltNames1 <> '' then AddFieldValueXML('altnames', AltNames1);
//*)
If AltNames1 <> '' then
LogMessage(' Parsed Results All Expanded Alternative Names: ' + AltNames1 + '||');
(*// When Alternative Names wanted in the "comment" field
If AltNames1 <> '' then
ItemListBase:=ItemListBase+#13#10+'Alternative Names: '+AltNames1 Else ItemList:=ItemListBase+#13#10;
LogMessage(' Comment List After alternative Names:'+ItemListBase+'||');
//*)
End;
//(*
//~Height~
curPos:=Pos('