Page 1 of 1

[UPD ITA] comingsoon.it

Posted: 2019-06-21 09:41:18
by fulvio53s03
New google's search structure! :rolleyes:

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=Fulvio53s03
Title=comingsoon
Description=import film e serie TV
Site=http://www.comingsoon.it
Language=IT
Version=1.4.0
Requires=4.2.1
Comments=puo' essere usato per ricerca informazioni tramite google (mode=0) oppure per estrarle direttamente da comingsoon.it (mode=1) inserendo l'URL direttamente.
License=*  The source code of the script can be used in   |*  another program only if full credits to Fulvio53s03*
GetInfo=1
RequiresMovies=1

[Options]
Mode=0|0|0=normal mode|1=batch mode (url)

[Parameters]

***************************************************)

// TypeSearch=1|1|1=search for exact expression|2=search for any word
// TypeOrder=3|3|1=order by Artist|2=order by film_o_serie Title|3=order by relevance

// needs the following units
// StringUtils7552.pas
//
program comingsoon;
uses
   StringUtils7552;
   
const
   comingsoonUrl = 'https://www.comingsoon.it';                // base url

   UrlBase = 'https://www.comingsoon.it';                // base url
   batchlogfic = 'c:\comingsoon_batch.txt';                  // log for batch mode
   debug_search = false;                                   // debuga mode on/off su ricerca dischi
   debug_film_o_serie = false;                                   // debug mode on/off su estrazione dati film_o_serie
   folder = 'f:\prova\';                                       // directory where to save files
   CRLFspace = CRLF + ' ';
var
   nuovo_anno, mese_anno, solo_anno, data_rilascio, label, stagione: String;
   Credit_address, Readdress, Page, Page_footer: String;
   film_o_serieName, ArtistName, firstcall, name, autori: String;
   Formato, Releases, artista: String;
   file_name, campo_URL: String;
   tappo_fine_ricerca: String;
   tipo_ricerca, pag_ricerca, save_value, ordine_lista, Salva_autore: String;
   value, episodi, lista_episodi: string;
   CharNormal, CharAbNormal: string;
   film_o_serie_ok: boolean;
   cerca_ancora: boolean;
   BatchMode, giri, PosBar: Integer;
   titolo_e_autore, titolo, autore, durata, cover: String;
   save_comments, commento_episodi, commento_skeda: String;
   save_description, save_desc_skeda, save_desc_episodi: String;
   batchlog, confbatch: TstringList;
   save_pag, artist, initchar, endchar: string;
   film_o_serieok: boolean;

//*********************inizio variabile per ricerca google ********************
   Address, Address_all, urlmusic, album, albumtest, genre: String;
   Save_address, Title_album, indir_album, indir_title_album, campo_pick: String;
   dati_album, init_control, end_control, init_ol, end_ol: String;
   str_loop, Desc_ricerca: String;
   ctr_loop: integer;
   found: boolean;
   i, lgth_tappo, lgth_dati_album, lgth_Pag_ricerca: integer;
//***********************fine variabile per ricerca google ********************

//------------------------------------------------------------------------------
// list of film_o_series
//------------------------------------------------------------------------------
procedure GetList;   
begin
   PickTreeClear;                                                    // clear list
   ctr_loop := 0;
   desc_ricerca := file_name;
   if desc_ricerca = '' then
      desc_ricerca := film_o_serieName;
//            'https://www.google.com/search?q=star+trek+discovery+site%3Awww.comingsoon.it&ie=utf-8&oe=utf-8'
//   Address := Address + '&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all';
//   Address := Address + '&as_sitesearch=www.comingsoon.it&as_occt=any&safe=images&as_filetype=&as_rights=';
//   Address := 'https://www.google.com/search?q=' + film_o_serieName + ' trama+site%3Awww.comingsoon.it&ie=utf-8&oe=utf-8';           //fs2019-06-12
   Address := 'https://www.google.com/search?q=' + film_o_serieName + '+site%3Awww.comingsoon.it&ie=utf-8&oe=utf-8';           //fs2019-06-12
   Address := UrlEncode(Address);
   Desc_ricerca := 'Lista pagine trovate per  "' + Desc_ricerca + '"';
   PickTreeAdd(Desc_ricerca, '"');
   due_giri;
   Address := textbetween(Page_footer, '<a', '</a>');
   Address := textbetween(Address, 'href="', '"');
   if length(address) > 0 then
      begin
      Address := 'https://www.google.com' + fulltrim(Address);
      due_giri;
      end;
if not found then
   begin
      LogMessage('No album found for ' + Desc_ricerca);
      exit;
   end;
   if PickTreeExec(Address) then
      begin
//      AnalyzeMoviePage(Address);                         // Album page
      AnalyzeMoviePage;                                    // Album page
      end
   else
      LogMessage('No serie/film selected');
// ---------------------------------------
end;

procedure due_giri;
begin
   Page := GetPage(Address);
   Page := UTF8decode(Page);                         //2019.01.28 FS accenti
   Save_address := Address;
   SetField(fieldURL, Address);
   HTMLdecode(Page);
   if debug_search then
      DumpPage(folder+'googleListPage.html', Page);                // debug

   found := True;
//   Desc_ricerca := 'Lista pagine trovate per  "' + Desc_ricerca + '"';
//   PickTreeAdd(Desc_ricerca, '"');
   if debug_search then
      DumpPage(folder+'comingsoonList.txt', Page);                // debug
   if Pos('find anything', Page) <> 0 then
   begin
      LogMessage('Error while reading selection page - no results found for ' + Desc_ricerca);
      Found := False;
      exit;
   end;

   init_ol := '</head>';                        //2015-11-25
   end_ol  := '</body>';
   init_control := '<a href="/url?q=https://www.comingsoon.it/';     //2016-02-10
   end_control := '<a href="/url?q=https://www.comingsoon.it/';      //2016-02-10
   tappo_fine_ricerca := init_control + 'Tappodifinericercadaticongoogle' + end_control;    //2019-06-07
   pag_ricerca := TextBetween(Page, init_ol, end_ol) + tappo_fine_ricerca + end_ol;  //elenco titoli richiesti e tappo ricerca
   page_footer := TextAfter(Page, '<footer>');
   lgth_Pag_ricerca :=  length(Pag_ricerca);
   if debug_search then
      DumpPage(folder+'googlericerca.html', pag_ricerca);                // debug

   save_pag := pag_ricerca;
   pag_ricerca := init_control + textAfter(pag_ricerca, init_control);
   lgth_tappo := length(tappo_fine_ricerca);
   dati_album := TextBetween (pag_ricerca, init_control, end_control);
   dati_album := init_control + dati_album + end_control;
//dati_album contiene recursivamente i dati delle pagine referenziate da google
   lgth_dati_album := length(dati_album);
   ctr_loop := ctr_loop + 1;
   str_loop := inttostr(ctr_loop);
   if debug_search then
      DumpPage(folder+'google_dati_album' + str_loop + '.html', dati_album);                // debug
   delete(Pag_ricerca, 1, (lgth_dati_album - length(end_control)));
   lgth_Pag_ricerca :=  length(Pag_ricerca);
   if debug_search then
      DumpPage(folder+'googlericerca-1.html', Pag_ricerca);

//****************** loop ricerca indirizzi *****************************
   cerca_ancora := false;
   if lgth_dati_album > (length(init_control) + length(end_control)) then
      cerca_ancora := true;
   while cerca_ancora  do                 //estraggo fino al tappo di fine ricerca
      begin
      initchar := 'https://';       //2017-01-04
      endchar  := '>';
      
// ******************** estrazione indirizzo *******************
      Address  := textBetween(dati_album, initchar, endchar);
      if length(address) < 1 then
          begin
          initchar := 'http://';       //2017-01-04
          Address  := textBetween(dati_album, initchar, endchar);
          end;
      initchar := 'https://';       //2017-01-04
      endchar  := '">';
      Address  := textBetween(dati_album, initchar, endchar);
      if length(address) < 1 then
          begin
          initchar := 'http://';       //2017-01-04
          Address  := textBetween(dati_album, initchar, endchar);
          end;
      Address  := 'https://' + Address;                // debug    fino al 2019-06-05 OK
      Address_all := Address;
      Address := textBefore(Address_all, '/&sa', '');
      if length(Address) = 0 then
         Address := textBefore(Address_all, '/%252', '');
// *************** fine estrazione indirizzo *******************

      initchar := '<div class="';
      endchar  := '</div>';
      Title_album  := textBetween(dati_album,initchar, endchar) + endchar;              //descrizione del link
      initchar := '">';
      endchar  := '</div>';
      Title_album  := textBetween(Title_album,initchar, endchar);              //descrizione del link
      HTMLRemoveTags(Title_album);
//      Title_album := copy(Title_album, 1, 42);
//fs2017-11-01    test se serie o scheda (film e serie TV)
//fs2019.06.12     if (pos('/scheda', Address) > 0) or (pos('/serie', Address) > 0) then
      Address := Address + '/';
      if (pos('/anticipazioni/', Address) = 0)
          and (pos('/foto/', Address) = 0)
          and (pos('/games/', Address) = 0)
          and (pos('/gossip/', Address) = 0)
          and (pos('/news/', Address) = 0)
          and (pos('/personaggi/', Address) = 0)
          and (pos('/speciali/', Address) = 0)
          and (pos('/sport/', Address) = 0)
          and (pos('/streaming/', Address) = 0)
          and (pos('/video/', Address) = 0)
          then begin
//          Address := copy(Address, 1, length(Address) - 1);
          campo_pick := Title_Album + Address;
//          if length(campo_pick) > 2 then     //perchè ho aggiunto '/' a fine indirizzo
          if length(campo_pick) > (length(Title_album) + 1) then     //perchè ho aggiunto '/' a fine indirizzo
             begin
             PickTreeAdd(Title_Album, Address);
             found := True;
             end;
      end;
//2016-02-10   init_control := '<li class="g">';
//2016-02-10   end_control := '<li class="g">';
//      init_control := '<div class="g">';           //2019-06-07
//      end_control := '<div class="g">';            //2019-06-07
      dati_album := init_control + TextBetween (pag_ricerca, init_control, end_control) + end_control;
      lgth_dati_album := length(dati_album);
      delete(Pag_ricerca, 1, (lgth_dati_album - length(end_control)));
      lgth_Pag_ricerca := length(Pag_ricerca);

      ctr_loop := ctr_loop + 1;
      str_loop := inttostr(ctr_loop);
      if debug_search then
         DumpPage(folder+'google_dati_album' + str_loop + '.html', dati_album);                // debug

       cerca_ancora := false;
       if lgth_dati_album > (length(tappo_fine_ricerca)) then
          cerca_ancora := true;
   end;
//************* fine loop ricerca indirizzi *****************************
end;

//------------------------------------------------------------------------------
// ANALYZE Movie PAGE
//------------------------------------------------------------------------------
procedure AnalyzeMoviePage;
var
   urlmusic, Lenght, Pays: String;
   Autore, style, Commenti, str_min, campo_note: String;
   minu, minuti, ore, lgth_comm, save_lgth_comm, i: integer;
   j: Real;
begin
   if pos('/film/', Address) > 1              //fs2017-10-29
      then begin
           stagione := '';
//           tipo_ricerca := 'sk ep';
           estrazione_film(Address);
           exit;
      end

   if pos('/scheda', Address) > 1
      then begin
           stagione := '';
           tipo_ricerca := 'sk ep';
      end
      else if pos('/episodi', Address) > 1
              then begin
                   tipo_ricerca := 'ep sk';
//                   stagione := ' (' + (textbetween(Address,'/episodi/',   '/') + ')';
                   stagione := ' (' + (textafter(Address, '/episodi/') + ')';
              end
              else begin
                  ShowMessage('indirizzo di estrazione non appropriato. Né scheda né episodi!');
                  exit;
              end;
    save_comments    := '';
    commento_episodi := '';
    commento_skeda   := '';
   if tipo_ricerca = 'sk ep' then
      begin
      estrazione_scheda;
      save_comments := commento_skeda + CRLF + commento_episodi;                     //quiFS2017
      SetField(fieldcomments, save_comments);     // commenti + elenco episodi           end
      save_description := save_desc_skeda;
      SetField(fieldDescription, save_description);

      end
   if tipo_ricerca = 'ep sk' then           // inizio variazioni fs2016-11-17
      begin
//      estrazione_episodi(Address);
      estrazione_episodi;
      save_comments := commento_skeda;                        // + commento_episodi;
//      SetField(fieldcomments, save_comments);     // commenti + elenco episodi           end
      SetField(fieldDescription, commento_episodi);
      save_description := save_desc_skeda + CRLF + commento_episodi;
//      SetField(fieldDescription, save_description);
      SetField(fieldComments, save_desc_skeda);
   end
end;

//------------------------------------------------------------------------------
// ESTRAE INFORMAZIONI DA SCHEDA + EPISODI SE E' UNA SERIE
//------------------------------------------------------------------------------
procedure estrazione_scheda;
begin
   Page := GetPage(Address);
   Page := UTF8decode(Page);
   HTMLdecode(Page);
   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonPageDetail.txt', Page);                         // debug_film_o_serie
//   HTMLdecode(Page);

   if (BatchMode = 0)  and (tipo_ricerca = 'sk ep') then
      SetField(fieldURL, Address);
   campo_URL := getfield(fieldurl);
   SetField(fieldDate, DateToStr(Date));
//   Normalizza_Page(Page);
   film_o_serieok := True;

   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonPageDetailHTMLdecode.html', Page);               // debug_film_o_serie
   Value := Page;

//*** cover       locandina jpg
   cover := TextBetween(value, '<link rel="image_src" href="', '">');
//   setfield(fieldborrower, cover);
   if tipo_ricerca = 'sk ep' then
      GetPicture(cover);

//   if length(Getfield(fieldtranslatedTitle)) < 1 then
//      begin
//fs2016-06-26       initchar := '<h1 itemprop="name" class="titolo scheda col-sm-10">';
       initchar := '<h1 class="titolo scheda col-sm-10">';        //fs2016-06-26
       endchar :=  '</h1>';
       label := textbetween(Value, initchar, endchar);
       label := label + stagione;
       if length(label) > 0
          then begin
          label := stringReplace(label, '/', '');
          label := AnsiMixedCase(AnsiLowerCase(Label), ' ');
          SetField(fieldtranslatedTitle, label);
       end;

   label := textbetween(Value, 'Titolo originale: ', '</p>');
   if pos('/scheda', campo_url) > 1  then
      label := label + ' (Serie TV)';
   label := AnsiMixedCase(AnsiLowerCase(Label), ' ');
   SetField(fieldoriginalTitle, label);

//inizio estrazione dati per fielddescription (da save_desk_skeda)
//   estrae-descrizione_vecchia               //FS debug: procedura ante 2019.01.18
//***************************************   estrae_descrizione                       //FS introdotta 2019.01.18
   initchar := '<!-- Trama -->';
   endchar :=  '<!-- Curiosità -->';
   label := TextBetween(Value, initchar, endchar) + endchar;
   initchar := '<div>';
   endchar :=  '</div>';
   label := TextBetween(label, initchar, endchar);
   initchar := '<p>';
   endchar :=  '</p>';
   label := TextBetween(label, initchar, endchar);
   save_desc_skeda := label;

   initchar := '<!-- Curiosità -->';
   endchar :=  '<!-- voci full -->';
   label := TextBetween(Value, initchar, endchar) + endchar;
   initchar := '<h2 class="anchor">';
   endchar :=  '<!-- voci full -->';
   label := TextBetween(label, initchar, endchar) + endchar;
   initchar := '<p>';
   endchar :=  '</p>';
   label := TextBetween(label, initchar, endchar);
   save_desc_skeda := save_desc_skeda + CRLF + label;
   HTMLRemoveTags(save_desc_skeda);

//***************************************   Fine estrae_descrizione                  //FS introdotta 2019.01.18


   initchar := '<span>GENERE</span>:';
   endchar :=  '</li>';
   label := TextBetween(value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
//   label := fulltrim(label);
   SetField(fieldcategory, label);

   initchar := '<li><span>REGIA</span>: ';
   endchar :=  '</li>';
   label := TextBetween(value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   SetField(fieldDirector, label);

   initchar := '<li><span>ATTORI</span>:';
   endchar :=  '</li>';
   label := initchar + TextBetween(Value, initchar, endchar) + endchar;
   HTMLRemoveTags(label);
   label := stringReplace(label, 'ATTORI: ', '');
   SetField(fieldactors, label);

   initchar := '<li><span>ANNO</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldyear, label);

   initchar := '<li><span>PAESE</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldcountry, label);

   initchar := '<li><span>PRODUZIONE</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldproducer, label);

   initchar := '<li><span>IDEATORE</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldwriter, label);

   initchar := '<li><span>DURATA</span>: ';
   endchar :=  ' Min</meta></li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   SetField(fieldlength, label);

// commenti_ le serie contengono anche l'elenco episodi //
   Value := stringReplace(Value, '>CURIOSITÀ:<', '>Curiosità:<');      //quiFS2017
   initchar := '<div class="h5 pad-tlr-18">Curiosità:</div>';
   endchar :=  '</div>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   commento_skeda := label;
//   save_comments := label;
   
   if tipo_ricerca = 'sk ep' then
      begin
//    per le serie, aggiungo l'elenco episodi
      initchar := '<nav class="col-xs-12 tab-menu tab-12 serietv">';
      endchar  := '</nav>';
      label := Textbetween(Value, initchar, endchar);
      initchar := '<li class="item1"><a href="';
      endchar  := '">';
      label    := Textbetween(label, initchar, endchar);
      if length(label) > 0 then
         begin
         label := 'https://www.comingsoon.it' + label;
         Address := label;
         estrazione_episodi(Address);
         save_comments := commento_skeda + CRLF + commento_episodi;
//         SetField(fieldcomments, save_comments);     // commenti + elenco episodi
         end;
      end
end;

//-----------------------------------
// ESTRAE INFORMAZIONI DA SCHEDA Film
//-----------------------------------
procedure estrazione_film;
begin
   Page := GetPage(Address);
//****************************************
   PosBar := AnsiLastPosEx('/scheda', Address, true, true);
   if PosBar = 0 then
      begin
        showmessage('Questa non è la scheda di un film!          Riprova.');
        exit;
      end
//****************************************


   Page := UTF8decode(Page);
   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonFilm.txt', Page);                         // debug_film_o_serie
   HTMLdecode(Page);

   if (BatchMode = 0) then
      SetField(fieldURL, Address);
   campo_URL := getfield(fieldurl);
   SetField(fieldDate, DateToStr(Date));
//   Normalizza_Page(Page);                  //fs2017-10-31  appesantisce l'esecuzione!
   film_o_serieok := True;

   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonPageDetailHTMLdecode.txt', Page);               // debug_film_o_serie
   Value := Page;

//*** cover       locandina jpg
   cover := TextBetween(value, '<link rel="image_src" href="', '">');
   if pos('def_ico.gif', cover) = 0 then
      GetPicture(cover);

   initchar := '<h1 itemprop="name" class="titolo scheda col-sm-10">';        //fs2016-06-26
   endchar :=  '</h1>';
   label := textbetween(Value, initchar, endchar);
   label := AnsiMixedCase(AnsiLowerCase(Label), ' ');
   SetField(fieldtranslatedTitle, label);

   label := textbetween(Value, 'Titolo originale: ', '</p>');
   label := AnsiMixedCase(AnsiLowerCase(Label), ' ');
   SetField(fieldoriginalTitle, label);

   initchar := '<div class="contenuto-scheda-destra col-xs-8">';
   endchar :=  '<div class="box-descrizione">';
   label := TextBetween(Value, initchar, endchar) + endchar;
   initchar := '<!-- Paragrafo -->';
//   label := TextBetween(label, initchar, endchar);     // era per solo serie
   label := TextAfter(label, initchar);                  //sia serie che film
   initchar := '<p>';
   endchar :=  '</p>';
   label := TextBetween(label, initchar, endchar);
   label := stringReplace(label, '<strong>', ' $%&$%&$%&');

   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   label := stringReplace(label, ' $%&$%&$%&', CRLF);      //se presenti descrizioni di serie multiple
   label := stringReplace(label, '$%&$%&$%&', '');         //eventuale prima riga della descrizione
   save_desc_skeda := label;

   initchar := '<span>GENERE</span>:';
   endchar :=  '</li>';
   label := TextBetween(value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
//   label := fulltrim(label);
   SetField(fieldcategory, label);

   initchar := '<li><span>REGIA</span>: ';
   endchar :=  '</li>';
   label := TextBetween(value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   SetField(fieldDirector, label);

   initchar := '<li><span>ATTORI</span>:';
   endchar :=  '</li>';
   label := initchar + TextBetween(Value, initchar, endchar) + endchar;
   HTMLRemoveTags(label);
   label := stringReplace(label, 'ATTORI: ', '');
   SetField(fieldactors, label);

   initchar := '<li><span>ANNO</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldyear, label);

   initchar := '<li><span>PAESE</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldcountry, label);

   initchar := '<li><span>PRODUZIONE</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldproducer, label);

   initchar := '<li><span>MUSICHE</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldcomposer, label);

   initchar := '<li><span>SCENEGGIATURA</span>: ';
   endchar :=  '</li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   SetField(fieldwriter, label);

   initchar := '<li><span>DURATA</span>: ';
   endchar :=  ' Min</meta></li>';
   label := TextBetween(Value, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   SetField(fieldlength, label);

// descrizione       fielddescription
   endchar := '</div>';
   label := textbetween(Value, '<div class="box-descrizione show">', endchar) + endchar;      //fs2017-10-29
   label := textbetween(label, '</h2>', '</div>');      //fs2017-10-29
   HTMLRemoveTags(label);
   label := FormatText(label);
   SetField(fielddescription, label);

// commento       fieldcomments
   initchar := '<!-- Critica -->';
   endchar := '</div>';
   label := textbetween(Value, initchar, endchar) + endchar;      //fs2017-10-29
   label := textbetween(label, '</h2>', '</div>');      //fs2017-10-29
   HTMLRemoveTags(label);
   label := FormatText(label);
   SetField(fieldcomments, label);

end;

//------------------------------------------------------------------------------
// ESTRAE INFORMAZIONI DA EPISODI DI UNA SERIE + SCHEDA DELLA SERIE
//------------------------------------------------------------------------------
Procedure estrazione_episodi;
Begin
   Page := GetPage(Address);
   Page := UTF8decode(Page);
   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonepisodes.txt', Page);            // debug_film_o_serie
   HTMLdecode(Page);
//*** cover   locandina jpg
   cover := TextBetween(Page, '<link rel="image_src" href="', '">');
   if tipo_ricerca = 'ep sk' then
      GetPicture(cover);

   if (BatchMode = 0)  and (tipo_ricerca = 'ep sk') then
      SetField(fieldURL, Address);
   campo_URL := getfield(fieldurl);
   initchar := '<div class="articoli-piu-recenti-xl box-main" id="box-lista-episodi-serietv" role="tablist">';
   endchar  := '<div class="box-share-tasti-sociali">';
   Value  := initchar + TextBetween(Page, initchar, endchar) + endchar;
   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonepisodesExtr.txt', Value);            // debug_film_o_serie
   Value := StringReplace(Value, '<div class="col-sm-6 titolo">', '$%&$%&$%&');

// formatta episodi //
//1. Sotto assedio        (A'ohe Kahi e Pe'e Ai) - REGIA: Bryan Spicer       - SCENEGG.: Peter M. Lenkov, Ken Solarz.......
   Value := stringReplace(Value, '<div class="col-sm-6 descrizione">',           '<div class="col-sm-6 descrizione">seispazi (');
//   Value := stringReplace(Value, '<li class="h6 anno"><strong>REGIA',            '<li class="h6 anno"><strong>)seispazi   - REGIA');
   Value := stringReplace(Value, '<li class="h6 anno"><strong>REGIA',            '<li class="h6 anno"><strong>)   - REGIA');
   Value := stringReplace(Value, '<li class="h6 anno"><strong>SCENEGGIATURA',    '<li class="h6 anno"><strong>      - SCENEGG.');
   Value := stringReplace(Value, '<li class="h6 anno"><strong>TRAMA</strong>: ', '<li class="h6 anno"><strong>$%&$%&$%&TRAMA</strong>: ');
//   Value := stringReplace(Value, '       )', ')');

   initchar := '<li class="h6 anno"><strong>DURATA';
   endchar  := '</li>';
   durata:= initchar + TextBetween(Value, initchar, endchar) + endchar;
   while length(durata) > (length(initchar) + length(endchar))    do
     begin
        durata:= initchar + TextBetween(Value, initchar, endchar) + endchar;
        Value := stringReplace(Value, durata, '');    // elimino durata dei singoli episodi
     end;
// fine formatta episodi //

   HTMLRemoveTags(Value);
   if debug_film_o_serie  then
      DumpPage(folder+'comingsoonepisodesExtr.txt', Value);            // debug_film_o_serie
   value := FormatText(value);
   Value := StringReplace(Value, CRLF, '');
   Value := stringReplace(Value, '$%&$%&$%&', CRLF);
   Value := stringReplace(Value, 'seispazi', '      ');         //eventuale prima riga della descrizione
   Value := stringReplace(Value, '        )', ')');
   Value := stringReplace(Value, '        ', '   ');
   Value := stringReplace(Value, '          ', '');
   commento_episodi := Value;                                   //fs2016-11-17

//fs 2016-06-02 -------------- aggiungo commenti per la serie ----------------------------------
// commenti_ le serie contengono anche l'elenco episodi //
   Page := stringReplace(Page, '>CURIOSITÀ:<', '>Curiosità:<');
   initchar := '<div class="h5 pad-tlr-18">Curiosità:</div>';
   endchar :=  '</div>';
   label := TextBetween(Page, initchar, endchar);
   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   commento_episodi := commento_episodi + CRLF + label;
//   save_comments := label;
//fine fs 2016-06-02 ------------------------------------------------

   if tipo_ricerca = 'ep sk' then
      begin
//    per le serie, aggiungo l'elenco episodi
      initchar := '<nav class="col-xs-12 tab-menu tab-12 serietv">';
      endchar  := '</nav>';
      label := Textbetween(Page, initchar, endchar);
      initchar := '<li class="item1"><a href="';
      endchar  := '">';
      label    := Textbetween(label, initchar, endchar);
      label    := Textbefore(label, '"', '');                      //fs 2017-10-26
      if length(label) > 0 then
         begin
         label := 'https://www.comingsoon.it' + label;
         Address := label;
         estrazione_scheda;
         end;
      end


end;
// ********************* fine estrazione episodi *****************************************

Procedure Normalizza_page(Pagina: string);    // elimina i crlf, trasforma delimiters maiuscoli in minuscoli
begin
  pagina := RegExprSetReplace('<([^>]+)>', pagina, '<\L\1>', true);
  CharAbNormal := crlf;
  CharNormal := ' ';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '<B';
  CharNormal := '<b';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '</B';
  CharNormal := '</b';
  pagina := StringReplace(Value, CharAbNormal, CharNormal);
  CharAbNormal := '<FONT';
  CharNormal := '<font';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '</FONT';
  CharNormal := '</font';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '<TR';
  CharNormal := '<tr';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '</TR';
  CharNormal := '</tr';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '<TD';
  CharNormal := '<td';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '</TD';
  CharNormal := '</td';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '<DIV';
  CharNormal := '<div';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '</DIV';
  CharNormal := '</div';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '<Ol';
  CharNormal := '<ol';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
  CharAbNormal := '</Ol';
  CharNormal := '</ol';
  pagina := StringReplace(pagina, CharAbNormal, CharNormal);
end;

//------------------------------------------------------------------------------
// set show warning (normal mode) or add to log (batch mode)
//------------------------------------------------------------------------------
procedure LogMessage(m: string);
begin
   if BatchMode > 0 then
      AddToLog('item '+GetField(fieldNumber)+': '+m)
   else
      ShowWarning(m);
end;

//------------------------------------------------------------------------------
// add a message in the batch log and save to disk
// (because I don't know when it's finished...)
//------------------------------------------------------------------------------
procedure AddToLog(m: string);
begin
//fs2016-12-31    batchlog.Add(m);
//fs2016-12-31    batchlog.SaveToFile(batchlogfic);
end;

//------------------------------------------------------------------------------
// process batch mode
//------------------------------------------------------------------------------
procedure comingsoonBatch;
begin
   film_o_serieName := GetField(fieldUrl);                      // if no url or another site then ignore
   if (film_o_serieName <> '') and (Pos(UrlBase, film_o_serieName) > 0) then
      AnalyzeMoviePage(film_o_serieName)
   else
      LogMessage('ignored url="'+film_o_serieName+'"');
end;   

//------------------------------------------------------------------------------
// process normal mode
//------------------------------------------------------------------------------
procedure comingsoonNorm;
begin
   film_o_serieok := False;
   file_name:= getField(fieldfilepath);
   if  (file_name <> '') and (pos('\', file_name) = 0) then
       film_o_serieName := file_name
   else
       if (GetField(fieldTranslatedTitle) <> '') then							//mrobama
          film_o_serieName := GetField(fieldTranslatedTitle)          // get film_o_serie name
     else													//mrobama
          film_o_serieName := GetField(fieldOriginalTitle);							//mrobama
// get film_o_serie name//fs20160205   ArtistName := getField(fieldOriginalTitle);                   // get artist

   repeat
    if not Input('comingsoon = ' + ArtistName + ' - ' + film_o_serieName, 'Scrivi il nome del film o della serie:'
        + crlf, film_o_serieName) or (film_o_serieName = '') then exit;
    formato := getfield(FieldOriginalTitle);
    if pos(formato, 'serie') > 0 then
       formato:= 'serie';
    GetList;
       until film_o_serieok;
end;

Procedure estrae_descrizione_vecchia;
begin
   initchar := '<div class="contenuto-scheda-destra col-xs-8">';
   endchar :=  '<div class="box-descrizione">';
   label := TextBetween(Value, initchar, endchar) + endchar;
   initchar := '<!-- Paragrafo -->';
//   label := TextBetween(label, initchar, endchar);     // era per solo serie
   label := TextAfter(label, initchar);                  //sia serie che film
   initchar := '<p>';
   endchar :=  '</p>';
   label := TextBetween(label, initchar, endchar);
   label := stringReplace(label, '<strong>', ' $%&$%&$%&');

   HTMLRemoveTags(label);
   label := FormatText(label);
   label := stringReplace(label, CRLF, '');
   label := stringReplace(label, ' $%&$%&$%&', CRLF);      //se presenti descrizioni di serie multiple
   label := stringReplace(label, '$%&$%&$%&', '');         //eventuale prima riga della descrizione
   save_desc_skeda := label;
end;

//------------------------------------------------------------------------------
//  start here
//------------------------------------------------------------------------------                                             
begin
      if not CheckVersion(4,2,2) then
      begin
         ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 4.2.1)');
         exit;
      end;   
// get user's parms (used more than once)
      BatchMode := GetOption('Mode');
// *********************************************************************
      if BatchMode = 1 then                                
          comingsoonBatch;
      if BatchMode = 0 then
          comingsoonNorm;

end.

Re: [UPD ITA] comingsoon.it

Posted: 2019-06-21 12:36:09
by antp
Thanks :)

Re: [UPD ITA] comingsoon.it

Posted: 2019-07-17 18:57:45
by otreux
thanks but error linea 237 :(

Re: [UPD ITA] comingsoon.it

Posted: 2019-07-22 06:56:30
by fulvio53s03
errore a parte, il lay-out del sito è cambiato completamente e comunque non si estrae nessuna informazione.
a fine estate conto di adeguare lo script, se nessun altro lo farà nel frattempo.

error aside, the layout of the site has changed completely and in any case no information is extracted.
at the end of the summer I plan to adapt the script, if no one else will do it in the meantime.
;) :)

Re: [UPD ITA] comingsoon.it

Posted: 2019-07-24 19:06:24
by otreux
i dream that you can do it ;)

Re: [UPD ITA] comingsoon.it

Posted: 2019-09-26 11:16:32
by otreux
any news? :)

Re: [UPD ITA] comingsoon.it

Posted: 2019-10-14 05:35:39
by fulvio53s03
inizio oggi a cercare una soluzione.
:up: