English > Support

Personal Video Database 1.0.2.7 MOD

<< < (33/69) > >>

Ivek23:

--- Quote from: VVV_Easy_Programing on January 05, 2019, 03:10:50 pm ---Notes for Ivek23:

* Not included the parameter GET_PLOTKEYWORDS_LIMIT=False because is redundant with PLOTKEYWORDS_LIMIT set in a big number
* Not included the script part "Connections" as suggested (but we can include it with parameter GET_CONNECTIONS=False)
--- End quote ---
That's OK.


--- Quote from: VVV_Easy_Programing on January 05, 2019, 03:10:50 pm ---Notes for Ivek23:

* Corrected: "curPos:=curPos+43;" by "curPos:=curPos+45;" in order to get the good year (at least in Amadeus movie)
* Not included the code part of Post:
--- End quote ---
I will explain this below.


--- Quote from: VVV_Easy_Programing on January 05, 2019, 03:10:50 pm ---Notes for Ivek23:

* Not included the code part of Post:

   ImageFile:=TextBetWeenFirst(ItemList,'"image": "','._V1_.jpg",')+'._V1_UY'+IntToStr(MAX_IMAGE_HEIGTH)+'_.jpg';
   AddImageURL(itPoster,ImageFile);
   LogMessage('      Get result poster:' + ImageFile +'||');
   ItemValue1:=TextBetWeenFirst(ItemList,'"datePublished": "','-');
   //AddFieldValueXML('year',ItemValue1);
    LogMessage('      Get result year01:'+ItemValue1+'||');

because is not needed for download the poster and the AddFieldValueXML is after // (commentary) and ItemValue1 is not more used
--- End quote ---
It can be added there, it works. I added it for updating another IMDb script, where I used it and works the same way as here. But it does not need to be updated every time, when the next time they will encounter new changes to the source code for the IMDb website.

Ivek23:
IMDB_ [EN] [HTTPS]

New added:

--- Quote ---  5. Cast & Crew field info names:   
   •   Directed by
   •   Writing Credits  // NO (WGA)
   •   Cast (in credits order)  // Only data info in normal Actors field
   •   Produced by
   •   Music by
   •   Cinematography by  // NO
   •   Film Editing by  // NO
   •   Casting By  // NO
   •   Production Design by  // NO
   •   Art Direction by  // NO
   •   Set Decoration by  // NO
   •   Costume Design by  // NO
   •   Production Management  // NO
   •   Second Unit Director or Assistant Director  // NO 
   •   Special Effects by  // NO
   •   Visual Effects by  // NO
   •   Casting Department  // NO
   •   Location Management  // NO
   •   Music Department  // NO
   •   Thanks
--- End quote ---

--- Quote ---  GET_CREW_CREDIT  = False ;  //Download Cast and Credit provider page for retreive the some credits (crew) info. Otherwise set to False to only the Directors, Writers, Composers, Producers, Cinematography and Thanks info of the Cast and Credit provider page. 
  //GET_CREW_CREDIT  = True ;  //Download Cast and Credit provider page for retreive the some credits (crew) info. Otherwise set to False to only the Directors, Writers, Composers, Producers, Cinematography and Thanks info of the Cast and Credit provider page.
--- End quote ---
Works in IMDB_ [EN] [HTTPS] _ (Cast & Crew) script.

--- Quote ---  GET_FULL_PLOTSUMMARY  = True ;  //Download Plot provider page for retreive the Summaries info. Otherwise only the info of the principal movie page
--- End quote ---

Modified:

Function ParsePage_IMDBMovieBASE

--- Quote ---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"
    //         If Not(GET_FULL_FEATURES) ~features~
  Var
      curPos,endPos,index:Integer;
      ItemValue1,ItemValue0,ItemValue,ItemList,ImageFile:String;
      titleValue:String;
      Name,Role,PersonURL:String;
      ItemArray:TWideArray;
  Begin
    LogMessage('Function ParsePage_IMDBMovieBASE BEGIN======================|');
    Result:=prFinished;  //It will change to prError if any big problem with exit;  //**// (* *)
    //Because the script don't retreives the data in the page 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)
    ItemList:=TextBetWeenFirst(HTML,'<div class="title_block"','div class="plot_summary_wrapper">'); //WEB_SPECIFIC.
   //LogMessage('      Get result ItemList:'+#13+ItemList+'||');   
    If (Length(ItemList)>0) Then Begin
        //Get ~title~
        titleValue:=TextBetWeenFirst(ItemList,'<h1 class="">','<');       //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
        AddFieldValueXML('title',titleValue);
        LogMessage('      Get result title:'+titleValue+'||');   
        //First normal kind get of ~year~
        ItemValue:=TextBetWeenFirst(ItemList,'<span id="titleYear">(',')</span>            </h1>');                                 //Strings which opens/closes the data. WEB_SPECIFIC      
        AddFieldValueXML('year',ItemValue);
        LogMessage('      Get result normal year:'+ItemValue+'||');
      //Second kind of get of ~year~
      endPos:=PosFrom('title="See more release dates" >',ItemList,curPos);
        curPos:=PosFrom('title="See more release dates" >',ItemList,endPos);
      endPos:=PosFrom(' (',ItemList,curPos);
      if (EndPos < 1) OR (EndPos > PosFrom('</a>            </div>',ItemList,curPos)) then
      EndPos := PosFrom('</a>            </div>',ItemList,curPos);
      curPos:=endPos-4;
      ItemValue0:=Copy(ItemList,curPos,4);
      LogMessage('      Get result second kind of year 0:'+ItemValue0+'||');
        if ItemValue0 <> '' then AddFieldValueXML('year',ItemValue0);
        if ItemValue0 <> '' then LogMessage('      Get result second kind of year:'+ItemValue0+'||');      
        //Second kind of get of ~year~ or for series
        endPos:=PosFrom('title="See more release dates" >',ItemList,curPos);
        curPos:=PosFrom('title="See more release dates" >',ItemList,endPos);   
        endPos:=PosFrom('</a>            </div>',ItemList,curPos);
      curPos:=curPos+43;
        ItemValue1:=Copy(ItemList,curPos,4);
        LogMessage('      Get series result for series year:'+ItemValue1+'||');
        //ItemValue1:=StringReplace(ItemValue1,'/a> ','',True,False,True);
        if ItemValue1 <> '' then AddFieldValueXML('year',ItemValue1);
        if ItemValue1 <> '' then LogMessage('      Get series result for series year2:'+ItemValue1+'||');
        //Get ~origtitle~
        ItemValue:=TextBetWeenFirst(ItemList,'<div class="originalTitle">','<');          //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);
        LogMessage('      Get result origtitle:'+ItemValue+'||');
        ItemValue:=TextBetWeenFirst(ItemList,BASE_URL_IMAGE_PRE_TRUE,'.');                 //Get poster code. Strings which opens/closes the data. WEB_SPECIFIC
        If ((Length(ItemValue)>0) and Not(USE_SAVED_PVDCONFIG and (Copy(PVDConfigOptions,opPoster,1)='0'))) then begin  //The Poster will be saved in PVDthen begin
            ItemValue:=BASE_URL_IMAGE_PRE_TRUE + ItemValue;                             //Base poster URL without '.jpg'. WEB_SPECIFIC
            ImageFile:=GetAppPath+'Scripts\'+BASE_DOWNLOAD_FILE_IMAGE_NAME+'-Poster.jpg'
            // Avoid HTTPS redirection: Download https image to file  OutPutFile=
            If (1=DownloadImage(ItemValue + '._V1_UY' + IntToStr(MAX_IMAGE_HEIGTH) + '_.jpg',ImageFile)) then begin  //Dowload in the selected user max size. WEB_SPECIFIC
                AddImageURL(itPoster,ImageFile);    //Get the photo from a file even if the next line we log the true URL.
                LogMessage('      Get result poster:'+ItemValue + '._V1_UY' + IntToStr(MAX_IMAGE_HEIGTH) + '_.jpg'+'||');
            end else if (1=DownloadImage(ItemValue +'.jpg',ImageFile)) then begin  //Dowload in the web base size. WEB_SPECIFIC
                AddImageURL(itPoster,ImageFile);    //Get the photo from a file even if the next line we log the true URL.
                LogMessage('      Get result poster:' + ItemValue + '.jpg'+'||');
            end;
        End;
    End;
--- End quote ---

Now I've updated the year code. For users who want to update information for series, adds the year correctly to the database.


--- Quote ---    //Get ~script info~
    //Get ~rdate~ in contry 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.
    If (Length(ItemList)>0) Then Begin
      ItemValue:=TextBetWeenFirst(ItemList,'"@type": "','",');   //Strings which opens/closes the data. WEB_SPECIFIC      
      ItemValue:=StringReplace(ItemValue,'TVSeries','TV Series',True,False,True);
      ItemValue:=StringReplace(ItemValue,'TVEpisode','TV Episode',True,False,True);      
      //AddCustomFieldValueByName('IMDBMovietype',ItemValue);
      //LogMessage('      Get result MediaType (CF~IMDBMovietype~):'+ItemValue+'||');
      MediaType:=StringReplace(ItemValue,'TVSeries','TV Series',True,False,True);
      MediaType:=StringReplace(ItemValue,'TVEpisode','TV Episode',True,False,True);               
      AddCustomFieldValueByName('IMDB_Movietype',MediaType);
      LogMessage('      Get result MediaType (CF~IMDB_Movietype~):'+MediaType+'||');
      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+'||');
   ImageFile:=TextBetWeenFirst(ItemList,'"image": "','._V1_.jpg",')+'._V1_UY'+IntToStr(MAX_IMAGE_HEIGTH)+'_.jpg';
   AddImageURL(itPoster,ImageFile);
   LogMessage('      Get result poster:' + ImageFile +'||');
   ItemValue1:=TextBetWeenFirst(ItemList,'"datePublished": "','-');
   //AddFieldValueXML('year',ItemValue1);
    LogMessage('      Get result year01:'+ItemValue1+'||');
      ItemValue:=TextBetWeenFirst(ItemList,'"datePublished": "','",');   //Strings which opens/closes the data. WEB_SPECIFIC
        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('      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('      Get result DatePublished ~rdate~ (CF~IMDB Release Date~):'+ItemValue+'||');      
      End;
      ItemValue:=TextBetWeenFirst(ItemList,'"ratingCount": ',',');   //Strings which opens/closes the data. WEB_SPECIFIC
      AddCustomFieldValueByName('IMDB_Votes',ItemValue);      
      if ItemValue <> '' then LogMessage('      Get result ratingCount (~IMDB_Votes~): '+ItemValue+' ||');   
      ItemValue:=TextBetWeenFirst(ItemList,'"ratingValue": "','"');   //Strings which opens/closes the data. WEB_SPECIFIC
      AddFieldValueXML('imdbrating',ItemValue);
      AddCustomFieldValueByName('IMDB Rating',ItemValue);
      AddCustomFieldValueByName('IMDBRating',ItemValue);
      if ItemValue <> '' then LogMessage('      Get result ratingValue ~imdbrating~ (CF~IMDB Rating~~IMDBRating~): '+ItemValue+' ||');         
    End;
--- End quote ---


--- Quote from: Ivek23 on January 21, 2019, 03:19:51 pm ---
--- Quote from: VVV_Easy_Programing on January 05, 2019, 03:10:50 pm ---Notes for Ivek23:

* Not included the code part of Post:

   ImageFile:=TextBetWeenFirst(ItemList,'"image": "','._V1_.jpg",')+'._V1_UY'+IntToStr(MAX_IMAGE_HEIGTH)+'_.jpg';
   AddImageURL(itPoster,ImageFile);
   LogMessage('      Get result poster:' + ImageFile +'||');
   ItemValue1:=TextBetWeenFirst(ItemList,'"datePublished": "','-');
   //AddFieldValueXML('year',ItemValue1);
    LogMessage('      Get result year01:'+ItemValue1+'||');

because is not needed for download the poster and the AddFieldValueXML is after // (commentary) and ItemValue1 is not more used
--- End quote ---
It can be added there, it works. I added it for updating another IMDb script, where I used it and works the same way as here. But it does not need to be updated every time, when the next time they will encounter new changes to the source code for the IMDb website.
--- End quote ---

Ivek23:
IMDB_ [EN] [HTTPS] script

Modified:


--- Quote ---    //Get "plot_summary" as ~comment~ (In the PVD check fields table selection only ~description~ can be checked for overwrite but the user can change the config and
    // write ~description~ in ~comment~ so with the script parameter we Avoid double use of ~description~ and ~comment~.
    If Not(PRESERVE_PVD_DESCRIPTION_SETTING) Then Begin
        curPos:=Pos('<div class="plot_summary',HTML);                                 //WEB_SPECIFIC.   
        If 0<curPos then begin
            curPos:=Pos('<div class="summary_text">',HTML);                                 //WEB_SPECIFIC.
            If 0<curPos Then Begin
                ItemValue:=TextBetWeen(HTML,'<div class="summary_text','</div>',false,curPos);   //Strings which opens/closes the data. WEB_SPECIFIC
                curPos:=Pos('  <a href="',ItemValue);
                If 0<curPos then ItemValue:=Copy(ItemValue,0,curPos-1);
                ItemValue:=StringReplace(ItemValue,',            ',', ',True,False,True);
                ItemValue:=StringReplace(ItemValue,'            ',' ',True,False,True);
                ItemValue:=StringReplace(ItemValue,'        ',' ',True,False,True);
                ItemValue:=StringReplace(ItemValue,'Add a Plot »','',True,False,True);
                ItemValue:=StringReplace(ItemValue,'See full summary »','',True,False,True);
                ItemValue:=StringReplace(ItemValue,'">','',True,False,True);
                curPos:=Pos('var ue_t0=ue_t0||+new Date();var ',ItemValue);
                If 0<curPos then ItemValue:=Copy(ItemValue,0,curPos-1);
                //AddFieldValueXML('comment',ItemValue);
                LogMessage('      Get result "Plot_summary" as ~comment~:'+ItemValue+'||');
            End;
        End;   
    End;
--- End quote ---
Now the plot_summary info on the primary IMDb page will no longer be written to the comment field, although you will make changes to the PVD settings.

Ivek23:
IMDB_ [EN] [HTTPS] script

ParsePage_IMDBMovieCREDIT

New added and modified:


--- Quote ---Function ParsePage_IMDBMovieCREDIT(HTML:String):Cardinal; //BlockOpen
    //Returns:
    //     Result:=prFinished; Script has finished gathering data
    //     Result:=prError; If żany big problem? with exit;
    //Retrieve: ~crew~ctDirectors,ctWriters,ctComposers,ctProducers
    //          ~actors~ ctActors
  Var
    curPos,endPos,index:Integer;
   debug_pos1:Integer;
    ItemValue,ItemList:String;
    Name,Role,PersonURL:String;
   ItemValue14:String;
   Fullinfo,Directors,Writers,Composers,Producers:String;   
  Begin
    LogMessage('Function ParsePage_IMDBMovieCREDIT BEGIN=====================||');
    Result:=prFinished;  //It will change to prError if any big problem with exit;
  //Get Full Cast & Crew   
   curPos:=Pos('<h1 class="header">Full Cast & Crew</h1>',HTML);
   If 0<curPos Then Begin   
      EndPos:=curPos;
      ItemValue:=HTMLValues2(HTML,'<h1 class="header">Full Cast & Crew</h1>','<h2>See also</h2>','<h4 ','</h4>','<br>   •   ',EndPos);  //WEB_SPECIFIC.
      If ItemValue <> '' then ItemValue:='<link url="'+GetFieldValueXML('url')+'fullcredits">Full Cast&Crew info names</link><br>   •   '+ItemValue;
      AddCustomFieldValueByName('Cinema1',ItemValue);
      LogMessage('      Get result Movie Full Cast & Crew Credits:'+ItemValue+'||');
   End;         
  //Get ~crew~ctDirectors,ctWriters,ctComposers,ctProducers
   Fullinfo:='';
    //Go to "Directed by" ~crew~ctDirectors
    curPos:=Pos('<h4 class="dataHeaderWithBorder">Directed by',HTML);                     //Strings start which opens the block content data. WEB_SPECIFIC   
    If 0<curPos Then Begin
      curPos:=PosFrom('</h4>',HTML,curPos);                                              //Strings end which opens the block content data.  WEB_SPECIFIC
      curPos:=curPos+Length('</h4>');                                                    //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~ n the ~crew~
      endPos:=PosFrom('</table>',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('<td class="name">',ItemList)                                         //String which opens the subList data. WEB_SPECIFIC
      index:=1;
      While curPos>0 Do Begin
         If (index>PEOPLE_LIMIT) Then break;     //Limited depassed.
         //Get PersonURL (Always must it has)
         PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',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,'> ','</a>',false,curPos);                                 //Strings which opens/closes the data. WEB_SPECIFIC     
         LogMessage('      Parse Results Name:'+Name+'||');
         //Get Role: PVD don't save Role in crew people but is added for Ivek23 as LogMessage compatibility
            Role:=TextBetWeen(ItemList,'<td ','</td>',false,curPos);                             //Strings which opens/closes the data. WEB_SPECIFIC
         LogMessage('      Parse Results Role1:'+Role+'||');
         Role:=StringReplace(Role,'class="credit">','',True,False,True);
         Role:=StringReplace(Role,'colspan="2">','',True,False,True);
         Role:=StringReplace(Role,'            (uncredited)','(uncredited)',True,False,True);
         LogMessage('      Parse Results Role:'+Role+'||');
         AddMoviePerson(Name,'','',PersonURL,ctDirectors);
         //LogMessage('      Get results Director:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctDirectors');
         if Directors <> '' then Directors:=Directors+#13;
         if PersonURL <> '' then Directors:=Directors+'<link url="'+PersonURL+'">'+Name+'</link>'+'          ';
         if Role <> '' then Directors:=Directors+Role;         
         LogMessage('      Get results Directors:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||ctDirectors');
         curPos:=PosFrom('<td class="name">',ItemList,curPos)                                            //String which opens the subList data. WEB_SPECIFIC
         index:=index+1;
      End;
    End;
   If Directors <> '' then fullinfo:=fullinfo+'Directed:'+'<br>'+Directors+'<br><br>';
    //Go to "Writer:" or "Writers:" ~crew~ctWriters
   curPos:=Pos('<h4 class="dataHeaderWithBorder">Writing Credits',HTML);
   If 0<curPos Then Begin   
      curPos:=PosFrom('</h4>',HTML,curPos);                                              //Strings end which opens the block content data.  WEB_SPECIFIC
      curPos:=curPos+Length('</h4>');                                                    //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('</table>',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('<td class="name">',ItemList)                                            //String which opens the subList data. WEB_SPECIFIC
      index:=1;
      While curPos>0 Do Begin
         If (index>PEOPLE_LIMIT) Then break;     //Limited depassed.
         //Get PersonURL (Always must it has)
         PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',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,'> ','</a>',false,curPos);                                 //Strings which opens/closes the data. WEB_SPECIFIC
         LogMessage('      Parse Results Name:'+Name+'||');
            //Get Role: PVD don't save Role in crew people but is added for Ivek23 as LogMessage compatibility
         Role:=TextBetWeen(ItemList,'<td class="credit">','</td>',false,curPos);                    //Strings which opens/closes the data. WEB_SPECIFIC
         Role := StringReplace(Role,') and',') ',True,False,True);
         Role := StringReplace(Role,') &',') ',True,False,True);
         Role := StringReplace(Role,'novel &','novel ',True,False,True);
         Role := StringReplace(Role,'screenplay &','screenplay ',True,False,True);
         Role := StringReplace(Role,'script &','script ',True,False,True);
         //Role := StringReplace(Role,'story &','story ',True,False,True);
         //Role := StringReplace(Role,'&',' ',True,False,True);
         if Pos('and',Role) = 1 then Delete(Role, 1, 3);
         if Pos('&',Role) = 1 then Delete(Role, 1, 2);
         if Pos('story and',Role) = 1 then Delete(Role, 7, 3);
         //Role:=StringReplace(Role,'            ','          ',True,False,True);         
         LogMessage('      Parse Results Role:'+Role+'||');            
         AddMoviePerson(Name,'','',PersonURL,ctWriters);
         //LogMessage('      Get results Writer:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctWriters');
         if Writers <> '' then Writers:=Writers+#13;
         if PersonURL <> '' then Writers:=Writers+'<link url="'+PersonURL+'">'+Name+'</link>'+'          ';
         if Role <> '' then Writers:=Writers+Role;                  
         LogMessage('      Get results Writers:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||ctWriters'); 
         curPos:=PosFrom('<td class="name">',ItemList,curPos)     //String which opens the subList data. WEB_SPECIFIC
         index:=index+1;
      End;
    End;
   If Writers <> '' then fullinfo:=fullinfo +'Writing Credits:'+'<br>'+Writers+'<br><br>';
    //Go to "Producers" ~crew~ctProducers
   curPos:=Pos('<h4 class="dataHeaderWithBorder">Produced by',HTML);
   If 0<curPos Then Begin
      curPos:=PosFrom('</h4>',HTML,curPos);                                              //Strings end which opens the block content data.  WEB_SPECIFIC
      curPos:=curPos+Length('</h4>');                                                    //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('</table>',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('<td class="name">',ItemList)                                               //String which opens the subList data. WEB_SPECIFIC
      index:=1;
      While curPos>0 Do Begin
         If (index>PEOPLE_LIMIT) Then break;     //Limited depassed.
         //Get PersonURL (Always must it has)
         PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',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,'> ','</a>',false,curPos);                                 //Strings which opens/closes the data. WEB_SPECIFIC
         LogMessage('      Parse Results Name:'+Name+'||');
            //Get Role: PVD don't save Role in crew people but is added for Ivek23 as LogMessage compatibility
         Role:=TextBetWeen(ItemList,'<td class="credit">','</td>',false,curPos);                    //Strings which opens/closes the data. WEB_SPECIFIC
         LogMessage('      Parse Results Role:'+Role+'||');
         AddMoviePerson(Name,'','',PersonURL,ctProducers);
         //LogMessage('      Get results Producers:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctProducers');
         if Producers <> '' then Producers:=Producers+#13;
         if PersonURL <> '' then Producers:=Producers+'<link url="'+PersonURL+'">'+Name+'</link>'+'          ';
         if Role <> '' then Producers:=Producers+Role;         
         LogMessage('      Get results Producers:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||ctProducers'); 
         curPos:=PosFrom('<td class="name">',ItemList,curPos)                                                   //String which opens the subList data. WEB_SPECIFIC
         index:=index+1;
      End;   
    End;
   If Producers <> '' then fullinfo:=fullinfo +'Produced:'+'<br>'+Producers+'<br><br>';
    //Go to "Music" ~crew~ctComposers
   curPos:=Pos('<h4 class="dataHeaderWithBorder">Music by',HTML);
   If 0<curPos Then Begin
      curPos:=PosFrom('</h4>',HTML,curPos);                                              //Strings end which opens the block content data.  WEB_SPECIFIC
      curPos:=curPos+Length('</h4>');                                                    //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('</table>',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+'||');List+'||');
      curPos:=Pos('<td class="name">',ItemList)                                               //String which opens the subList data. WEB_SPECIFIC
      index:=1;
      While curPos>0 Do Begin
         If (index>PEOPLE_LIMIT) Then break;     //Limited depassed.
         //Get PersonURL (Always must it has)
         PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',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,'> ','</a>',false,curPos);                                 //Strings which opens/closes the data. WEB_SPECIFIC         
         LogMessage('      Parse Results Name:'+Name+'||');
            //Get Role: PVD don't save Role in crew people but is added for Ivek23 as LogMessage compatibility
         Role:=TextBetWeen(ItemList,'<td class="credit">','</td>',false,curPos);                    //Strings which opens/closes the data. WEB_SPECIFIC
         LogMessage('      Parse Results Role:'+Role+'||');
         AddMoviePerson(Name,'',Role,PersonURL,ctComposers);
         //LogMessage('      Get results Composers:#'+IntToStr(index)+'|'+Name+'|'+PersonURL+'||ctComposers');
         if Composers <> '' then Composers:=Composers+#13;
         if PersonURL <> '' then Composers:=Composers+'<link url="'+PersonURL+'">'+Name+'</link>'+'          ';
         if Role <> '' then Composers:=Composers+Role;
         LogMessage('      Get results Composers:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||ctComposers'); 
         curPos:=PosFrom('<td class="name">',ItemList,curPos)                                                   //String which opens the subList data. WEB_SPECIFIC
         index:=index+1;
      End;
    End;
   If Composers <> '' then fullinfo:=fullinfo +'Music:'+'<br>'+Composers+'<br><br>';
    //Get  to "Cast" ~actors~ ctActors
    //Go Cast list
    curPos:=Pos('<table class="cast_list">',HTML);                                     //Strings start which opens the block content data. WEB_SPECIFIC
    curPos:=curPos+Length('<table class="cast_list">');                                //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('</div>',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('<td class="primary_photo">',ItemList)                               //String which opens the subList data. WEB_SPECIFIC
    index:=1;
    While curPos>0 Do Begin
        If (index>PEOPLE_LIMIT) Then break;     //Limited depassed.
        //Get PersonURL (Always must it has)
        PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',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,'> ','</a>',false,curPos);                             //Strings which opens/closes the data. WEB_SPECIFIC      
        LogMessage('      Parse Results Name:'+Name+'||');
        //Get Role
        Role:=TextBetWeen(ItemList,'<td class="character">','</td>',false,curPos);                    //Strings which opens/closes the data. WEB_SPECIFIC         
        LogMessage('      Parse Results Role:'+Role+'||');
      Role:=StringReplace(Role,'       (',' (',True,False,True);
      Role:=StringReplace(Role,'(uncredited)                    ','(uncredited) • ',True,False,True);
      Role:=StringReplace(Role,')                    ',') ',True,False,True);
      Role:=StringReplace(Role,' /              ',' - ',True,False,True);
      Role:=StringReplace(Role,'         / ...                    ',' • ',True,False,True);
      Role:=StringReplace(Role,'                  ',' • ',True,False,True);      
      Role:=StringReplace(Role,'      (uncredited)',' (uncredited)',True,False,True);
      LogMessage('      Parse Results Role_1:'+Role+'||');      
        AddMoviePerson(Name,'',Role,PersonURL,ctActors);
        LogMessage('      Get results cast:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||ctActors');                                               
        curPos:=PosFrom('<td class="primary_photo">',ItemList,curPos);                                  //String which opens the Web Result item List data. WEB_SPECIFIC
        index:=index+1;
    End;   
--- End quote ---

Ivek23:
IMDB_ [EN] [HTTPS] script

ParsePage_IMDBMovieCREDIT

Part 2:

New added and modified:


--- Quote ---Function ParsePage_IMDBMovieCREDIT(HTML:String):Cardinal; //BlockOpen
    //Returns:
    //     Result:=prFinished; Script has finished gathering data
    //     Result:=prError; If żany big problem? with exit;
    //Retrieve: ~crew~ctDirectors,ctWriters,ctComposers,ctProducers
    //          ~actors~ ctActors
  Var
    curPos,endPos,index:Integer;
   debug_pos1:Integer;
    ItemValue,ItemList:String;
    Name,Role,PersonURL:String;
   ItemValue14:String;
   Fullinfo,Directors,Writers,Composers,Producers:String;   
  Begin
    LogMessage('Function ParsePage_IMDBMovieCREDIT BEGIN=====================||');
    Result:=prFinished;  //It will change to prError if any big problem with exit;
.
.
.
   //Get to "Others Crew"
    //Go Others Crew list
   //~Cinematography~
   ItemValue:='';
   curPos:=Pos('<h4 class="dataHeaderWithBorder">Cinematography by',HTML);
   If 0<curPos Then Begin
      curPos:=PosFrom('</h4>',HTML,curPos);
      curPos:=curPos+Length('</h4>');
      endPos:=PosFrom('</table>',HTML,curPos);
      ItemList:=Copy(HTML,curPos,endPos-curPos);
      //LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
      curPos:=Pos('<td class="name">',ItemList);
      index:=1;
      While curPos>0 Do Begin
         PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',false,curPos) + BASE_URL_SUF;
         //LogMessage('      Parse Results PersonURL:'+PersonURL+'||');         
         Name:=TextBetWeen(ItemList,'> ','</a>',false,curPos);
         //LogMessage('      Parse Results Name:'+Name+'||');
         Role:=TextBetWeen(ItemList,'<td class="credit">','</td>',false,curPos);
         //LogMessage('      Parse Results Role:'+Role+'||');   
         if ItemValue <> '' then ItemValue:=ItemValue+#13;
         if PersonURL <> '' then ItemValue:=ItemValue+'<link url="'+PersonURL+'">'+Name+'</link>'+'          ';
         if Role <> '' then ItemValue:=ItemValue+Role;
         //AddCustomFieldValueByName('Cinema',ItemValue);   
         //if ItemValue <> '' then Fullinfo:=Fullinfo+'Cinematography:<br>'+ItemValue+'<br><br>';
         LogMessage('      Get results Cinematography by:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||');                                               
         curPos:=PosFrom('<td class="name">',ItemList,curPos);
         index:=index+1;
      End;   
   End;
   If ItemValue <> '' then Fullinfo:=Fullinfo+'Cinematography:<br>'+ItemValue+'<br><br>';       
   //~Thanks~
   ItemValue14:='';
   curPos:=Pos('<h4 class="dataHeaderWithBorder">Thanks',HTML);
   If 0<curPos Then Begin
      curPos:=PosFrom('</h4>',HTML,curPos);
      curPos:=curPos+Length('</h4>');
      endPos:=PosFrom('</table>',HTML,curPos);
      ItemList:=Copy(HTML,curPos,endPos-curPos);
      //LogMessage('           Parse results ('+IntToStr(curPos)+','+IntToStr(endPos)+') complex ItemList:'+ItemList+'||');
      curPos:=Pos('<td class="name">',ItemList);
      index:=1;
      While curPos>0 Do Begin
         PersonURL:=BASE_URL_PERSON_PRE + TextBetWeen(ItemList,'<a href="/name/','/',false,curPos) + BASE_URL_SUF;               
         //LogMessage('      Parse Results PersonURL:'+PersonURL+'||');
         Name:=TextBetWeen(ItemList,'> ','</a>',false,curPos);
         //LogMessage('      Parse Results Name:'+Name+'||');
         Role:=TextBetWeen(ItemList,'<td class="credit">','</td>',false,curPos);
         //LogMessage('      Parse Results Role:'+Role+'||');   
         //if ItemValue14 <> '' then ItemValue14:=ItemValue14+#13;
         if ItemValue14 <> '' then ItemValue14:=ItemValue14+#32#32;   
         If Pos('the producers wish to thank',Role) OR Pos('special thanks',Role) OR Pos('thanks',Role) < 1 then   
         if PersonURL <> '' then ItemValue14:=ItemValue14+'<link url="'+PersonURL+'">'+Name+'</link>'+'          ';            
         debug_pos1:=Pos('the producers wish to thank',Role);
            If debug_pos1 >0 then Role:=Copy(Role,0,debug_pos1-1);
         debug_pos1:=Pos('very special thanks',Role);
            If debug_pos1 >0 then Role:=Copy(Role,0,debug_pos1-1);            
         debug_pos1:=Pos('special thanks',Role);
            If debug_pos1 >0 then Role:=Copy(Role,0,debug_pos1-1);
         debug_pos1:=Pos('thanks',Role);
            If debug_pos1 >0 then Role:=Copy(Role,0,debug_pos1-1);            
         if Role <> '' then ItemValue14:=ItemValue14+Role;
         ItemValue14:=StringReplace(ItemValue14,'      <link url="',#13+'<link url="',True,False,True);
         LogMessage('      Get results Thanks:#'+IntToStr(index)+'|'+Name+'|'+Role+'|'+PersonURL+'||');            
         curPos:=PosFrom('<td class="name">',ItemList,curPos);    
         index:=index+1;
      End;   
   End;   
   If ItemValue14 <> '' then Fullinfo:=Fullinfo+'Thanks:<br>'+ItemValue14;      
   if (Length(Fullinfo)>0) then begin
        AddCustomFieldValueByName('Cinema',Fullinfo);
        LogMessage('      Get result Movie Others Crew:'+Fullinfo+'||');
    End;
    LogMessage('Function ParsePage_IMDBMovieCREDIT END=====================||');
  End; //BlockClose
--- End quote ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version