(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Hubert Kosior, KaraGarga, Chetan Rao, Donna Huffman Title=All Movie Guide Description=All Movie Guide detailed info import with small picture Site=http://www.allmovie.com Language=EN Version=0.5.2 / March 2009 Requires=3.5.0 Comments=a bug corrected by Antoine Potten|completely rewritten for the new AllMovieGuide site by Chetan Rao.|Reworked March 2009 for changes to AllMovieGuide by Donna Huffman License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] CategoryOptions=3|1|1=Only import first category|2=Import all categories and separate with "/"|3=Import all categories and separate with "," ProducerOptions=0|1|0=Do Not Import into Producer Field|1=Import Production Company in Producer Field SynopsisOptions=1|1|1=Import into Description Field|2=Import into Comments Field|0=DO NOT import Synopsis ReviewOptions=2|2|1=Import into Description Field|2=Import into Comments Field|0=DO NOT import Review AwardsOptions=2|2|1=Import into Description Field|2=Import into Comments Field|0=DO NOT import Awards List CastOptions=3|3|1=Import Cast divided by ";"|2=Import Cast as a list (AMG Default)|3=Import Cast as a list (like IMDB)|4=Import Cast as a list within paranthesis|5=Import Cast within paranthesis FieldforCredits=2|1|0=DO NOT import Production Credits|1=Import Production Credits into Description Field|2=Import Production Credits into Comments Field|3=Import Production Credits into Actors Field CreditsOptions=2|3|1=Import Credits divided by ";"|2=Import Credits as a list (AMG Default)|3=Import Credits as a list (like IMDB)|4=Import Credits as a list within paranthesis|5=Import Credits within paranthesis ***************************************************) program AllMovie; uses StringUtils1; var MovieName: string; PageURL: string; // simple string procedures function StringReplaceAll(S, Old, New: string): string; begin while Pos(Old, S) > 0 do S := StringReplace(S, Old, New); Result := S; end; function GetStringFromList(Content, Delimiter: string): string; begin Result := StringReplace(Content, '', Delimiter); HTMLRemoveTags(Result); HTMLDecode(Result); Result := UTF8Decode(Result); Result := StringReplace(Result, #9, ''); Result := StringReplace(Result, #10, ''); Result := StringReplace(Result, #13, ''); // remove trailing delimiter if (Copy(Result, Length(Result), 1) = Delimiter) then Result := Copy(Result, 0, Length(Result) - 1); Result := StringReplaceAll(Result, ' ', ' '); Result := StringReplaceAll(Result, ', ', ','); Result := StringReplace(Result, ',', ', '); end; function GetStringFromTable(Content, Delimiter, ColDelim : string): string; var Data : string; ColLen : Integer; begin ColLen := Length(ColDelim); Content := StringReplace(Content, #9, ''); Content := StringReplace(Content, #10, ''); Content := StringReplace(Content, #13, ''); Content := StringReplace(Content, '', ColDelim); Content := StringReplace(Content, '', Delimiter); Content := StringReplace(Content, '', ColDelim); Content := StringReplaceAll(Content, ' ', ''); HTMLRemoveTags(Content); HTMLDecode(Content); Content := UTF8Decode(Content); Result := ''; Result := Content; end; procedure CutAfter(var Str: string; Pattern: string); begin Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str)); end; procedure CutBefore(var Str: string; Pattern: string); begin Str := Copy(Str, Pos(Pattern, Str), Length(Str)); end; // Loads and analyses page from internet (list of movies or direct hit) procedure AnalyzePage(Address: string); var Page: TStringList; begin Page := TStringList.Create; Page.Text := GetPage(Address); // ShowMessage('AnalysePage ' + Address); // movie list Sleep(500); if Pos('Search Results for:', Page.Text) > 0 then begin PickTreeClear; PickTreeAdd('Search results', ''); AddMoviesTitles(Page); if PickTreeExec(Address) then // ShowMessage(Address); AnalyzePage(Address); // refine search end else if Pos('Sorry, there are too many possible matches, please adjust your search.', Page.Text) > 0 then begin ShowMessage('Sorry, there is too many possible matches, please adjust your search.'); if Input('All Movie Import', 'Enter the title of the movie:', MovieName) then AnalyzePage('http://www.allmovie.com/search/work/' + URLEncode(MovieName)); // direct hit end else begin if CanSetField(fieldURL) then SetField(FieldURL, Address); // showmessage (Address); AnalyzeMoviePage(Page) end; // cleanup Page.Free; end; // Extracts movie details from page procedure AnalyzeMoviePage(MoviePage: TStringList); var Page: string; Value: string; Content: string; Dummy: string; SubPage: TStringList; begin Page := MoviePage.Text; Page := UTF8Decode(Page); SubPage := TStringList.Create; // Original title if CanSetField(fieldOriginalTitle) then begin Value := TextBetween(Page, 'span class="title">', ''); SetField(fieldOriginalTitle, Value); end; // get the left panel content -- this yields year, runtime, country, director & genre Content := TextBetween(Page, '