English > Support
New FilmAffinity Script
afrocuban:
At least recently, FilmAffinity script parses Movie title custom field "title1" together with movietype when the title is not movie, but series, documentary or so. For example, for https://www.filmaffinity.com/en/film348275.html for the result after <h1> we were getting
--- Quote ---Orson Welles: The One-Man Band documentary
--- End quote ---
Instead
--- Quote ---Orson Welles: The One-Man Band
--- End quote ---
only.
So, using AI, I corrected this, because I confirmed that in such cases there are exactly 16 spaces between the title and movie type. So I changed this in the script. Instead of this
--- Code: ---
//Get ~title~
curPos:=1
ItemValue:=TextBetWeen(HTML,'<h1 id="main-title">','</h1>',false,curPos); //Strings which opens/closes the data. WEB_SPECIFIC
AddCustomFieldValueByName('title1',ItemValue);
LogMessage(' Get result title:'+ItemValue+'||');
--- End code ---
I changed with this ( I choose to use >8 spaces just in case)
--- Code: ---
// Get ~title~
curPos := 1;
// Extract the section within <h1 id="main-title"> and </h1>
ItemValue := TextBetWeen(HTML, '<h1 id="main-title">', '</h1>', false, curPos);
LogMessage('Intermediate result after <h1>: ' + ItemValue + '||');
// Check and clean up any trailing content with 8 or more spaces
curPos := Pos(' ', ItemValue); // 8 spaces here between single quotes
if curPos > 0 then
begin
// Move the cursor to cover any additional spaces
// This loop handles any number of trailing spaces greater than or equal to 8
while (curPos <= Length(ItemValue)) and (ItemValue[curPos] = ' ') do // 8 spaces here between single quotes
begin
curPos := curPos + 1;
end;
// Extract the title up to the first non-space character after the spaces
ItemValue := Copy(ItemValue, 1, curPos - 1);
LogMessage('Cleaned title result: ' + ItemValue + '||');
end
else
begin
LogMessage('No extra trailing content found.');
end;
// Trim any leading or trailing whitespace
ItemValue := Trim(ItemValue);
// Add the title to the custom field
AddCustomFieldValueByName('title1', ItemValue);
// Log the final cleaned title for verification
LogMessage('Get result title: ' + ItemValue + '||');
--- End code ---
It would be good Ivek to officially include it in FilmAffinity script if interested in, otherwise if someone is interested in, I can post my already customized script
Ivek23:
--- Quote from: afrocuban on November 22, 2024, 09:13:35 pm ---It would be good Ivek to officially include it in FilmAffinity script if interested in
--- End quote ---
No interested.
--- Quote from: afrocuban on November 22, 2024, 09:13:35 pm ---otherwise if someone is interested in, I can post my already customized script
--- End quote ---
You can post script.
afrocuban:
Thank you Ivek. Here is my script that corrects this.
afrocuban:
Does anyone have an idea why this script wouldn't populate data, although it parses them (poster)? And, why it wouldn't parse some data at all (Actors, desciption). As I can tell, web layout hasn't change...
--- Code: ---
(12/2/2024 11:05:05 PM) Get result title: Ghostlight||
(12/2/2024 11:05:05 PM) Get result poster:http://pics.filmaffinity.com/ghostlight-171637604-large.jpg||
(12/2/2024 11:05:05 PM) Get result rating/orating (CF~FilmAffinity_Rating~):7.0||
(12/2/2024 11:05:05 PM) Get result (~FilmAffinity_Votes~):122||
(12/2/2024 11:05:05 PM) Get result origtitle:Ghostlight||
(12/2/2024 11:05:05 PM) Get result year:2024||
(12/2/2024 11:05:05 PM) Get result Original Runtime:110||
(12/2/2024 11:05:05 PM) Get result Movie Features:Original Runtime: 110 min.<br>||
(12/2/2024 11:05:05 PM) Get results country:United States||
(12/2/2024 11:05:05 PM) Parse results List Directors:Alex Thompson, Kelly O'Sullivan||
(12/2/2024 11:05:05 PM) Get results Directors:Alex Thompson||
(12/2/2024 11:05:05 PM) Get results Directors:Kelly O'Sullivan||
(12/2/2024 11:05:05 PM) Parse results List Writers:Kelly O'Sullivan||
(12/2/2024 11:05:05 PM) Get results Writers:Kelly O'Sullivan||
(12/2/2024 11:05:05 PM) Parse results List Composers:Quinn Tsan||
(12/2/2024 11:05:05 PM) Get results Composers:Quinn Tsan||
(12/2/2024 11:05:05 PM) Parse results List Actors:||
(12/2/2024 11:05:05 PM) Get results studio:Little Engine, Runaway Train. Distributor: IFC Films, Sapan Studios||
(12/2/2024 11:05:05 PM) Parse results List Genre+Category:Drama. Comedy | Comedy-Drama. Stage Play||
(12/2/2024 11:05:05 PM) Parse results List Category: Comedy-Drama. Stage Play||
(12/2/2024 11:05:05 PM) Get results Category:Comedy-Drama,Stage Play||
(12/2/2024 11:05:05 PM) Parse results List Genre:Drama. Comedy ||
(12/2/2024 11:05:05 PM) Get results Genre:Drama,Comedy||
(12/2/2024 11:05:05 PM) Get result description:||
(12/2/2024 11:05:05 PM) Function ParsePage NORMAL END======================|
(12/2/2024 11:05:05 PM) Provider data info retreived Ok in 2024-12-02 23:05:05| (~Updated~)
(12/2/2024 11:05:05 PM) Function ParsePage smNormal END======================|
(12/2/2024 11:05:05 PM) GET: http://pics.filmaffinity.com/ghostlight-171637604-large.jpg
(12/2/2024 11:05:05 PM) Redirected to: https://pics.filmaffinity.com/ghostlight-171637604-large.jpg
--- End code ---
afrocuban:
Using AI, I've managed to parse actors now, but cannot populate them to PVD:
--- Code: ---
// Get ~Actors~
curPos := 1;
ItemList := TextBetWeen(HTML, '<dt>Cast</dt>', '</dd>', false, curPos);
LogMessage('Parsed results List Actors: ' + ItemList + '||');
// Extract actor names
while Pos('<li class="nb" itemprop="actor"', ItemList) > 0 do
begin
curPos := Pos('<li class="nb" itemprop="actor"', ItemList);
ItemSubList := TextBetWeen(ItemList, '<div class="name" itemprop="name">', '<>', false, curPos);
ItemValue := Trim(ItemSubList);
// Adding actor to database
LogMessage('Adding Actor: ' + ItemValue);
AddMoviePerson(ItemValue, '', '', '', ctActors);
LogMessage('Added Actor: ' + ItemValue);
// Move to the next actor
ItemList := Copy(ItemList, curPos + Length('<li class="nb" itemprop="actor"'), Length(ItemList));
end;
--- End code ---
--- Quote ---(12/2/2024 11:27:23 PM) Parsed results List Actors: Keith Kupferer Dolly De Leon Katherine Mallen Kupferer Tara Mallen Hanna Dworkin Tommy Rivera-Vega Alma Washington H.B. Ward Dexter Zollicoffer Deanna Dunagan Francis Guinan David Bianco Matthew C. Yee See all credits||
--- End quote ---
Scriptnig procedure:
--- Quote ---
procedure AddMoviePerson(Name, TransName, Role, URL : String; const AType : Byte);
Adds movie credits (actor, director, etc.).
Parameters:
Name name of the person
TransName translated name of the person
Role role of the person (if applicable)
URL web address of the person (if available)
AType credits type
Possible values for AType variable:
0 actor
1 director
2 writer
3 composer
4 producer
--- End quote ---
is followed, so I have no idea for now what it could be?
Navigation
[0] Message Index
[#] Next page
Go to full version