81
PVD Python Scripts / Re: PVD Selenium MOD v4 IMDb Movie Script Confusion
« Last post by Ivek23 on March 21, 2025, 07:13:42 pm »Function ParsePage_IMDBMovieBASE
Improved part of the code
Improved part of the code
Improved part of the code for the CustomStringReplace function, thus obtaining better space in scripts.
More to come next time or tomorrow.
Improved part of the code
Quote
//Get ~IMDb Url~
MovieURL := TextBetWeenFirst(ItemList, '","url":"','","name":"');
MovieURL := StringReplace(MovieURL, 'https://' ,'http://' ,True, False, True);
AddFieldValueXML('url', MovieURL);
LogMessage('Function ParsePage_IMDBMovieBASE - * Get result MovieURL: ' + MovieURL);
// IMDB_FIELD = 'IMDB';
if PosFrom('imdb', MovieURL, 1) > 0 then
AddCustomFieldValueByName(IMDB_FIELD, '-1');
Quote
If Not (ReferencePageDownloaded) Then Begin
// 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 - If set to false, both with GET_LOCAL_TITLE, nothing will be added, so it doesn't make sense here. However, in REFERENCE, as the third option, we can set the title available from the IMDb page for users with English settings (on IMDb or computer Regional Settings) or those in English-speaking geo-locations.
AddFieldValueXML('title', titleValue);
AddCustomFieldValueByName('Title', titleValue);
AddCustomFieldValueByName('Localized title', titleValue);
LogMessage('Function ParsePage_IMDBMovieBASE - Get result title: ' + titleValue + ' | |');
//If Not (USE_SAVED_PVDCONFIG And (ConfigOptions[2] = '0')) Then Begin
// 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 that title. WEB_SPECIFIC
AddFieldValueXML('origtitle', ItemValue);
AddCustomFieldValueByName('Origtitle', ItemValue);
AddCustomFieldValueByName('Original Title', ItemValue);
LogMessage('Function ParsePage_IMDBMovieBASE - Get result origtitle + (CF~OrigTitle~): ' + ItemValue + ' | |');
//End;
Improved part of the code
Quote
If Not (ReferencePageDownloaded) Then Begin
// Get ~title~
titleValue := TextBetWeenFirst(ItemList, '","name":"', '","'); // Strings which opens/closes the data. WEB_SPECIFIC
If titleValue = '0' then titleValue := '';
//if GET_ORIGINAL_TITLE then - If set to false, both with GET_LOCAL_TITLE, nothing will be added, so it doesn't make sense here. However, in REFERENCE, as the third option, we can set the title available from the IMDb page for users with English settings (on IMDb or computer Regional Settings) or those in English-speaking geo-locations.
AddFieldValueXML('title', titleValue);
AddCustomFieldValueByName('Title', titleValue);
AddCustomFieldValueByName('Localized title', titleValue);
LogMessage('Function ParsePage_IMDBMovieBASE - Get result title: ' + titleValue + ' | |');
//If Not (USE_SAVED_PVDCONFIG And (ConfigOptions[2] = '0')) Then Begin
// 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 that title. WEB_SPECIFIC
AddFieldValueXML('origtitle', ItemValue);
AddCustomFieldValueByName('Origtitle', ItemValue);
AddCustomFieldValueByName('Original Title', ItemValue);
LogMessage('Function ParsePage_IMDBMovieBASE - Get result origtitle + (CF~OrigTitle~): ' + ItemValue + ' | |');
//End;
Quote
//If Not (USE_SAVED_PVDCONFIG And (ConfigOptions[18] = '0')) Then Begin
// Get ~rdate~ + (CF~IMDB Release Date~)
ItemValue := TextBetWeenFirst(ItemList, ',"datePublished":"', '","'); // Strings which opens/closes the data. WEB_SPECIFIC
AddFieldValueXML('rdate', ItemValue); // It has to be added here, because being original field it follows by design the regional settings of your computer and cannot be customized like IMDB Release Date(s). It can be added as ItemArray[2] + '.' + ItemArray[1] + '.' + ItemArray[0]; only if the formats in the HTML and your computer are identical.
LogMessage('Function ParsePage_IMDBMovieBASE - Get result ~rdate~: ' + ItemValue + ' | |');
ItemValue := StringReplace(ItemValue, '-01', '-1', True, False, True);
ItemValue := StringReplace(ItemValue, '-02', '-2', True, False, True);
ItemValue := StringReplace(ItemValue, '-03', '-3', True, False, True);
ItemValue := StringReplace(ItemValue, '-04', '-4', True, False, True);
ItemValue := StringReplace(ItemValue, '-05', '-5', True, False, True);
ItemValue := StringReplace(ItemValue, '-06', '-6', True, False, True);
ItemValue := StringReplace(ItemValue, '-07', '-7', True, False, True);
ItemValue := StringReplace(ItemValue, '-08', '-8', True, False, True);
ItemValue := StringReplace(ItemValue, '-09', '-9', True, False, True);
if ItemValue <> '' then LogMessage('Function ParsePage_IMDBMovieBASE - Get result ReleaseDatePublished: ' + ItemValue + ' | |');
if ItemValue <> '' then begin
ExplodeString(ItemValue, ItemArray, '-');
ItemValue := ItemArray[2] + '.' + ItemArray[1] + '.' + ItemArray[0];
AddCustomFieldValueByName('IMDB Release Date', ItemValue);
if ItemValue <> '' then LogMessage('Function ParsePage_IMDBMovieBASE - Get result DatePublished (CF~IMDB Release Date~): ' + ItemValue + ' | |');
//End;
End;
End; //If Not (ReferencePageDownloaded) then Begin should and here
Improved part of the code for the CustomStringReplace function, thus obtaining better space in scripts.
Quote
//If Not (USE_SAVED_PVDCONFIG And (ConfigOptions[18] = '0')) Then Begin
// Get ~rdate~ + (CF~IMDB Release Date~)
ItemValue := TextBetWeenFirst(ItemList, ',"datePublished":"', '","'); // Strings which opens/closes the data. WEB_SPECIFIC
AddFieldValueXML('rdate', ItemValue); // It has to be added here, because being original field it follows by design the regional settings of your computer and cannot be customized like IMDB Release Date(s). It can be added as ItemArray[2] + '.' + ItemArray[1] + '.' + ItemArray[0]; only if the formats in the HTML and your computer are identical.
LogMessage('Function ParsePage_IMDBMovieBASE - Get result ~rdate~: ' + ItemValue + ' | |');
ItemValue := CustomStringReplace(ItemValue, ['-01', '-02', '-03', '-04', '-05', '-06', '-07', '-08', '-09'], ['-1', '-2', '-3', '-4', '-5', '-6', '-7', '-8', '-9']);
if ItemValue <> '' then LogMessage('Function ParsePage_IMDBMovieBASE - Get result ReleaseDatePublished: ' + ItemValue + ' | |');
if ItemValue <> '' then begin
ExplodeString(ItemValue, ItemArray, '-');
ItemValue := ItemArray[2] + '.' + ItemArray[1] + '.' + ItemArray[0];
AddFieldValueXML('rdate',ItemValue);
AddCustomFieldValueByName('IMDB Release Date', ItemValue);
if ItemValue <> '' then LogMessage('Function ParsePage_IMDBMovieBASE - Get result DatePublished (CF~IMDB Release Date~): ' + ItemValue + ' | |');
//End;
End;
End; //If Not (ReferencePageDownloaded) then Begin should and here
More to come next time or tomorrow.