English > Support

New FilmAffinity Script

<< < (2/3) > >>

afrocuban:
This is the best I could achieve to get back actors to the field:




--- Code: ---   // Get ~Actors~ (Only name in Web from !file! list)
    curPos := 1;
    ItemList := TextBetWeen(HTML, '<dt>Cast</dt>', '</dd>', false, curPos); // Strings which opens/closes the data. WEB_SPECIFIC
    LogMessage('Parsed results List Actors: ' + ItemList + '||');


    // Remove " See all credits" if it exists
    curPos := Pos(' See all credits', ItemList);
    if curPos > 0 then
        ItemList := Copy(ItemList, 1, curPos - 1);
    LogMessage('Cleaned ItemList: ' + ItemList);


    // Forward the plain text to the field
    AddMoviePerson(ItemList, '', '', '', 0); // Use 0 for actors
    LogMessage('Added All Actors: ' + ItemList);
--- End code ---


The problem is because function TextBetween removes all tags from the resulting substring, and since the actors are separated by spaces only on FA when parsed, it's impossible to distinguish between individual names by space only as delimiter, thus impossible to generate comma separated list.

Ivek23:

--- Quote from: afrocuban on December 03, 2024, 03:29:30 am ---This is the best I could achieve to get back actors to the field:
.
.
.
The problem is because function TextBetween removes all tags from the resulting substring, and since the actors are separated by spaces only on FA when parsed, it's impossible to distinguish between individual names by space only as delimiter, thus impossible to generate comma separated list.
--- End quote ---


--- Quote ---     //Get ~Actors~ (Only name in Web from !file! list)(Separated with ',' and with spaces).
   curPos:=Pos('<dt>Cast</dt>',HTML);
   //curPos:=curPos+Length('<dt>Cast</dt>');                                                    //Strings end which opens the block content data.  WEB_SPECIFIC
   curPos:=PosFrom('<div class="cast-wrapper">',HTML,curPos);                                                    //Strings end which opens the block content data.  WEB_SPECIFIC   
   curPos:=curPos+Length('<div class="cast-wrapper">');                                                    //Strings end which opens the block content data.  WEB_SPECIFIC
   endPos:=PosFrom('</dd>',HTML,curPos);                                            //Strings which opens/closes the data. WEB_SPECIFIC
    //ItemList:=TextBetWeenFirst(HTML,'<div class="cast-wrapper"','</dd>');    //Strings which opens/closes the data. WEB_SPECIFIC
   ItemList:=Copy(HTML,curPos,endPos-curPos);
    LogMessage('           Parse results List Actors:'+ItemList+'||');
   ItemList:=StringReplace(ItemList,'</a>','|',True,True,False);                      //WEB_SPECIFIC   
   ItemList:=StringReplace(ItemList,'See all credits','',True,True,False);                      //WEB_SPECIFIC      
   ItemList:=RemoveTags(ItemList, False);
/LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
    ExplodeString(ItemList,ItemArray, '|');
    for index := Low(ItemArray) to High(ItemArray) do begin
        ItemValue:=Trim(ItemArray[index]);
        AddMoviePerson(ItemValue,'','','',ctActors);
        LogMessage('      Get results Actors:'+ItemValue+'||');
    end;   
--- End quote ---

Try this code, it transferred the actors to the Actors field for me

afrocuban:

--- Quote from: Ivek23 on December 03, 2024, 10:40:49 am ---
--- Quote from: afrocuban on December 03, 2024, 03:29:30 am ---This is the best I could achieve to get back actors to the field:
.
.
.
The problem is because function TextBetween removes all tags from the resulting substring, and since the actors are separated by spaces only on FA when parsed, it's impossible to distinguish between individual names by space only as delimiter, thus impossible to generate comma separated list.
--- End quote ---


--- Quote ---     //Get ~Actors~ (Only name in Web from !file! list)(Separated with ',' and with spaces).
   curPos:=Pos('<dt>Cast</dt>',HTML);
   //curPos:=curPos+Length('<dt>Cast</dt>');                                                    //Strings end which opens the block content data.  WEB_SPECIFIC
   curPos:=PosFrom('<div class="cast-wrapper">',HTML,curPos);                                                    //Strings end which opens the block content data.  WEB_SPECIFIC   
   curPos:=curPos+Length('<div class="cast-wrapper">');                                                    //Strings end which opens the block content data.  WEB_SPECIFIC
   endPos:=PosFrom('</dd>',HTML,curPos);                                            //Strings which opens/closes the data. WEB_SPECIFIC
    //ItemList:=TextBetWeenFirst(HTML,'<div class="cast-wrapper"','</dd>');    //Strings which opens/closes the data. WEB_SPECIFIC
   ItemList:=Copy(HTML,curPos,endPos-curPos);
    LogMessage('           Parse results List Actors:'+ItemList+'||');
   ItemList:=StringReplace(ItemList,'</a>','|',True,True,False);                      //WEB_SPECIFIC   
   ItemList:=StringReplace(ItemList,'See all credits','',True,True,False);                      //WEB_SPECIFIC     
   ItemList:=RemoveTags(ItemList, False);
/LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
    ExplodeString(ItemList,ItemArray, '|');
    for index := Low(ItemArray) to High(ItemArray) do begin
        ItemValue:=Trim(ItemArray[index]);
        AddMoviePerson(ItemValue,'','','',ctActors);
        LogMessage('      Get results Actors:'+ItemValue+'||');
    end;   
--- End quote ---

Try this code, it transferred the actors to the Actors field for me

--- End quote ---


Wow, thanks! I t works like a charm! Two small things: endPos has to be declared as additional String variable in this function, and there's missing "/" in

--- Quote ---/LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
--- End quote ---


so it should be commented out.

Ivek23:
Either like this


--- Quote ---//LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
--- End quote ---

or like this


--- Quote ---LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
--- End quote ---

It's up to you what you take, according to your wishes.

afrocuban:
You are right!


For my personal purposes I have slightly modified your snippet to:


--- Code: ---AddMoviePerson(ItemValue,'','No Role On FilmAffinity','',ctActors);
--- End code ---


in order to get each actor to a new line (maintaining the feel and look of IMDb parsing), while indicating roles aren't stated on FA. Next I'll try to implement PersonURL for FA, but not planning to create FA script for people, not in the near future.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version