English > PVD Python Scripts

PVD Selenium MOD v4 IMDb Movie Script Confusion

(1/15) > >>

Ivek23:

--- Quote from: Ivek23 on March 20, 2025, 02:04:09 pm ---I do not recommend this, because for series there should be one script and for movies another script. I especially do not recommend this, because there is already quite a bit of confusion and errors in the movie scripts, because certain parts of the code either do not transfer any information to you. And if they do transfer information. they have errors or transfer incorrect information.

And that's it.
Many custom fields have been added that do not belong to certain parts of the code and then remain empty or have incorrect information in them or these fields are duplicated and therefore do not transfer any information in them. Therefore, it will be necessary to examine the IMDB Movie script in detail, where there is the most confusion.

--- End quote ---

afrocuban:
For my personal use, I will disable all the duplicates of the custom fields once I set all the scripts. We were foolish we were allowed to ask to have like 6 custom fields for Aspect ratio, for example. I just brought them all so users can decide which one they want. If some are empty, it's either they don't exist for the given movie, or they are set by Configurator not to be brought. Logic of the script is extremely complex. But let's see.

Ivek23:
We will custom fields, which are duplicates and if necessary, duplicate custom fields will be removed because they contain similar information, but we will go step by step. Testing is needed to see how and what.

Ivek23:
Function ParsePage_IMDBMovieBASE

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');
--- End quote ---

   

--- 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;
--- End quote ---

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;
--- End quote ---

   


--- 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

--- End quote ---

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
--- End quote ---


More to come next time or tomorrow.

afrocuban:
Thanks Ivek.


here's the assesment of these 3 snippets:


The only thing from the first 2 snippets  I see is that commented out lines are deleted from the original. I compared everything in Notepad++:


--- Quote ---      //MovieURL := 'http://www.imdb.com' + TextBetWeenFirst(ItemList, '", "url":"', '", "name":"');
--- End quote ---

--- Quote ---      //LogMessage('Function ParsePage_IMDBMovieBASE -   *   Get result url 1: ' + MovieURL + ' | |');
--- End quote ---


--- Quote ---         // If titleValue = '' then titleValue := TextBetWeenFirst(ItemList, '<h1 class="long">', '<'); // Strings which opens/closes the data. WEB_SPECIFIC
--- End quote ---



These lines, which were already commented out, are just deleted as "improvement" but they don't influence anything anyway, so I am not sure what improvement is there? With or without them, everything works anyway.

Also, the third snippets works too, it's just the other way to achieve the same. There are so many ways to achieve the same goal, and I choose one, that works too.

I hope to see what doesn't work actually in the scripts.


Navigation

[0] Message Index

[#] Next page

Go to full version