Thanks for a feedback, Ivek.
I understood your points, and this is what I did
//Get to "Cast" ~actors~ ctActors
//Go Cast list
curPos:=Pos('<h3 class="ipc-title__text">Top cast',HTML); //Strings start which opens the block content data. WEB_SPECIFIC
curPos:=curPos+Length('<div class="ipc-avatar ipc-avatar--base ipc-avatar--dynamic-width" role="group">'); //Strings end which opens the block content data. WEB_SPECIFIC
//Get all "raw" crew summary (in raw because we need the hidden person links) May one person or severals in the ~crew~
endPos:=PosFrom('</li></ul><><><><>',HTML,curPos); //Strings which opens/closes the data. WEB_SPECIFIC
ItemList:=Copy(HTML,curPos,endPos-curPos);
//LogMessage(' Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
curPos:=Pos('" class="ipc-image" loading="',ItemList) //String which opens the subList data. WEB_SPECIFIC
index:=1;
ItemValue1:=''; // Initialize the custom IMDb Cast field
While curPos>0 Do Begin
If (index>PEOPLE_LIMITS) Then break; //Limited depassed.
//Get PersonURL (Always must it has)
ItemValue:=TextBetWeen(ItemList,'<a data-testid="title-cast-item__actor" href="/name/','?ref_=tt_cl_t_',false,curPos);
PersonURL:=BASE_URL_PERSON_PRE + ItemValue + BASE_URL_SUF; //Strings which opens/closes the data. WEB_SPECIFIC
LogMessage(' Parse Results PersonURL:'+PersonURL+'||');
//Get Name (Always must it has)
//Name:=TextBetWeen(ItemList,'?ref_=tt_cl_t_'+IntToStr(index)+'" class="StyledComponents__ActorName-y9ygcu-1 eyqFnv"','</a><div class="title-cast-item__characters-list">',false,curPos);
Name:=TextBetWeen(ItemList,'">','</a><div class="title-cast-item__characters-list">',false,curPos); //Strings which opens/closes the data. WEB_SPECIFIC
//Name:=Trim(StringReplace(Name,'>','',True,False,True));
LogMessage(' Parse Results Name:'+Name+'||');
//Get Role YES: PVD save Role in cast (actors) people (Not always has link)
Role:=TextBetWeen(ItemList,' title-cast-item__char" data-testid="cast-item-characters-link">','</span><span data-testid="cast-item-characters-with-as" class="',false,curPos); //Strings which opens/closes the data. WEB_SPECIFIC
//Role:=Trim(StringReplace(Role,'>','',True,False,True));
///Role:=StringReplace(Role,Chr(13),'',True,False,True);
///Role:=StringReplace(Role,' ','',True,False,True);
LogMessage(' Parse Results Role:'+Role+'||');
If Pos('http://www.imdb.com/name//' ,PersonURL) < 1 then
AddMoviePerson(Name,'',Role,PersonURL,ctActors);
LogMessage(' Get results cast:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||ctActors');
// Custom field: IMDb Cast (names only, separated by " • ")
If ItemValue1='' Then
ItemValue1:=Name
Else
ItemValue1:=ItemValue1+' • '+Name;
//curPos:=PosFrom('" class="ipc-image" loading="',ItemList,curPos); //String which opens the Web Result item List data. WEB_SPECIFIC
index:=index+1;
End;
//LogMessage(#13+'');
End;
//*)
//(*
LogMessage(#13+'');
//*)
// Add custom field IMDb Cast
AddCustomFieldValueByName('IMDb Cast', ItemValue1);
// Log the IMDb Cast field for verification
LogMessage('IMDb Cast: '+ItemValue1);
//Get "plot_summary" as ~comment~ //debug_pos1-1
Mysteriously and hilariously, instead of importing Cast, it imports Tv2 value into IMDb Cast field! It's some problem with ItemValue1 value that I'm trying to define, but I am not able to grasp what I'm doing wrong, so it pulls ItemValue1 from the first previous segment where it's used, and that is exactly Tv2 field in the script.
If you're willing to review and suggest snippet change, it would be appreciated as always.
P.S. Forum won't accept in the code section / div, but it's there in
<><><><>
so it's actually < / div >< / div >< / div >< / div >, without space inside, of course.