Buon divertimento.
I added the option to choose if you want great image size or tiny image size.
Enjoy it.
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Fulvio53s03 & seraphico (Original by Claudio Rinaldi)
Title=MyMovies
Description=Get movie info from MyMovies.it
Site=www.mymovies.it
Language=IT
Version=1.2.3
Requires=3.5.2
Comments=
License=
GetInfo=1
[Options]
Poster=1|0|1=Download full-res Poster|0=Download tiny Poster
***************************************************)
program MyMoviesIT;
uses
Stringutils7552;
const
UrlBase = 'http://www.mymovies.it';
UrlRicerca = '&titolo_orig=®ista=&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=';
QueryFilm = UrlBase + '/dizionario/recensione.asp?id=';
ImagePath = UrlBase + '/filmclub/';
NoCommento = '(Riceverai le informazioni pochi giorni prima della messa in onda)'; // commenti inutili "(la recensione più amata dal pubblico)"
Riceverai = '(Riceverai le informazioni pochi giorni prima della messa in onda)';
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
cEndId = '" title="'; // ID end marker
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 = 'scheda;genere='; // Catogory start marker
cEndCategory = ';'; // Category end marker
// cEndCategory = ';tile=1;sz='; // Category end marker
cStartDuration = 'durata '; // Duration start marker
cEndDuration = ' min.'; // Duration end marker
cStartYear = '<title>'; // Year start marker
cEndYear = ' | MYmovies</title>'; // Year 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://www.mymovies.it/filmclub/';
cEndImage = '"';
var
MovieUrl, MovieName, Commento, TranslatedStr, PageStr: string;
Startchar, EndChar, UsePage, Addressnext: String;
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);
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;
// -----------------------
// ANALYZE MOVIE DATA PAGE
// IN: none
// OUT: set Ant fields
// -----------------------
procedure AnalyzeMoviePage;
var
cImage : string;
SaveField, TempField, DelField : string;
PositionCategory, PositionDuration: integer;
begin
// Get packed title main page
PageStr := getPage(MovieUrl);
// Translated Title field
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);
PositionCategory := pos(cStartCategory, PageStr) + length(TempField);
// TempField := TempField + cEndcategory;
// TempField := TextBetween(TempField, '">' , cEndcategory);
SetField(fieldCategory, TempField);
// Duration field
TempField := TextBetween(PageStr, cStartDuration, cEndDuration);
PositionDuration := pos(cStartDuration, PageStr) + length(TempField);
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);
SetField(fieldCountry, TempField);
// Year
TempField := PageStr;
TempField := Textbetween (tempField, cStartYear, cEndYear);
TempField := Textbetween (TempField, '(', ')');
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);
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;
StartPos, EndPos: 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; // 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/database/">Effettua una nuova ricerca</a>';
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);
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 := GetPage(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 := getpage(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(3,5,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 3.5.1) and StringUtils1 version 6');
end.