filmaffinity 3.02

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: filmaffinity 3.02

Post by antp »

It seems that Indy 9 does not support TLS v1.1/1.2, hence the problems on some sites.
Indy 10 seems to still support all Delphi versions since the 5th, so no problem for our old Delphi 7, so it would probably be possible to replace Indy 9 by Indy 10.
The weird thing is that there is no stable version since a super old 10.0.52 version, so I guess I'll have to try with the current development version.
Alternatively I could make a DLL in C#/.NET and call it from the Delphi code, but that would probably require much more work than just trying to upgrade the Indy library used.
Well, as I said, I'll try to work on that after I finished moving my other site to the new server (the forum works in HTTS now, btw :D), sorry for the delay but at least the program is not abandoned ;) I just hope I'll be able to recompile everything on my PC, since all versions since 3.6 were built by soulsnake.
Altober
Posts: 19
Joined: 2018-03-03 19:20:36

Re: filmaffinity 3.02

Post by Altober »

antp wrote: 2018-03-08 17:15:37 Worse case scenario: we can use an external tool to download pages instead of the GetPage function.
There was a solution like that for another script, using the "curl" program. I'll maybe check if I can either use that or make a quick similar tool to distribute with AMC if I can't easily fix it in AMC's code.
But it will probably be for the next month, as currently the free time allowed to my soft & web projects is for the migration of the server, which is done for antp.be (except HTTPS not yet configured and errors when displaying some old topics), but still to do for imcdb.org
You registered on the new forum, but until a few days ago this forum was still running on an old version of phpbb2, I had to update it to move to the new server :D
Undertand, antp, thanks in advance.
We expect news about this problem...
Thanks

Edit:
I just read the news!!

Very thanks for work on fix for this problem...
Unfortunately I am not a programmer, I have knowledge in graphic design only.
I would gladly try to help, but about Delphi, C, C++, etc I'm a big donkey :shaking:
mikeman
Posts: 1
Joined: 2018-03-09 18:39:37

Re: filmaffinity 3.02

Post by mikeman »

I really hope this helps to solve the problem quickly;

https://stackoverflow.com/questions/187 ... elphi-2006

I think the problem is in the Indy version used which don't support SSLv2 or 3 or if it supports it that the option "SSLIOHandlerSocket.SSLOptions.Method " in the file "getscript.pas" would be "sslvSSLv23" or something else.

thanks.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: filmaffinity 3.02

Post by antp »

Yes it is due to the old version of Indy, as I only have TLSv1 and not the higher ones (and SSLv2/3 are older than TLS, cf wikipedia).
I hope that upgrading to the latest version of Indy will work and solve the problem.
maravic
Posts: 9
Joined: 2017-05-29 10:09:43

Re: filmaffinity 3.02

Post by maravic »

Muchas gracias por el esfuerzo, esperamos que prontamente se pueda utilizar nuevamente el sitio filmaffinity, dado que es el más completo en español.
Muchas Gracias Nnuevamente y quedamos a la espera... Saludos!
fulvio53s03
Posts: 744
Joined: 2007-04-28 05:46:43
Location: Italy

Re: filmaffinity 3.02

Post by fulvio53s03 »

antp wrote: 2018-03-09 20:10:41 Yes it is due to the old version of Indy, as I only have TLSv1 and not the higher ones (and SSLv2/3 are older than TLS, cf wikipedia).
I hope that upgrading to the latest version of Indy will work and solve the problem.
Please, Do you think it will be possible in a little time?
:??: :clapping:
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: filmaffinity 3.02

Post by antp »

Cf my earlier posts, depends on the time I'll have left this month after I finish moving my other site to the new server (that I must finish within the next two weeks). In worse case AMC will be for first half of April if I don't find time for it in these next weeks.
fulvio53s03
Posts: 744
Joined: 2007-04-28 05:46:43
Location: Italy

Re: filmaffinity 3.02

Post by fulvio53s03 »

Many Thanks.
In Ant We Trust!
:clapping: :grinking:
masterchipo
Posts: 99
Joined: 2010-02-22 23:15:05

Re: filmaffinity 3.02

Post by masterchipo »

Gracias antp
antp wrote: 2018-03-09 21:20:06 Cf my earlier posts, depends on the time I'll have left this month after I finish moving my other site to the new server (that I must finish within the next two weeks). In worse case AMC will be for first half of April if I don't find time for it in these next weeks.
Altober
Posts: 19
Joined: 2018-03-03 19:20:36

Re: filmaffinity 3.02

Post by Altober »

antp wrote: 2018-03-09 21:20:06 Cf my earlier posts, depends on the time I'll have left this month after I finish moving my other site to the new server (that I must finish within the next two weeks). In worse case AMC will be for first half of April if I don't find time for it in these next weeks.
Many Thanks!!!
PinkFloyd
Posts: 11
Joined: 2014-05-20 13:41:12

Re: filmaffinity 3.02

Post by PinkFloyd »

Thank you very much.
saintwolf
Posts: 4
Joined: 2011-11-08 10:14:02
Location: Spain
Contact:

Re: filmaffinity 3.02

Post by saintwolf »

Thanks, I appreciate it!
Looking forward to keep using this awesome program.
marcosblink
Posts: 3
Joined: 2018-01-24 20:03:50

Re: filmaffinity 3.02

Post by marcosblink »

[quote=antp post_id=43018 time=1520630406 user_id=2]
Cf my earlier posts, depends on the time I'll have left this month after I finish moving my other site to the new server (that I must finish within the next two weeks). In worse case AMC will be for first half of April if I don't find time for it in these next weeks.
[/quote]

Thanks!! :clapping: :clapping:
JuanRa_007
Posts: 21
Joined: 2014-06-08 09:08:31

Re: filmaffinity 3.02

Post by JuanRa_007 »

antp wrote: 2018-03-09 21:20:06 Cf my earlier posts, depends on the time I'll have left this month after I finish moving my other site to the new server (that I must finish within the next two weeks). In worse case AMC will be for first half of April if I don't find time for it in these next weeks.
Thanks!!! Do not forget us !!! :innocent: :clapping: :clapping:
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: filmaffinity 3.02

Post by antp »

If all goes well I'll maybe have a little time in end of next week (I should finish with the server migration this weekend, it goes well), or else that will be for first half of April as said previously.
mrobama
Posts: 85
Joined: 2009-04-03 12:34:34

Re: filmaffinity 3.02

Post by mrobama »

Hi all, I wrote a little workaround for developers. In this way, we can test our script also on https, so when the patch will be ready we can release our scripts. Of course, I'm waiting for new AMC version with https fixed, in the meanwhile I will use my patch.

My workarounds works in this way:
- create an index.php file on a web server (also localhost is ok if you use apache or xampp ...)
- include my unit in your script (update ProxyUrl const and write the full url of your index.php)
- in your script replace all occurrencies of GetPage and GetPicture with getPageLegacy and getPictureLegacy

This is a dirty workaround to transform https to http using this simple "proxy", I haven't tested it too much and you could add some security checks (url allowed in index.php, ...)

This is the index.php file I created

Code: Select all

<?php
$opts = array('http' =>
    array(
        'follow_location' => 1,
    )
);
$context = stream_context_create($opts);
$html = @file_get_contents($_GET['url'], false, $context);
if (is_array($http_response_header) && count($http_response_header))
	foreach($http_response_header as $header)
		if (strpos($header, 'Location:') === FALSE)
			header($header);
die($html);
This is the HttpsLegacy.pas unit I created, remember to update ProxyUrl

Code: Select all

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

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

[Infos]
Authors=
Title=HttpsLegacy.pas
Description=
Site=
Language=?
Version=
Requires=4.2.1
Comments=
License=
GetInfo=0

[Options]

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

{
  PLEASE READ THIS BEFORE USING THIS UNIT:
  1. Create the php file in your hosting (you can find it on antb forum), call it index.php (or any other filename you like)
  2. Update the above ProxyUrl constant to match the hosting url (example: http://localhost/index.php?url=  or http://myhostingsite.ext/index.php?url= )
  3. Add this unit to your script and replace all occurrencies of GetPage and GetPicture with GetPageLegacy and GetPictureLegacy
  
  index.php file:
 

 
	<?php
	$opts = array('http' =>
		array(
			'follow_location' => 1,
		)
	);
	$context = stream_context_create($opts);
	$html = @file_get_contents($_GET['url'], false, $context);
	if (is_array($http_response_header) && count($http_response_header))
		foreach($http_response_header as $header)
			if (strpos($header, 'Location:') === FALSE)
				header($header);
	die($html);  
 
}

{  
  This file was created by MrObama.
}  

{
  History
  -------
  v.1:  Added getPageLegacy, getPictureLegacy, simplifiedURLEncode
}

unit HttpsLegacy;

const
  HttpsLegacy_Version = 1;
  ProxyUrl = 'http://localhost/index.php?url='; // UPDATE THIS URL!!!

var
  newVersion: boolean;

function simplifiedURLEncode(str: string): string;
var new: string;
begin
  new := str;
  new := StringReplace(new, '%', '%25');
  new := StringReplace(new, ':', '%3A');
  new := StringReplace(new, ';', '%3B');
  new := StringReplace(new, '/', '%2F');
  new := StringReplace(new, '&', '%26');
  new := StringReplace(new, '#', '%23');
  new := StringReplace(new, '-', '%2D');
  new := StringReplace(new, '=', '%3D');
  new := StringReplace(new, '?', '%3F');
  new := StringReplace(new, '@', '%40');
  new := StringReplace(new, '+', '%2B');
  new := StringReplace(new, ' ', '%20');
  new := StringReplace(new, '''', '%27');
  new := StringReplace(new, '\', '%5C');
  new := StringReplace(new, '_', '%5F');
  new := StringReplace(new, '^', '%5E');
  result := new;
end;


function getPageLegacy(Url: string): string;
begin
  if newVersion then
    result := getPage(Url)
  else // old client, proxy workaround for https bug
    result := getPage(ProxyUrl + simplifiedURLEncode(Url));
end;


procedure getPictureLegacy(Url: string);
begin
  if newVersion then
    getPicture(Url)
  else // old client, proxy workaround for https bug
    getPicture(ProxyUrl + simplifiedURLEncode(Url));
end;


begin
  newVersion := CheckVersion(4,2,2);
end.
This is how I used it in MyMovies script

Code: Select all

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

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

[Infos]
Authors=Fulvio53s03  (Original by Claudio Rinaldi & seraphico)
Title=MyMovies
Description=Get movie info from MyMovies.it
Site=www.mymovies.it
Language=IT
Version=2.1
Requires=4.2.1
Comments=
License=
GetInfo=1
RequiresMovies=1

[Options]
Poster=1|0|1=Download full-res Poster|0=Download tiny Poster

[Parameters]

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

program MyMoviesIT;

uses
  Stringutils7552, HttpsLegacy;

const
  UrlBase = 'http://www.mymovies.it';
  UrlRicerca = '&titolo_orig=&regista=&attore=&id_genere=-1&nazione=&clausola1=-1&anno_prod=&clausola2=-1&stelle=-1&id_manif=-1&anno_manif=&disponib=-1&ordinamento=1&submit=Inizia+ricerca+%BB';
  QueryBase = UrlBase + '/database/ricerca/avanzata/?titolo=';
  debug_search = true; // debuga mode on/off su ricerca dischi
  folder = 'C:\ProgramData\Ant Movie Catalog\Log\MyMovies\'; // directory where to save files

  ImagePath = UrlBase + '/filmclub/';
  Apice       = #39;
  NoCommento = '(Riceverai le informazioni pochi giorni prima della messa in onda)';  // commenti inutili  "(la recensione più amata dal pubblico)"
  PiuAmata   = '(la recensione più amata dal pubblico)';
  cStartNumRis = 'nel Titolo. Ho trovato '; // Result Number start Marker
  cEndNumRis = ' film.</h3>';               // Result Number end Marker
  cStartId = 'recensione.asp?id=';   // ID start marker
  EndId = '" title="';              // ID end marker
  cStartNewTitle = '<meta property="og:title" content="';
  cEndNewTitle = '"';
  cStartTitle = 'Titolo originale <em>';             // Title start marker
  cEndTitle = '</em>';              // Title end marker
  cStartTranslTitle = '<h1 style="margin-bottom:3px;">';        // Translated title start marker
  cEndTranslTitle = '</h1>';         // Translated title end marker
  cStartImage2 = '<img src="';       // Image start marker
  cEndImage2 = '"';                  // Image end marker
  cStartDirector = 'Un film di <a href="';      // Director start marker
  cEndDirector = '</a>.';                       // Director end marker
  cStartCategory  = '<a title="Film ';   // Catogory start marker
  cEndCategory = '</a>';            // Category first end marker
  cStartCategory2  = '">';   // Catogory start marker
  cEndCategory2 = '</a>';            // Category second end marker
  cStartDuration = 'durata ';        // Duration start marker
  cEndDuration = ' min.';          // Duration end marker
  cStartYear = '<meta property="og:title" content="';              // Year start marker
  cEndYear = '/>';                 // Year end marker
  cStartYear2  = '(';   // year start marker
  cEndYear2 = ')';            // year second end marker
  cStartDesc = '<div id="recensione">';          // Description start marker
  cEndDesc = '<div style="text-align:right;">';  // Description end marker

  cStartCast = 'Con <a href="';              // Actor start marker
  cEndCast   = '<a title="';
  cEndCast2  = 'Titolo originale <em>';      // Actor end marker
  cStartImage = 'src="http://pad.mymovies.it/filmclub/';
  cEndImage = '"';
var
  MovieUrl, MovieName, Commento, TranslatedStr, PageStr:  string;
  Startchar, EndChar, UsePage, Addressnext: String;
  cImage, SaveField, TempField, DelField : string;
  PositionCategory, PositionDuration: integer;
  Positioncast: integer;
  idx : integer;
  
function MyTrim(Value: string):string;
var
  ExitLoop: Boolean;
  NewField, OldField: String;
  OldLgthValue, NewLgthValue: integer;
begin
    NewField := ' ';
    OldField := #9;
    value := StringReplace(Value, OldField, NewField);
    OldField := #10;
    value := StringReplace(Value, OldField, NewField);
    OldField := #13;
    value := StringReplace(Value, OldField, NewField);
    OldField := '  ';
    value := StringReplace(Value, OldField, NewField);
    Newfield := '&';
    OldField := '&';
    value := StringReplace(Value, OldField, NewField);
    Newfield := 'è';
    OldField := '&egrave;';
    value := StringReplace(Value, OldField, NewField);
    ExitLoop := False;
    OldLgthValue := length(Value);
    HTMLRemoveTags(Value);
    Value := FullTrim(Value);
    OldField := '  ';
    NewField := ' ';
    repeat
      value := StringReplace(Value, OldField, NewField);
      NewLgthValue := length(Value);
    if  OldLgthValue = NewLgthValue then
        ExitLoop := True
    else
        OldLgthValue := NewLgthValue;
    until ExitLoop;

  Result := Value;
end;

//-------------------------
procedure estrae_info;          //2017.10.26 cambio struttura sito: aggiunta pagina intermedia tra la ricerca e le info.
//-------------------------
begin
  MovieUrl := textbetween(PageStr, '<!-- webTrekk Espresso -->', '<!-- /webTrekk Espresso -->');
  HTMLRemoveTags(MovieUrl);
  MovieUrl := textbetween(MovieUrl, (' pageHref = ' + Apice), (Apice + ';'));

  PageStr := getPageLegacy(MovieUrl);
   if debug_search then
      DumpPage(folder+'mymovies_pageStr.txt', Pagestr);                // debug
end;



// -----------------------
// ANALYZE MOVIE DATA PAGE
// IN:  none    OUT: set Ant fields
// -----------------------
procedure AnalyzeMoviePage;
var
  BeginPos, EndPos: integer;
begin
  // Get packed title main page
  PageStr := getPageLegacy(MovieUrl);
  
  if debug_search then
     DumpPage(folder+'mymovies_page.html', Pagestr); // debug
  if pos('<!-- webTrekk Espresso -->', PageStr) > 0 then
     begin
        estrae_info
     end;
  if pos('var_carica_taboola', pageStr) > 0
     then
         nuovo_tipo_pagina
     else
         vecchio_tipo_pagina
  end;
//end;

//----------------------------
procedure nuovo_tipo_pagina;
var
  titolo_originale, Trama_e_critica: string;
  init_char, end_char: string;
begin
  TempField := TextBetween(PageStr, cStartNewTitle, cEndNewTitle);
  TempField := MyTrim(TempField);
  SetField(fieldTranslatedTitle, TempField);

  // Original Title field
  titolo_originale := TextBetween(PageStr, 'Titolo originale</td>', '</tr>');
  HTMLRemoveTags(titolo_originale);
  SetField(fieldOriginalTitle, titolo_originale);
  if titolo_originale = '' then
    SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle))
    else
    SetField(fieldOriginalTitle, titolo_originale);

  // Director Field
  TempField := TextBetween(PageStr, '<tr><td valign="top">Regia di</td>', '</tr>');
  HTMLRemovetags(tempfield);
  SetField(fieldDirector, TempField);

  // Actors Field
  TempField := TextBetween(PageStr, '<tr><td valign="top">Attori</td>', '</tr>');
  HTMLRemovetags(tempfield);
  SetField(fieldActors, TempField);            //attori principali

  // Category Field
  TempField := TextBetween(PageStr, '<tr><td valign="top">Genere</td>', '</tr>');
  HTMLRemovetags(tempfield);
  SetField(fieldCategory, TempField);

  // Duration field
  TempField := TextBetween(PageStr, '<tr><td valign="top">Durata</td>', '</tr>');
  HTMLRemovetags(tempfield);
  tempfield := Textbefore(' ', Tempfield, '');
  SetField(fieldLength, TempField);

  // Country field
  TempField := PageStr;
  Tempfield := TextBetween(TempField, '<td valign="top">Produzione</td>', '</tr>') + '</tr>';
//  Tempfield := '<tr> href=' + TextBetween(TempField, 'href=', '</tr>');
  Tempfield := '<tr>' + TextBetween(TempField, 'href=', '</tr>');
  HTMLRemovetags(tempfield);
//  TempField := MyTrim(TempField);
  tempField := textafter(Tempfield, '>');
  SetField(fieldCountry, TempField);

//  Year
  TempField := PageStr;
  TempField := Textbetween (tempField, '<td valign="top">Anno</td>', '</tr>');
  HTMLRemovetags(tempfield);
  SetField(fieldYear, TempField);

  // Get film image
  cImage := TextBetween(PageStr, '<amp-img layout="responsive" class="stonda3" width="230" height="330" src="', '"></amp-img>');
  cImage := StringReplace(cImage, 'https', 'http');

  GetPictureLegacy(cImage);

// Description Field
   init_char := '<strong>Recensione</strong>';
   end_char  := '</p>';
   Trama_e_critica := TextBetween(PageStr, init_char, end_char);
   if debug_search then
      DumpPage(folder+'mymovies_trama_e_critica.txt', trama_e_critica);                // debug
   init_char := '<p class="corpo">';
   end_char  := '<a target="_blank" href="http://www.mymovies.it/pdf/?recensione=';
   Trama_e_critica := TextBetween(Trama_e_critica, init_char, end_char);
   Trama_e_critica := UTF8decode(Trama_e_critica);
   Trama_e_critica := StringReplace(Trama_e_critica, 'Il film ' + GetField(fieldTranslatedTitle) + ' è disponibile in streaming. Scopri MYmovieslive', '');
   Trama_e_critica := StringReplace(Trama_e_critica, 'Questo film è disponibile in versione digitale, scopri il miglior prezzo: TROVASTREAMING', '');
   HTMLRemovetags(Trama_e_critica);
   Trama_e_critica := Fulltrim(Trama_e_critica);
   SetField(fieldDescription, Trama_e_critica);

// Comments Field
   init_char := 'class="corpo citazione mm-blocco-news" style="display: table;"';
   end_char  := '<div class="clear10">';
//   TempField := '<p ' + init_char + textBetween(Trama_e_critica, init_char, end_char) + end_char;
   TempField := '<p ' + textBetween(Trama_e_critica, init_char, end_char);
   TempField := StringReplace(TempField, 'Il film Shadow è disponibile in streaming. Scopri MYmovieslive', '');
   TempField := StringReplace(TempField, 'Questo film è disponibile in versione digitale, scopri il miglior prezzo: TROVASTREAMING', '');
   HTMLRemovetags(tempfield);
   TempField := Fulltrim(Tempfield);
   SetField(fieldComments, TempField);

// Movie URL field
   SetField(fieldURL, MovieUrl);
   SetField(fieldDate, DateToStr(Date));

end;

//----------------------------


//----------------------------
procedure vecchio_tipo_pagina;
//----------------------------
begin
  TempField := TextBetween(PageStr, cStartTranslTitle, cEndTranslTitle);
  TempField := MyTrim(TempField);
  SetField(fieldTranslatedTitle, TempField);

  // Original Title field
  SetField(fieldOriginalTitle, TextBetween(PageStr, cStartTitle, cEndTitle));
  if(GetField(fieldOriginalTitle)='')then
    SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));

  // Director Field
  TempField := TextBetween(PageStr, cStartDirector, cEndDirector) + cEndDirector;
  TempField := TextBetween(TempField, '>' , cEndDirector);
  HTMLRemovetags(tempfield);
  SetField(fieldDirector, TempField);

  // Actors Field
  TempField := CstartCast + TextBetween(PageStr, cStartCast, cEndCast);     // da 'con:'   a Titolo
  Positioncast := pos(cStartCast, PageStr) + length(TempField);
  SaveField := TempField;
  TempField := TextBetween(PageStr, cStartCast, cEndCast2);   // da 'con:'   a Titolo Originale
  if length(tempField) > 0 then
      TempField := '<a href="' + TempField
  else
    TempField := '<a href="' + SaveField;

  DelField  := '<div id="attori_espandi"' + TextBetween(TempField, '<div id="attori_espandi"', '</div>');
  TempField := StringReplace(TempField, DelField, '');
  DelField  := '<div id="attori_comprimi"' + TextBetween(TempField, '<div id="attori_comprimi"', '</div>');
  TempField := StringReplace(TempField, DelField, '');
  TempField := MyTrim(TempField);
  SetField(fieldActors, TempField);

  // Category Field
  TempField := TextBetween(PageStr, cStartCategory, cEndcategory) + cEndcategory;
  TempField := TextBetween(TempField, cStartCategory2, cEndcategory2);
//  TempField := TempField + cEndcategory;
//  TempField := TextBetween(TempField, '">' , cEndcategory);
  SetField(fieldCategory, TempField);

  // Duration field
  TempField := TextBetween(PageStr, '<td valign="top">Durata</td>', '</tr>');
  HTMLRemovetags(tempfield);
  StringReplace(tempfield, ' minuti', '');
  SetField(fieldLength, TempField);

  // Country field
  TempField := PageStr;
  if PositionDuration > 0 then
     Delete(TempField, 1, PositionDuration - 1)
     else
        if  Positioncast > 0 then
            Delete(TempField, 1, Positioncast - 1)
        else
            if  PositionCategory > 0 then
                Delete(TempField, 1, PositionCategory - 1);

  Tempfield := TextBetween(TempField, '-', ' <strong>');
  TempField  := MyTrim(TempField);
  if  pos('Transitional', Tempfield)= 0 then
      SetField(fieldCountry, TempField);

//  Year
  TempField := PageStr;
  TempField := Textbetween (tempField, cStartYear, cEndYear);
//  TempField := Textbetween (TempField, '(', ')');
  TempField := TextBetween(TempField, cStartYear2, cEndYear2);
  SetField(fieldYear, TempField);

  // Get film image
  cImage := TextBetween(PageStr, cStartImage, cEndImage);
  if cImage = '' then
    cImage := TextBetween(PageStr,cStartImage2, cEndImage2)
  else
  begin
    if GetOption('Poster')=1 then
       cImage := ImagePath + StringReplace(cImage, '/imm.jpg', '/locandina.jpg')
    else
       cImage := ImagePath + cImage
    end;


  if cImage <> '' then
    GetPicture(cImage);

// Description Field
   TempField := TextBetween(PageStr, cStartDesc, cEndDesc) + cEndDesc;
   TempField := MyTrim(TempField);
   TempField := StringReplace(TempField, 'Il film Shadow è disponibile in streaming. Scopri MYmovieslive', '');
   TempField := StringReplace(TempField, 'Questo film è disponibile in versione digitale, scopri il miglior prezzo: TROVASTREAMING', '');
   TempField := Fulltrim(Tempfield);
   SetField(fieldDescription, TempField);

// Movie URL field
   SetField(fieldURL, MovieUrl);
   SetField(fieldDate, DateToStr(Date));

// Commento
//   TempField := Textbetween(PageStr, '<p style="padding-right:3px; margin-top:15px;">', '<a href="http://www.mymovies.it/dizionario/critica');
   TempField := Textbetween(PageStr, '">Rassegna stampa</a>', '</td>') + '</td>';
   TempField := Textbetween(TempField, '<p style="padding-right:3px; margin-top:15px;">', '<a href="http://www.mymovies.it/dizionario/critica');
   TempField := MyTrim(TempField);
   SetField(fieldComments, TempField);
end;

procedure CalcLgthToDelete;
begin
  StartChar :=  '<div class="linkblu" style="padding:3px;"';
  EndChar   :=  '<div class="linkblu" style="padding:3px;"';
  Positioncast := Length(startChar) + Length(Textbetween(UsePage, StartChar, EndChar));
  if Positioncast  = 0 then
     begin
     EndChar := '<a href="http://www.mymovies.it/prossimamente/">';
     Positioncast := Length(startChar) + Length(Textbetween(UsePage, StartChar, EndChar));
     end;
end;

// ------------------------------------------------------------------
// FILL PICKTREE CONTROL WITH LINKS & TITLES or RETURN ONE PAGE LINK
// da 35mm.it
// ------------------------------------------------------------------
function PopulatePickTree(OneFilm: boolean): string;
var
  TempIdFilm, TempTitle: string;
  TempAuthor, TempYear: string;
  LineToDrop, LineToUse, LineTodelete, LineTxt: string;
  LengthFilm, LgthTitle, LineNr: integer;
  PositionCategory, LgthLineToUse, PositionDuration: integer;
  PageAll, PageLoop: string;
  cFilmYear, CYearId: string;
  NewLinkStart, NewLinkEnd: string;
  StartPos, EndPos: integer;
  NewLinkStartPos, NewLinkEndPos: integer;
begin
  if OneFilm then                                                           // per un solo film trovato è OK
    begin
      StartChar := 'http://www.mymovies.it/dizionario/recensione.asp?id=';
      EndChar   := '" title=';
      UsePage  := Textbetween(Pagestr, StartChar, EndChar);
      if length(UsePage) > 0 then
        begin
          TempIdFilm := StartChar + Usepage;
          result := TempIdFilm;
        end
    end
  else
    begin
      PickTreeClear;
      PickTreeAdd('Risultati ricerca per "' + getfield(fieldFilePath) + '":', '');                                               // per più pagine di film
      PageLoop := PageStr;
      StartChar := '<a title="Database MYmovies" href="http://www.mymovies.it/film/"><strong>Film</strong></a>';
      EndChar := '<a href="http://www.mymovies.it/prossimamente/">';
//fulvio      EndChar := '<a href="http://www.mymovies.it/database/">Effettua una nuova ricerca</a>';
      NewLinkStart := 'Media:<br />';
      NewLinkEnd := '#trovastreaming">';
      UsePage := TextBetween(PageStr, StartChar, EndChar) + EndChar;

      repeat                     // inizio gestione pagina multipla
        LineNr  := Pos('>Pagina successiva', PageStr);
        PageAll := UsePage;
        StartChar :=  '<div class="linkblu" style="padding:3px;"';
        Positioncast := Pos(StartChar, UsePage);
        Delete(UsePage, 1, Positioncast - 1)
        CalcLgthToDelete;

        repeat
          CalcLgthToDelete;
          StartChar :=  '<div class="linkblu" style="padding:3px;"';
          EndChar   :=  '<div class="linkverde">';
          LineToUse := StartChar + textbetween(UsePage, StartChar, EndChar) + EndChar;
          StartChar := '<div class="linkverde">';
           EndChar   := '<div class="linkblu" style="padding:3px;"';
          LineToDrop := textbetween(UsePage, StartChar, EndChar);
          if Length(LineToDrop) = 0 then
             begin
             EndChar := '<a href="http://www.mymovies.it/prossimamente/">';
             LineToDrop := textbetween(UsePage, StartChar, EndChar);
             end;
          LineToDelete := LineToUse + LineToDrop;
          PositionDuration := Length(LineToDelete);
          StartPos := pos(StartChar, UsePage);
          StartChar := 'http://www.mymovies.it/dizionario/recensione.asp?id=';
          EndChar := '" title="';
          if StartPos > 0 then
            begin
              TempIdFilm := StartChar + TextBetween(UsePage, Startchar, EndChar);

              // fixed new urls: 13/03/2018
              NewLinkStartPos := pos(NewLinkStart, LineToUse);
              if NewLinkStartPos <> 0 then
                begin
                  NewLinkEndPos := pos(NewLinkEnd, LineToUse);
                  if NewLinkEndPos > NewLinkStartPos then
                    begin
                      TempIdFilm := TextBetween(LineToUse, NewLinkStart, NewLinkEnd) + NewLinkEnd;
                      TempIdFilm := 'https:' + TextBetween(TempIdFilm, '"http:', NewLinkEnd);
                    end
                end;

              LengthFilm := length(StartChar) + length(TempIdFilm);
              Delete(UsePage, 1, LengthFilm);

              StartChar := 'title="';
              EndChar := '">';
              TempTitle := TextBetween(UsePage, Startchar, EndChar);
              LgthTitle := Length(TempTitle) + length(StartChar) + length(EndChar);
              TempTitle := FullTrim(TempTitle);
              LgthTitle := length(StartChar) + LgthTitle + length(EndChar);
              TempAuthor := Textbetween (UsePage, 'Un film di <b>', '</b>');
              TempAuthor := Textbetween (TempAuthor, '">', '</a>');
              TempYear   := Textbetween (UsePage, '<a href="http://www.mymovies.it/film/?anno=', '">');
              TempTitle  := TempTitle + ' (' + TempAuthor + ') ' + TempYear;
              PickTreeAdd(TempTitle, TempIdFilm);

              StartChar :=  'http://www.mymovies.it/dizionario/recensione.asp?id=';
              EndChar := '" title="';
              StartPos := pos(StartChar, UsePage);
             Delete(PageAll, 1, Positioncast - 1);
             UsePage := PageAll;
            end;
        until(Positioncast < 100);
        result := '';

// Controlla se ci sono altre pagine di risultati
        StartPos := Pos('Ricerca MYmovies', PageLoop);
        Delete(PageLoop, 1, StartPos - 1);
        StartChar := '<a href="?titolo=';
        EndChar := '">Pagina successiva';

        LineTxt := TextBetween(PageLoop, StartChar, EndChar);
        repeat
           if Length(LineTxt) > 1 then
              begin
              AddressNext := QueryBase + LineTxt;
              LineTxt := LineTxt + EndChar;
              end
          LineTxt := TextBetween(LineTxt, StartChar, EndChar);
        until length(LineTxt) < length(EndChar);
        SetField(fieldcomments, AddressNext);
        Pagestr  := getPageLegacy(Addressnext);
        PageLoop := PageStr;
        StartChar := '<a title="Database MYmovies" href="http://www.mymovies.it/film/"><strong>Film</strong></a>';
        EndChar := '<a href="http://www.mymovies.it/prossimamente/">';
        UsePage := TextBetween(PageStr, StartChar, EndChar) + EndChar;
      until (LineNr < 1); // repeat
    end
end;

//
// ---------------------------------
// ANALYZE FIRST SEARCH RESULT PAGE:
// IN:  page Url (string)
// OUT: none
// ---------------------------------
procedure AnalyzeSearchPage(Url: string);
var
  NumRisultati : string;
begin
  PageStr := getPageLegacy(Url);
//  SetField(fieldURL, URL);
  NumRisultati := Textbetween(PageStr, cStartNumRis, cEndNumRis);

  if ( (NumRisultati = '0') or (NumRisultati = '')) then
    begin
      ShowMessage('Title not found / Nessun film trovato.');
      SetField(fieldURL, MovieUrl);
      exit;
    end

  if NumRisultati = '1' then
    MovieUrl := PopulatePickTree(true)
  else
    begin
      PopulatePickTree(false);
      if not PickTreeExec(MovieUrl) then // ..select one
        exit;
    end;

  AnalyzeMoviePage;
end;

begin
  if (CheckVersion(4,2,1)) and (StringUtils1_Version > 5) then
    begin
      TranslatedStr := StringReplace(GetField(fieldTranslatedTitle), '.', ' ');
      MovieName := StringReplace(GetField(fieldOriginalTitle), '.', ' ');
      if (TranslatedStr <> '') then
        MovieName := TranslatedStr;

      if(Input('MyMovies.It', 'Enter the title of the movie', MovieName)) then
        begin
          MovieUrl := QueryBase + StringReplace(MovieName,' ','+') + UrlRicerca;
          AnalyzeSearchPage(MovieUrl);
        end;
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 4.2.1) and StringUtils1 version 6');
end.
Altober
Posts: 19
Joined: 2018-03-03 19:20:36

Re: filmaffinity 3.02

Post by Altober »

Thanks for your help mrobama!!
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: filmaffinity 3.02

Post by antp »

Some progress on the SSL/TLS problem, a new version to test:
viewtopic.php?f=6&t=6847
bonneville
Posts: 3
Joined: 2018-03-03 12:36:01

Re: filmaffinity 3.02

Post by bonneville »

I have cataloged 50 movies with filmaffinity and no problem for now.

Thank you very much.
jairr71
Posts: 1
Joined: 2018-03-25 08:04:07

Re: filmaffinity 3.02

Post by jairr71 »

It also works for me! Thank you :)
Post Reply