141
Talk / Re: AI and PVD
« on: November 23, 2024, 10:42:11 pm »
Second one
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
You mentioned somewhere on the forum that you could change and fix scripts with the help of AI.
Is it possible to get some AI tool to help edit PVD scripts?
What do you use and could you share it with other PVD users?
I would also start using AI to help edit PVD scripts if I got the right information on how to use it.
All models are anonymously provided by DuckDuckGo
GPT-4o mini
General purpose AI with high built-in moderation
Created by OpenAI
Claude 3 Haiku
General purpose AI with high built-in moderation
Created by Anthropic
Llama 3.1 70B
Open Source
General purpose AI with medium built-in moderation
Created by Meta
Mixtral 8x7B
Open Source
General purpose AI with low built-in moderation
Created by Mistral AI
Please note: starting a new chat with any model will delete your current chat session
Yes, knowing that PVD cannot handle HTTPS and relies on the AHK script for downloading pages, we need to take extra caution when creating part2 of wscr3. Here are some key considerations:
1. Ensure Secure Handling of HTTPS:
Consistent Use of AHK: Ensure that all HTTPS requests are handled through the AHK script to maintain consistency and avoid errors.
Error Handling: Implement robust error handling to manage any potential issues with HTTPS downloads.
2. Avoid Direct HTTPS Calls in Part2:
No Direct HTTP Requests: Ensure that part2 does not attempt any direct HTTP requests, which PVD cannot process.
3. Manage Variable Dependencies:
Separate Variables: Use distinct variables for URLs and file paths in part2 to avoid conflicts with part1.
Consistent Paths: Ensure all paths are correctly set and accessible to both the AHK script and the main processing script.
4. Logging and Debugging:
Detailed Logs: Maintain detailed logs to trace each step and catch any issues early.
Sequential Logging: Ensure that the logs differentiate between the actions of part1 and part2 clearly.
5. Complete Initial Processing Before Starting Part2:
Clear Markers: Use clear markers to indicate the end of part1 and the beginning of part2.
Confirmation of Completion: Ensure part1 completes all tasks before initiating part2.
Example Pseudo-code for Part2:
pascal
// Ensure part1 completion
LogMessage('Function ParsePage smNormal END======================|');
Exit; // End of initial processing
// Part 2: Start new process for multiple posters
LogMessage('Starting process to download multiple posters');
// Define new URL and file path
NewURL := 'https://www.imdb.com/title/tt3461252/mediaindex';
NewDownloadFile := 'Tmp/multipage-UTF8_NO_BOM.htm';
// Download the new page using AHK script
FileExecute(ScriptPath+'PVdBDownPage.exe', '"'+NewURL+'" "'+ScriptPath+NewDownloadFile+'"');
// Wait for the new download to finish
While Not(FileExists(ScriptPath+NewDownloadFile)) Do Begin
wait (2000);
End;
// Process the new page for multiple posters
WebText := FileToString(ScriptPath+NewDownloadFile);
WebText := ConvertEncoding(WebText, 65001);
LogMessage('Downloaded multiple posters page');
// Extract and download multiple posters
// Add your logic here to extract poster links and download them
By taking these precautions and structuring the script carefully, we ensure that part2 integrates smoothly with part1 and reliably handles all the necessary HTTPS requests through the AHK script.
Key Implications:
Sequential Addition: Posters need to be added one by one, using the navigation buttons to move through the poster slots (e.g., pos1, pos2).
Automatic Overwrite: Adding a poster in pos1 will overwrite the existing one unless the user navigates to a new slot (pos2) before adding another poster.
Manual Actions Mimicked by Script: Since manual actions require navigation buttons to switch between slots, the script needs to mimic these actions to add multiple posters.
Approach for wscr3:
To import multiple posters programmatically while respecting the manual navigation process, follow these steps:
Extract Poster URLs:
Extract multiple poster URLs from the gallery page as discussed.
Sequential Addition with Navigation:
Use script logic to simulate the navigation and addition of each poster URL.
Ensure the script switches to the next poster slot (pos2, pos3, etc.) before adding each new poster.
Pseudo-code Example:
pascal
// Ensure part1 completion
LogMessage('Function ParsePage smNormal END======================|');
Exit; // End of initial processing
// Part 2: Start new process for multiple posters
LogMessage('Starting process to download multiple posters');
// New URL and file path
NewURL := 'https://www.imdb.com/title/tt3461252/mediaindex';
NewDownloadFile := 'Tmp/multipage-UTF8_NO_BOM.htm';
// Download the new page using AHK script
FileExecute(ScriptPath+'PVdBDownPage.exe', '"'+NewURL+'" "'+ScriptPath+NewDownloadFile+'"');
// Wait for the new download to finish
While Not(FileExists(ScriptPath+NewDownloadFile)) Do Begin
wait (2000);
End;
// Process the new page for multiple posters
WebText := FileToString(ScriptPath+NewDownloadFile);
WebText := ConvertEncoding(WebText, 65001);
LogMessage('Downloaded multiple posters page');
// Extract and store multiple poster URLs
PosterURLs := ExtractPosterURLs(WebText); // Pseudo-function to parse and get poster URLs
// Navigate and add each poster URL sequentially
For i := 0 to Length(PosterURLs) - 1 Do Begin
// Simulate clicking 'nextposterbtn' to navigate to the next poster slot
SimulateClickNextPosterButton(); // Pseudo-function for clicking the button
// Add the poster URL to the current slot
AddCustomFieldValueByName('posterURL'+IntToStr(i), PosterURLs[i]);
AddCustomFieldValueByName('poster'+IntToStr(i), PosterURLs[i]); // Adjust as needed
End;
// Update poster count
AddCustomFieldValueByName('postercount', IntToStr(Length(PosterURLs)));
Testing:
Run wscr3: Execute the script and verify that each poster is added to a new slot correctly.
Check Navigation: Ensure that the script correctly mimics navigation actions between poster slots.
Validation: Verify that all posters appear correctly in PVD without overwriting each other.
By following these steps, you can ensure that multiple posters are imported into PVD correctly while respecting its manual navigation and addition process.
Knowing all before your last message do you think you could Mimick manual actions with part2 to switch between slots, so part2 could be able to add multiple posters?
Steps to Mimic Manual Actions:
Simulate Clicking the Next Poster Button:
Use an AHK script to simulate the click on the nextposterbtn to switch to the next poster slot (e.g., from pos1 to pos2).
Add Poster URL:
Once the new slot is active, use the script to add the poster URL to that slot.
Detailed Plan:
Extract Poster URLs:
Extract the URLs from the IMDb gallery page.
Navigate and Add Posters:
For each extracted URL, navigate to the next poster slot and add the poster.
Example Pseudo-code for Part2:
Part 2: Adding Multiple Posters
pascal
// Ensure part1 completion
LogMessage('Function ParsePage smNormal END======================|');
Exit; // End of initial processing
// Part 2: Start new process for multiple posters
LogMessage('Starting process to download multiple posters');
// New URL and file path
NewURL := 'https://www.imdb.com/title/tt3461252/mediaindex';
NewDownloadFile := 'Tmp/multipage-UTF8_NO_BOM.htm';
// Download the new page using AHK script
FileExecute(ScriptPath+'PVdBDownPage.exe', '"'+NewURL+'" "'+ScriptPath+NewDownloadFile+'"');
// Wait for the new download to finish
While Not(FileExists(ScriptPath+NewDownloadFile)) Do Begin
wait (2000);
End;
// Process the new page for multiple posters
WebText := FileToString(ScriptPath+NewDownloadFile);
WebText := ConvertEncoding(WebText, 65001);
LogMessage('Downloaded multiple posters page');
// Extract and store multiple poster URLs
PosterURLs := ExtractPosterURLs(WebText); // Pseudo-function to parse and get poster URLs
// Function to simulate clicking the next poster button
procedure SimulateClickNextPosterButton();
begin
// Use AHK script to simulate the click
FileExecute('PathToAHKScript\click_next_poster_button.ahk', '');
end;
// Navigate and add each poster URL sequentially
For i := 0 to Length(PosterURLs) - 1 Do Begin
// Simulate clicking 'nextposterbtn' to navigate to the next poster slot
SimulateClickNextPosterButton();
// Add the poster URL to the current slot
AddCustomFieldValueByName('posterURL'+IntToStr(i), PosterURLs[i]);
AddCustomFieldValueByName('poster'+IntToStr(i), PosterURLs[i]); // Adjust as needed
End;
// Update poster count
AddCustomFieldValueByName('postercount', IntToStr(Length(PosterURLs)));
Steps for Creating AHK Script:
Create AHK Script:
Write an AHK script to simulate the click on the nextposterbtn.
ahk
; AHK script to simulate clicking the next poster button
ControlClick, nextposterbtn, ahk_class PVDWindowClass
return
Integrate AHK with Delphi/Pascal Script:
Ensure the Delphi/Pascal script calls the AHK script correctly to simulate the button click.
By following these steps and ensuring the AHK script correctly simulates the navigation actions, you can effectively add multiple posters to PVD as if done manually. This approach should work smoothly given the outlined process.
Orson Welles: The One-Man Band documentary
Orson Welles: The One-Man Band
//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+'||');
// 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 + '||');
Hi afrocuban,
PVD can handle multiple images for the same type (poster, disk cover, etc..) but from scripts I have never been able to upload more than 1 per type.
type
TPosterInfo = record
ImageURL: string;
Caption: string;
Height: Integer; // Included height in the record for clarity
end;
Function ParsePage_IMDBMovieBASE(HTML: String): Cardinal; //BlockOpen
//Returns:
// Result:=prFinished; Script has finished gathering data
// Result:=prError; If ¿any big problem? with exit;
// Retrieve: ~title~, ~year~, ~origtitle~, ~poster~ / ~imdbrating~, ~IMDB_Votes~ (Custom Field) / ~TOP_250~ (Custom Field) /
// If Not(GET_FULL_CREDIT): ~crew~ ctDirectors, ctWriters, ctComposers, ctProducers (Not in base page), ctActors
// ~description~ / ~category~ "keywords" / ~tagline~ / ~genre~
// If Not(GET_FULL_MPAA) ~mpaa~
// ~country~ / ~rdate~ in contry provider local IP geolocation
// If Not(GET_FULL_AKA) ~aka~.
// ~budget~ / ~money~ / ~studio~ "Production Co"
Var
curPos, endPos, index, debug_pos1: Integer;
StartPos, Hours, Minutes: Integer;
ItemValue, ItemValue0, ItemValue1, ItemValue2, ItemValue99, ItemList, ImageFile: String;
MovieURL, titleValue, yearValue, yearsValue: String;
Name, Role, PersonURL: String;
ItemList2, ItemList12, day_s, month_s, year_s: String;
ItemList1, ItemList11: String;
ItemArray: TWideArray;
Posters: array of TPosterInfo; // Declared Posters here
PosterURL, TempURL: String; // Added for poster handling
TempHeight: Integer; // Added for poster handling
Begin
LogMessage('Function ParsePage_IMDBMovieBASE BEGIN======================|');
Result := prFinished; // It will change to prError if any big problem with exit;
//Because the script doesn't retrieve the data in order, a token search for the first curPos position or block select is mandatory
//Get ~title~, ~year~, ~origtitle~, ~poster~
//Get all "raw" title summary (in raw because we need the hidden links, we avoid "complete" token in strings which opens/closes) // (* *)
//Get ~MID ID:~ and ~NUM ID::~
AddCustomFieldValueByName('MID ID:', GetFieldValueXML('mid'));
LogMessage(' ** Movie MID ID: ' + GetFieldValueXML('mid') + ' **');
if GetFieldValueXML('num') <> '0' then AddCustomFieldValueByName('NUM ID:', GetFieldValueXML('num'));
if GetFieldValueXML('num') <> '0' then LogMessage(' * Movie NUM ID: ' + GetFieldValueXML('num') + ' ||');
//Get ~script info~
//Get ~rdate~ in country provider local IP geolocation. See: http://sobizarre-en.blogspot.fr/2014/12/how-to-easily-defeat-imdb-geolocation.html
//Get ~imdbrating~, ~IMDB_Votes~ (Two tries)
ItemList := TextBetWeenFirst(HTML, '<script type="application/ld+json"', '}</script>'); //WEB_SPECIFIC.
//LogMessage(' Parse results (' + IntToStr(curPos) + ',' + IntToStr(endPos) + ') complex ItemList: ' + '<script type="application/ld+json"' + ItemList + '}</script>' + '||');
If (Length(ItemList) > 0) Then Begin
//Get ~IMDb Url~
//MovieURL:='http://www.imdb.com' + TextBetWeenFirst(ItemList, '","url":"', '","name":"');
MovieURL := TextBetWeenFirst(ItemList, '","url":"', '","name":"');
MovieURL := StringReplace(MovieURL, 'https://', 'http://', True, False, True);
AddFieldValueXML('url', MovieURL);
LogMessage(' * Get result url 1:' + MovieURL + ' ||');
LogMessage(' * Get result MovieURL: ' + MovieURL);
// IMDB_FIELD = 'IMDB';
if PosFrom('imdb', MovieURL, 1) > 0 then AddCustomFieldValueByName(IMDB_FIELD, '-1');
//Get ~title~
titleValue := TextBetWeenFirst(ItemList, '","name":"', '","'); //Strings which opens/closes the data. WEB_SPECIFIC
If titleValue = '0' then titleValue := '';
//If titleValue = '' then titleValue := TextBetWeenFirst(ItemList, '<h1 class="long">', '<'); //Strings which opens/closes the data. WEB_SPECIFIC
if GET_ORIGINAL_TITLE then AddFieldValueXML('title', titleValue);
AddCustomFieldValueByName('Title', titleValue);
AddCustomFieldValueByName('Localized title', titleValue);
LogMessage(' Get result title:' + titleValue + '||');
//Get ~origtitle~
ItemValue := TextBetWeenFirst(ItemList, '","name":"', '","'); //Strings which opens/closes the data. WEB_SPECIFIC
If (Length(ItemValue) = 0) Then ItemValue := titleValue; //Provider hides the original title if same as title. WEB_SPECIFIC
AddFieldValueXML('origtitle', ItemValue);
AddCustomFieldValueByName('Origtitle', ItemValue);
LogMessage(' Get result origtitle:' + ItemValue + '||');
//Get ~alternatetitle~
ItemValue := TextBetWeenFirst(ItemList, '","alternateName":"', '","'); //Strings which opens/closes the data. WEB_SPECIFIC
AddCustomFieldValueByName('Localized title', ItemValue);
if GET_LOCAL_TITLE then AddFieldValueXML('title', ItemValue);
if ItemValue <> '' then LogMessage(' Get result alternatetitle:' + ItemValue + '||');
If ItemValue <> '' then AddCustomFieldValueByName('Imdb_Title', ItemValue + #13 + titleValue + ' (original title)')
Else AddCustomFieldValueByName('Imdb_Title', titleValue);
//Get ~IMDB_Movietype~
ItemValue := TextBetWeenFirst(ItemList, '","@type":"', '","'); //Strings which opens/closes the data. WEB_SPECIFIC
MediaType := ItemValue;
MediaType := StringReplace(MediaType, 'TVEpisode', 'TV Episode', True, False, True);
MediaType := StringReplace(MediaType, 'TVSeries', 'TV Series', True, False, True);
AddCustomFieldValueByName('IMDB_Movietype', MediaType);
AddCustomFieldValueByName('Tv 0', MediaType);
if ItemValue <> '' then LogMessage(' Get result MediaType (CF~IMDB_Movietype~):' + MediaType + '||');
//Get ~IMDB_MPAA~
ItemValue := TextBetWeenFirst(ItemList, ',"contentRating":"', '","'); //Strings which opens/closes the data. WEB_SPECIFIC
AddCustomFieldValueByName('IMDB_MPAA', ItemValue);
if ItemValue <> '' then LogMessage(' Get result ContentRating (CF~IMDB_MPAA~):' + ItemValue + '||');
// Start of the new poster-related code
procedure AddPoster(const URL: string; Height: Integer);
begin
SetLength(Posters, Length(Posters) + 1);
Posters[High(Posters)].ImageURL := URL;
Posters[High(Posters)].Caption := 'Poster'; // Adjust this as needed
Posters[High(Posters)].Height := Height; // Added to ensure height is stored
end;
repeat
PosterURL := TextBetWeenFirst(ItemList, BASE_URL_IMAGE_PRE_TRUE, '.'); // Adjust this to match actual URLs
if PosterURL <> '' then
begin
TempURL := BASE_URL_IMAGE_PRE_TRUE + PosterURL + '.jpg';
TempHeight := StrToIntDef(TextBetWeenFirst(PosterURL, '_V1_UY', '_'), 0);
AddPoster(TempURL, TempHeight);
end;
until (PosterURL = '');
// Import the posters up to the specified limit
PosterCount := Min(5, Length(Posters)); // Up to 5 posters
for index := 0 to PosterCount - 1 do
begin
ImageFile := GetAppPath + 'Scripts\' + BASE_DOWNLOAD_FILE_IMAGE_NAME + '-Poster-' + IntToStr(index + 1) + '.jpg';
if (1 = DownloadImage(Posters[index].ImageURL + '._V1_UY' + IntToStr(Posters[index].Height) + '_.jpg', ImageFile)) then
begin
AddImageURL(itPoster, ImageFile);
LogMessage('Imported poster: ' + Posters[index].ImageURL + '._V1_UY' + IntToStr(Posters[index].Height) + '_.jpg' + ' || Height: ' + IntToStr(Posters[index].Height));
end
else if (1 = DownloadImage(Posters[index].ImageURL + '.jpg', ImageFile)) then
begin
AddImageURL(itPoster, ImageFile);
LogMessage('Imported poster: ' + Posters[index].ImageURL + '.jpg' + ' || Height: ' + IntToStr(Posters[index].Height));
end;
end;
// End of the new poster-related code
End;
Begin
LoadPosters;
// Additional code to integrate with PVD if needed
End.
//~description~
(11/16/2024 1:17:20 PM) Could not compile script: IMDB_2c_afro-Custom Cast + more.psf
[Error] (731:5): Identifier expected
This code of yours does not work for me. Can you attach your version of the script so I can see how it looks and works.
IMDB_[EN][HTTPS]_TEST_2c(Cast&Crew)_(afrocuban) script is attached.
Of course it doesn't transfer the correct information because this feature is not disabled. You probably have a setting to transfer information to "Cast" ~actors~ ctActors from the Full Cast&Crew website. Find this feature in the Script Options section at the top of the script and change the settings as shown below.Code: [Select]//GET_FULL_CREDIT = True ; //Download Cast or Credit provider page for retreive the info. Otherwise only the info of the principal movie page.
GET_FULL_CREDIT = False ; //Download Cast or Credit provider page for retreive the info. Otherwise only the info of the principal movie page.
I will edit a special script for this, maybe today for you.
Here is a special IMDB_[EN][HTTPS]_TEST_2c(Cast&Crew)_(afrocuban) script for you, which is set up to transfer information to "Cast" ~actors~ ctActors from the Full Cast&Crew website. You can also edit other person information using it.
The IMDB_[EN][HTTPS]_TEST_2c script cannot transfer all person information from the primary IMDb movie pages, because it will need to make some corrections or updates to properly transfer all information again, because some changes were made to the source code of the IMDb pages again.
IMDB_[EN][HTTPS]_TEST_2c(Cast&Crew)_(afrocuban) script is attached.
Of course it doesn't transfer the correct information because this feature is not disabled. You probably have a setting to transfer information to "Cast" ~actors~ ctActors from the Full Cast&Crew website. Find this feature in the Script Options section at the top of the script and change the settings as shown below.Code: [Select]//GET_FULL_CREDIT = True ; //Download Cast or Credit provider page for retreive the info. Otherwise only the info of the principal movie page.
GET_FULL_CREDIT = False ; //Download Cast or Credit provider page for retreive the info. Otherwise only the info of the principal movie page.
If GET_FULL_CREDIT Then Begin
//Get ~crew~ctDirectors,ctWriters,ctComposers,ctProducers
curPos:=Pos('<li role="presentation" class="ipc-metadata-list__item" data-testid="title-pc-principal-credit"><span class="ipc-metadata-list-item__label">Director',HTML); // Strings start which opens the block content data. WEB_SPECIFIC
curPos:=PosFrom('<div class="ipc-metadata-list-item__content-container"><ul class="ipc-inline-list ipc-inline-list--show-dividers ipc-inline-list--inline ipc-metadata-list-item__list-content baseAlt" role="presentation">',HTML,curPos); // Strings end which opens the block content data. WEB_SPECIFIC
curPos:=curPos+Length('<div class="ipc-metadata-list-item__content-container"><ul class="ipc-inline-list ipc-inline-list--show-dividers ipc-inline-list--inline ipc-metadata-list-item__list-content baseAlt" role="presentation">'); // 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('<a class="ipc-metadata-list-item__list-content-item ipc-metadata-list-item__list-content-item--link" rel="" href="/name/',ItemList); // String which opens the subList data. WEB_SPECIFIC
index:=1;
While curPos>0 Do Begin
If (index>PEOPLE_LIMITS) Then break; // Limited depassed.
//Get PersonURL (Always must it has)
PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a class="ipc-metadata-list-item__list-content-item ipc-metadata-list-item__list-content-item--link" rel="" href="/name/','/?ref_=tt_ov_dr',false,curPos) + 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_ov_dr">','<',false,curPos); // Strings which opens/closes the data. WEB_SPECIFIC
LogMessage(' Get result Name:'+Name+'||');
//Get Role NO: PVD don't save Role in crew people
If Pos('http://www.imdb.com/name//' ,PersonURL) < 1 then
AddMoviePerson(Name,'','',PersonURL,ctDirectors);
LogMessage(' Get results Director:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctDirectors');
curPos:=PosFrom('<a class="ipc-metadata-list-item__list-content-item ipc-metadata-list-item__list-content-item--link" rel="" href="/name/',ItemList,curPos); // String which opens the subList data. WEB_SPECIFIC
index:=index+1;
End;
//Go to "Writer:" or "Writers:" ~crew~ctWriters
curPos:=Pos('">Writer',HTML); // Strings start which opens the block content data. WEB_SPECIFIC
curPos:=PosFrom('<div class="ipc-metadata-list-item__content-container"><ul class="ipc-inline-list ipc-inline-list--show-dividers ipc-inline-list--inline ipc-metadata-list-item__list-content baseAlt" role="presentation">',HTML,curPos); // Strings end which opens the block content data. WEB_SPECIFIC
curPos:=curPos+Length('<div class="ipc-metadata-list-item__content-container"><ul class="ipc-inline-list ipc-inline-list--show-dividers ipc-inline-list--inline ipc-metadata-list-item__list-content baseAlt" role="presentation">'); // 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('<a class="ipc-metadata-list-item__list-content-item ipc-metadata-list-item__list-content-item--link" rel="" href="/name/',ItemList); // String which opens the subList data. WEB_SPECIFIC
index:=1;
While curPos>0 Do Begin
If (index>PEOPLE_LIMITS) Then break; // Limited depassed
//Get PersonURL (Always must it has)
PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a class="ipc-metadata-list-item__list-content-item ipc-metadata-list-item__list-content-item--link" rel="" href="/name/','/?ref_=tt_ov_wr',false,curPos) + 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_ov_wr">','<',false,curPos); // Strings which opens/closes the data. WEB_SPECIFIC
LogMessage(' Get result Name:'+Name+'||');
//Get Role NO: PVD don't save Role in crew people
AddMoviePerson(Name,'','',PersonURL,ctWriters);
LogMessage(' Get results Writer:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctWriters');
curPos:=PosFrom('<a class="ipc-metadata-list-item__list-content-item ipc-metadata-list-item__list-content-item--link" rel="" href="/name/',ItemList,curPos); // String which opens the subList data. WEB_SPECIFIC
index:=index+1;
End;
//Go to "Soundtracks" ~crew~ctComposers
curPos:=Pos('/soundtrack/?ref_=tt_trv_snd" target="">Soundtracks</a>',HTML); // Strings start which opens the block content data. WEB_SPECIFIC
curPos:=curPos+Length('/soundtrack/?ref_=tt_trv_snd" target="">Soundtracks</a>'); // 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('/soundtrack/?ref_=tt_trv_snd" aria-label="See more" target="">',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('</span><span class="soundtrack-comment-1">',ItemList); // String which opens the subList data. WEB_SPECIFIC
index:=1;
While curPos>0 Do Begin
If (index>PEOPLE_LIMITS) Then break; // Limited depassed.
//Get PersonURL (Always must it has)
PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'" href="/name/','/?ref_=tt_trv_snd">',false,curPos) + BASE_URL_SUF; // Strings which opens/closes the data. WEB_SPECIFIC
//Get Name (Always must it has)
Name:=TextBetWeen(ItemList,'/?ref_=tt_trv_snd">','<',false,curPos); // Strings which opens/closes the data. WEB_SPECIFIC
//Get Role NO: PVD don't save Role in crew people
If Pos('http://www.imdb.com/name//' ,PersonURL) < 1 then
AddMoviePerson(Name,'','',PersonURL,ctComposers);
LogMessage(' Get results Composers:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctComposers');
curPos:=PosFrom('Composed by',ItemList,curPos); // String which opens the subList data. WEB_SPECIFIC
index:=index+1;
End;
//Go to "Producers" ~crew~ctProducers
//No Producers in principal page.
LogMessage(' Get No results Producers'+#13);
//Get to "Cast" ~actors~ ctActors
// Start the cast extraction process
LogMessage('Starting cast extraction process.');
curPos:=Pos('<h3 class="ipc-title__text">Top cast',HTML); // Start of cast block
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) and (index <= 15) Do Begin
// 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,'">','</a><div class="title-cast-item__characters-list">',false,curPos); // Strings which opens/closes the data. WEB_SPECIFIC
LogMessage('Parse Results Name:'+Name+'||');
// Custom field: IMDb Cast (names only, separated by " • ")
If ItemValue1='' Then
ItemValue1:=Name
Else
ItemValue1:=ItemValue1+' • '+Name;
curPos:=PosFrom('<a data-testid="title-cast-item__actor" href="',ItemList,curPos); // Move to the next actor's block
index:=index+1;
End;
// Add custom field IMDb Cast
AddCustomFieldValueByName('IMDb Cast', ItemValue1);
// Log the IMDb Cast field for verification
LogMessage('IMDb Cast: '+ItemValue1);
// Log message and end block as in your script
LogMessage('Completed cast extraction process.');
LogMessage(#13+'');
End;
//Get "plot_summary" as ~comment~ //debug_pos1-1
I will edit a special script for this, maybe today for you.
//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