All Movie Guide script something went wrong
-
- Posts: 63
- Joined: 2009-03-11 14:36:10
- Location: Hungary
All Movie Guide script something went wrong
Does not bring down :
Title, Description - AMG SYNOPSIS:
PLS help
thx
Title, Description - AMG SYNOPSIS:
PLS help
thx
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
Movie Title, please!
Re: All Movie Guide script something went wrong
The 'All Movie Guide' script no longer fetches the following three fields of information:
1. Movie rating
2. Plot synopsis (AMG Synopsis) [Description field]
3. Movie review (AMG Review) [Comments field]
It's possible some other fields might be pulling a blank as well.
Any help would be much appreciated, please. The last script update was done by R_V, that is, Raoul.
Raoul, if you are still around in the forum, your expertise is sorely needed once again. Or anyone else who has the skills to restore this script back to health. Raoul, Antoine, Fulvio, anyone, please?
PS: The script does not fetch the aforementioned fields of information for any movie title whatsoever. So it doesn't matter which movie title you type in: the script will draw a blank in the aforementioned three fields, perhaps more.
1. Movie rating
2. Plot synopsis (AMG Synopsis) [Description field]
3. Movie review (AMG Review) [Comments field]
It's possible some other fields might be pulling a blank as well.
Any help would be much appreciated, please. The last script update was done by R_V, that is, Raoul.
Raoul, if you are still around in the forum, your expertise is sorely needed once again. Or anyone else who has the skills to restore this script back to health. Raoul, Antoine, Fulvio, anyone, please?
PS: The script does not fetch the aforementioned fields of information for any movie title whatsoever. So it doesn't matter which movie title you type in: the script will draw a blank in the aforementioned three fields, perhaps more.
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
Movie Title, please!
Re: All Movie Guide script something went wrong
Fulvio, all the movie titles will produce the same blank result in the following three fields:
1. Movie rating
2. Description (Plot synopsis)
3. Comments (Review)
For example: Iron Man, Arthur, Crash, The Godfather, etc.
Last edited by Lemaireus on 2021-02-22 11:26:16, edited 1 time in total.
Re: All Movie Guide script something went wrong
Movie Title: The Godfather
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
My script's release is 0.8.5, November 2017. Is it the last One? (it comes now from AMC download).
Every movie I look for (between you titles) gives me:
"Sorry, there are too many possible matches......"
Every movie I look for (between you titles) gives me:
"Sorry, there are too many possible matches......"
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
Try This (tested with "All the President's Men"):
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Hubert Kosior, KaraGarga, Chetan Rao, Donna Huffman, R_V, Fulvio53s03
Title=All Movie Guide
Description=All Movie Guide detailed info import with picture
Site=https://www.allmovie.com
Language=EN
Version=1.0 / febbraio 2021
Requires=3.5.0
Comments=a bug corrected by Antoine Potten|completely rewritten again for the AllRovi site by Chetan Rao.|Reworked March 2009 for changes to AllMovieGuide by Donna Huffman|Rewritten for Allmovie.com by R_V (V 0.7.0 <-> 0.7.2 Feb 2014)
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
RequiresMovies=1
[Options]
CategoryOptions=2|3|1=Only import first category|2=Import all categories and divide by "/"|3=Import all categories and divide by ","
ProducerOptions=1|0|0=Import Production Companies into Producer Field|1=Import Releaser Company into 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=1|2|0=DO NOT import Production Credits|1=Import Production Credits into Description Field|2=Import Production Credits into Comments Field
CreditsOptions=3|2|1=Import Credits as a list (like AMG)|2=Import Credits as a list (like IMDB)|3=Import Credits as a list (within paranthesis)
CharacteristicsOptions=1|1|0=DO NOT import Characteristics|1=Import into Description Field
Picture=1|1|1=Big|2=Small
MaxResults=100|5000|100=Maximum search results returned|200=|5000=|8000=
BatchMode=0|0|0=Normal working mode|1=Batch mode: if the URL field is filled, it imports from that page instead of asking for a title
[Parameters]
***************************************************)
program AllMovie;
uses
StringUtils1;
const
crlf = #13#10; // carriage return/line feed
tab = #9;
var
MovieName: string;
PageURL: string;
UpdateFile: TStringList;
// 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 RemoveWhiteSpace(S : string) : string;
begin
Result := StringReplaceAll(S, tab, '');
Result := StringReplaceAll(Result, crlf, '');
Result := Trim(Result);
end;
function GetStringFromList(Content, Delimiter: string): string;
var
Data : string;
begin
while(true) do
begin
Data := TextBetween(Content, '">', '</a>');
if (Length(Data) = 0) then
break;
HTMLRemoveTags(Data);
Data := RemoveWhiteSpace(Data);
Result := Result + Data + Delimiter + ' ';
Content := TextAfter(Content, '</a>');
end;
// remove trailing delimiter
Result := Trim(Result);
if (Copy(Result, Length(Result), 1) = Delimiter) then
Result := Copy(Result, 0, Length(Result) - 1);
end;
function GetStringFromTable(Content, Delimiter, ColDelim : string): string; // for actors
var
Data, cast_role : string;
ColLen : Integer;
begin
ColLen := Length(ColDelim);
Result := '';
Content := TextBetween(Content, '<div class="cast_container">', '<span>Jump to: ') + '<div class="cast_container">';
//Content := TextAfter(Content, '<div class="cast_container">');
while(true) do
begin
Data := TextBetween(Content, '<div class="cast_name artist-name">', '<div class="cast_container">');
// make a unique delimiter between character and name
cast_role := Fulltrim(TextBetween(Data, '<div class="cast_role">', '</div>')); // if there is no cast_role next go line 80
Data := StringReplaceAll(Data, '<div class="cast_role">', ColDelim);
HTMLRemoveTags(Data);
HTMLDecode(Data);
if (Length(Data) = 0) then
break;
Data := RemoveWhiteSpace(Data);
// make sure we don't start with the ColDelim
if (Copy(Data, 0, ColLen) = ColDelim) then
Data := Copy(Data, ColLen + 1, Length(Data));
// make sure we don't end with the ColDelim
if (Copy(Data, Length(Data) - ColLen + 1, ColLen) = ColDelim) then
Data := Copy(Data, 1, Length(Data) - ColLen);
Content := TextAfter(Content, '<div class="cast_container">');
if cast_role <> '' then // if there is no cast_role necessary for actors format options
Result := Result + Data + Delimiter
else
Result := Result + Data + '## ';
end;
end;
function GetStringFromTable2(Content, Delimiter, ColDelim : string): string; // for crew
var
Data : string;
ColLen : Integer;
begin
ColLen := Length(ColDelim);
Result := '';
Content := TextBetween(Content, '<div class="crew_container">', '<span>Jump to: ') + '<div class="crew_container">';
//Content := TextAfter(Content, '<div class="crew_container">');
while(true) do
begin
Data := TextBetween(Content, '<div class="crew_name artist-name">', '<div class="crew_container">');
// make a unique delimiter between character and name
Data := StringReplaceAll(Data, '<div class="crew_role">', ColDelim);
HTMLRemoveTags(Data);
HTMLDecode(Data);
if (Length(Data) = 0) then
break;
Data := RemoveWhiteSpace(Data);
// make sure we don't start with the ColDelim
if (Copy(Data, 0, ColLen) = ColDelim) then
Data := Copy(Data, ColLen + 1, Length(Data));
// make sure we don't end with the ColDelim
if (Copy(Data, Length(Data) - ColLen + 1, ColLen) = ColDelim) then
Data := Copy(Data, 1, Length(Data) - ColLen);
Content := TextAfter(Content, '<div class="crew_container">');
Result := Result + Data + Delimiter;
end;
end;
function GetStringFromAwardsTable(Content, Delimiter, ColDelim : string): string;
var
Data : string;
RowData : string;
ColLen : Integer;
AwardTitle : string;
AwardType : string;
AwardRecps : string;
AwardYear : string;
Presenter : string;
begin
ColLen := Length(ColDelim);
Result := '';
while(true) do
begin
Data := TextBetween(Content, '<h3 class="award">', '</table>');
Presenter := FullTrim( TextBetween(Content, '<h3 class="award">', '</h3>') );
HTMLDecode(Data);
if (Length(Data) = 0) then
break;
Data := RemoveWhiteSpace(Data);
RowData := Data;
RowData := TextAfter(Rowdata, '<tbody>');
while(true) do
begin
Data := TextBetween(RowData, '<tr>', '</tr>');
if (Length(Data) = 0) then
break;
Data := StringReplace(Data, '<td class="award-type"', '<td class="award-type"><td class="award-type"');
Data := StringReplace(Data, '<td class="award-title"', '<td class="award-title"><td class="award-title"');
Data := StringReplace(Data, '<td class="award-year"', '<td class="award-year"><td class="award-year"');
AwardType := TextBetween(Data, '<td class="award-type">', '</td>');
AwardTitle := TextBetween(Data, '<td class="award-title">', '</td>');
AwardRecps := TextBetween(Data, '<div class="recipients">', '</div>');
AwardYear := TextBetween(Data, '<td class="award-year">', '</td>');
HTMLRemoveTags(AwardType);
HTMLRemoveTags(AwardTitle);
HTMLRemoveTags(AwardRecps);
HTMLRemoveTags(AwardYear);
AwardType := FullTrim(AwardType);
AwardTitle := FullTrim(AwardTitle);
AwardRecps := FullTrim(AwardRecps);
AwardYear := FullTrim(AwardYear);
if (Length(AwardType) > 0) then
AwardType := ' (' + AwardType + ')';
Data := AwardTitle + AwardType + ColDelim + AwardRecps + ColDelim + AwardYear + ColDelim + Presenter;
Result := Result + Trim(Data) + Delimiter;
RowData := TextAfter(RowData, '</tr>');
end;
Content := TextAfter(Content, '</table>');
end;
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;
function StrOccurs(Text, SearchText: string) : integer;
var
loc, len : integer;
begin
StrOccurs := 0;
len := length(SearchText);
loc := 1;
repeat
loc := Pos(SearchText, Text);
if loc > 0 then
begin
StrOccurs := StrOccurs + 1;
loc := loc + len;
Text := Copy(Text, loc, Length(Text) - loc);
end;
until(loc <= 0);
end;
// Loads and analyses search results page
procedure AnalyzeSearchResults(MovieTitle: string);
var
Page: TStringList;
NumResults, MaxResults, Code : Integer;
Address, MovieResults : string;
begin
MaxResults := GetOption('MaxResults');
Page := TStringList.Create;
Page.Text := GetPage('https://www.allmovie.com/search/movies/' + MovieTitle);
NumResults := 0;
if Pos('search results for ', Page.Text) > 0 then
begin
MovieResults := TextBetween(Page.Text, '<li class="filter-movies active">', '</li>');
MovieResults := StringReplace(MovieResults, ',', '');
MovieResults := StringReplace(MovieResults, '+', '');
NumResults := StrToInt(TextBetween(MovieResults, '(', ')'), Code);
if Code > 0 then
NumResults := 0;
if (NumResults > 0) and (NumResults <= MaxResults) then
begin
PickTreeClear;
PickTreeAdd(IntToStr(NumResults) + ' results found for "' + MovieName + '"', '');
AddMoviesTitles(MovieTitle);
if PickTreeExec(Address) then
AnalyzePage(Address);
end;
end;
if (NumResults > MaxResults) then
ShowMessage('Sorry, there are too many possible matches, please adjust your search and retry.')
else
if NumResults = 0 then
ShowMessage('Sorry, no movies found.');
// cleanup
Page.Free;
end;
// Loads and analyses a movie page
procedure AnalyzePage(Address: string);
var
Page: TStringList;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if CanSetField(fieldURL) then SetField(FieldURL, Address);
AnalyzeMoviePage(Address, Page);
Page.Free;
end;
// Extracts movie details from page
procedure AnalyzeMoviePage(Address: String; MoviePage: TStringList);
var
Page: string;
Value, Value2, Temp, Writer, Composer: string;
Content: string;
Delimiter : string;
Dummy: string;
SubPage: TStringList;
Rating : real;
begin
Page := MoviePage.Text;
SubPage := TStringList.Create;
// Original title
if CanSetField(fieldOriginalTitle) then
begin
Value := TextBetween(Page, '<h2 class="movie-title" itemprop="name">', '<');
Value := UTF8Decode(Value);
Value := FullTrim(Value);
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
end;
Content := Page;
// Year
if CanSetField(fieldYear) then
begin
Value := TextBetween(Page, '<span class="release-year">(', ')');
SetField(fieldYear, Value);
end;
// Length
if CanSetField(fieldLength) then
begin
Value := TextBetween(Page, 'Run Time - <span>', ' min');
SetField(fieldLength, Value);
end;
// Country
if CanSetField(fieldCountry) then
begin
Value := TextBetween(Page, 'Countries - <span>', '</span>');
Value := UTF8Decode(Value);
SetField(fieldCountry, Value);
end;
// AKA -> translated title
if CanSetField(fieldTranslatedTitle) then
begin
Value := TextBetween(Page, '<h4>Alternate Title</h4>', '</span>');
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
Value := FullTrim(Value);
SetField(fieldTranslatedTitle, Value);
end;
// Rating
if CanSetField(fieldRating) then
begin
// Value := TextBetween(page, 'itemprop="ratingValue">', '</div>');
Value := TextBetween(page, '"aggregateRating": {', '}');
Value := TextBetween(Value, '"ratingValue": "', '"');
Value := FullTrim(Value);
Rating := StrToFloat(Value);
SetField(fieldRating, FloatToStr(Rating));
end;
// Certification
if CheckVersion(4,2,0) = True then
begin
Value := TextBetween(Content, 'MPAA Rating - <span>', '</span>');
Value := AnsiUpperCase(Value);
Value := StringReplace(Value, 'PG13', 'PG-13');
Value := StringReplace(Value, 'NC17', 'NC-17');
SetField(fieldCertification, Value);
end;
// Director
if CanSetField(fieldDirector) then
begin
Value := TextBetween(Content, 'Directed by ', '</span>');
Value := UTF8Decode(Value);
Value := GetStringFromList(Value, ',');
SetField(fieldDirector, Value);
end;
// Genre -> category
if CanSetField(fieldCategory) then
begin
Value := TextBetween(Content, 'Genres - ', '</span');
Value := UTF8Decode(Value);
if GetOption('CategoryOptions') = 1 then
begin
Value := TextBetween(Value, '">', '</a>');
HTMLRemoveTags(Value);
end
else
begin
if GetOption('CategoryOptions') = 2 then
Delimiter := '/';
if GetOption('CategoryOptions') = 3 then
Delimiter := ',';
Dummy := GetStringFromList(Value, Delimiter);
// sub-genres
Value := TextBetween(Content, 'Sub-Genres - ', '</span>');
Value := UTF8Decode(Value);
Value := GetStringFromList(Value, Delimiter);
if Length(Value) > 0 then
Value := Dummy + Delimiter + ' ' + Value
else
Value := Dummy;
end;
SetField(fieldCategory, Value);
end;
// Producing company -> producer
if CanSetField(fieldProducer) then
begin
Value := '';
if GetOption('ProducerOptions') = 0 then
begin
Value := TextBetween(Page, '<h4>Produced by</h4>', '</div>');
Value := UTF8Decode(Value);
end;
if GetOption('ProducerOptions') = 1 then
begin
Value := TextBetween(Page, '<h4>Released By</h4>', '</div>');
Value := UTF8Decode(Value);
end;
HTMLRemoveTags(Value);
Value := FullTrim(Value);
SetField(fieldProducer, Value);
end;
// Image
if CanSetPicture then
begin
Value := TextBetween(Page, ' <div class="poster">', '</div>');
Value := TextBetween(Value, '<img src="', '"');
Value := StringReplace(Value, '?partner=allrovi.com', '');
Value := StringReplace(Value, 'https', 'http');
if GetOption('Picture') = 1 then
Delete(Value, Pos('_derived', Value), (Pos('_m0/', Value))-(Pos('_derived', Value))+4);
// don't bother getting the default "no-image"
if ( (Length(Value) > 0) and (Pos('no-image', Value) = 0) ) then GetPicture(Value);
end;
// Plot synopsis
if CanSetField(fieldComments) or CanSetField(fieldDescription) then
begin
// store the author of the synopsis
// Dummy := TextBetween(Page, '<h4 class="review-author headline" itemprop="author" itemscope itemtype="https://schema.org/Person">', '</h4>');
// Dummy := TextBetween(Page, '<section class="review read-more synopsis">', '</section>');
// Dummy := TextBetween(Dummy, 'by <span itemprop="name">', '</span>');
// Value := TextBetween(Page, '<div class="text" itemprop="description">', '</div>');
Dummy := TextBetween(Page, '<section class="review read-more synopsis">', '</section>');
Dummy := TextBetween(Dummy, '<div class="text">', '</div>');
HTMLRemoveTags(Dummy);
Dummy := UTF8Decode(Dummy);
if GetOption('SynopsisOptions') = 1 then
begin
//if (GetOption('ReviewOptions') = 1) or (GetOption('AwardsOptions') = 1) or (GetOption('FieldforCredits') = 1) then
Value := 'AMG SYNOPSIS: ' + CRLF + fulltrim(Dummy);
SetField(fieldDescription, Value);
end;
if GetOption('SynopsisOptions') = 2 then
begin
//if (GetOption('ReviewOptions') = 2) or (GetOption('AwardsOptions') = 2) or (GetOption('FieldforCredits') = 2) then
Value := 'AMG SYNOPSIS: ' + Value;
SetField(fieldComments, Value);
end;
end;
// Characteristics
if (CanSetField(fieldComments)) and (GetOption('CharacteristicsOptions') > 0) then
begin
Value := TextBetween(Page, '<h3>Characteristics</h3>', '</section>');
Value := StringReplace(Value, '</h4>', ' : </h4>');
Value := StringReplace(Value, '</4>', ' : </h4>'); // because sometimes the html code is broken on AMG site
Value := StringReplace(Value, '<h4>', '<h4>##');
HTMLRemovetags(Value);
HTMLDecode(Value);
Value := RemoveSpaces(Value, True);
Value := StringReplace(Value, '##', crlf);
SetField(fieldDescription, GetField(fieldDescription) + CRLF + CRLF + 'CHARACTERISTICS:' + Value + crlf + crlf);
end;
// Review -> description
if (CanSetField(fieldComments) or CanSetField(fieldDescription)) and (GetOption('ReviewOptions') > 0) and (Pos('<li class="tab review">', Page) > 0) then
begin
// get the page
SubPage.Text := GetPage(Address + '/review');
// store the author of the synopsis
Dummy := TextBetween(SubPage.Text, '<span itemprop="author">', '</span>');
HTMLRemoveTags(Dummy);
// get the review
Content := TextBetween(SubPage.Text, 'itemprop="reviewBody">', '</section>');
Content := RemoveSpaces(Content, True);
Content := StringReplace(Content, '</p>', #13#10 + #13#10);
HTMLRemoveTags(Content);
HTMLDecode(Content);
Value := UTF8Decode(Content);
if (Length(Value) > 0) then
Value := Fulltrim(Value) + ' -- ' + Dummy + #13#10 + #13#10;
if GetOption('ReviewOptions') = 1 then
begin
//if (GetOption('SynopsisOptions')= 1) or (GetOption('AwardsOptions')= 1) or (GetOption('FieldforCredits')= 1) then
Value := 'AMG REVIEW: ' + Value;
SetField(fieldDescription, Value);
end;
if GetOption('ReviewOptions') = 2 then
begin
//if (GetOption('SynopsisOptions')= 2) or (GetOption('AwardsOptions')= 2) or (GetOption('FieldforCredits')= 2) then
Value := 'AMG REVIEW: ' + Value;
SetField(fieldComments, Value)
end;
end;
// Awards -> description
if (CanSetField(fieldComments) or CanSetField(fieldDescription)) and (GetOption('AwardsOptions') > 0) and (Pos('<li class="tab awards">', Page) > 0) then
begin
// get the page
SubPage.Text := GetPage(Address + '/awards');
// get the awards panel content -- this yields the awards
Content := TextAfter(SubPage.Text, '<div class="awards-box">');
Value := GetStringFromAwardsTable(Content, '~~ ', '||');
Value := UTF8Decode(Value);
Value := StringReplace(Value, '~~ ', #13#10);
Value := StringReplace(Value, '||', ' - ');
if Length(Value) > 0 then
begin
if GetOption('AwardsOptions') = 1 then
SetField(fieldDescription, GetField(fieldDescription) + 'AWARDS:' +#13#10 + Value + #13#10);
if GetOption('AwardsOptions') = 2 then
SetField(fieldComments, GetField(fieldComments) + 'AWARDS:' + #13#10 + Value + #13#10);
end;
end;
// Cast -> actors
if CanSetField(fieldActors) or CanSetField(fieldComments) or CanSetField(fieldDescription) or (CheckVersion(4,2,0) and (CanSetField(fieldWriter) or CanSetField(fieldComposer))) then
begin
// get the page
SubPage.Text := GetPage(Address + '/cast-crew');
// get the center panel content -- this yields the Cast table
Content := TextBetween(SubPage.Text, '<h2>Cast</h2>', '<h2>Crew</h2>');
Value := GetStringFromTable(Content, '~~ ', '||');
Value := UTF8Decode(Value);
if Length(Value) > 0 then
begin
// remove double spaces if only actor name given
while Pos(' ', Value) > 0 do
Delete(Value, Pos(' ', Value), 2);
if GetOption('CastOptions') = 1 then
begin
Value := StringReplaceAll(Value, '~~ ', ';');
Value := StringReplace(Value, '## ', ';');
Value := StringReplaceAll(Value, '||', '-');
SetField(fieldActors, Value);
end;
if GetOption('CastOptions') = 2 then
begin
Value := StringReplace(Value, '~~ ', #13#10);
Value := StringReplace(Value, '## ', #13#10);
Value := StringReplaceAll(Value, '||', '-');
if (Copy(Value, Length(Value) - 1, 2) = #13#10) then
Value := Copy(Value, 0, Length(Value) - 2);
SetField(fieldActors, Value);
end;
if GetOption('CastOptions') = 3 then
begin
Value := StringReplace(Value, '~~ ', #13#10);
Value := StringReplace(Value, '## ', #13#10);
Value := StringReplace(Value, '||', ' ... ');
if (Copy(Value, Length(Value) - 1, 2) = #13#10) then
Value := Copy(Value, 0, Length(Value) - 2);
SetField(fieldActors, Value);
end;
if GetOption('CastOptions') = 4 then
begin
Value := StringReplace(Value, '~~ ', ')'+#13#10);
Value := StringReplace(Value, '## ', #13#10);
Value := StringReplace(Value, '||', ' (');
if (Copy(Value, Length(Value) - 1, 2) = #13#10) then
Value := Copy(Value, 0, Length(Value) - 2);
SetField(fieldActors, Value);
end;
if GetOption('CastOptions') = 5 then
begin
Value := StringReplace(Value, '~~ ', '), ');
Value := StringReplace(Value, '## ', ', ');
Value := StringReplace(Value, '||', ' (');
if (Copy(Value, Length(Value) - 1, 2) = ', ') then
Value := Copy(Value, 0, Length(Value) - 2);
SetField(fieldActors, Value);
end;
end;
// ProductionCredits -> Comments/Description
// get the center panel content -- this yields the Cast table
Content := TextBetween(SubPage.Text, '<h2>Crew</h2>', '</section>');
// transform the weirdly formatted list into a pseudo table so we can
// reuse existing
Value := GetStringFromTable2(Content, '~~ ', '||');
Value := UTF8Decode(Value);
if Length(Value) > 0 then
begin
// remove double spaces if only name given
while Pos(' ', Value) > 0 do
Delete(Value, Pos(' ', Value), 2);
// begin get composer and writer
if CheckVersion(4,2,0) = True then
begin
Value2 := '%Name : '+Value;
Value2 := StringReplace(Value2, '~~ ', ']#'+#13#10+'%Name : ');
Value2 := deleteEnd(Value2, '%Name : ');
Value2 := StringReplace(Value2, '||', ' [');
if (Copy(Value2, Length(Value2) - 1, 2) = #13#10) then
Value2 := Copy(Value2, 0, Length(Value2) - 2);
// start loop
While Pos('#', Value2) > 0 do
begin
Temp := TextBetween(Value2, '%', '#');
if Pos('Composer', Temp) > 0 then
Composer := Composer+TextBetween(Temp, 'Name : ', ' [')+', ';
if (Pos('Screenwriter', Temp) > 0) OR (Pos('Screen Story', Temp) > 0) then
Writer := Writer+TextBetween(Temp, 'Name : ', ' [')+', ';
Delete(Value2,1,Pos('#',Value2));
end;
// end loop
Composer := deleteEnd(Composer, ', ');
SetField(fieldComposer,Composer);
Writer := deleteEnd(Writer, ', ');
SetField(fieldWriter,Writer);
end;
// end get composer and writer
if GetOption('CreditsOptions') = 1 then
begin
Value := StringReplace(Value, '~~ ', #13#10);
Value := StringReplaceAll(Value, '||', '-');
if (Copy(Value, Length(Value) - 1, 2) = #13#10) then
Value := Copy(Value, 0, Length(Value) - 2);
end;
if GetOption('CreditsOptions') = 2 then
begin
Value := StringReplace(Value, '~~ ', #13#10);
Value := StringReplace(Value, '||', ' ... ');
if (Copy(Value, Length(Value) - 1, 2) = #13#10) then
Value := Copy(Value, 0, Length(Value) - 2);
end;
if GetOption('CreditsOptions') = 3 then
begin
Value := StringReplace(Value, '~~ ', ')'+#13#10);
Value := StringReplace(Value, '||', ' (');
if (Copy(Value, Length(Value) - 1, 2) = #13#10) then
Value := Copy(Value, 0, Length(Value) - 2);
end;
if GetOption('FieldforCredits') = 1 then
SetField(fieldDescription, GetField(fieldDescription) + 'PRODUCTION CREDITS:' + #13#10 + Value + crlf + crlf);
if GetOption('FieldforCredits') = 2 then
SetField(fieldComments, GetField(fieldComments) + 'PRODUCTION CREDITS:' + #13#10 + Value + crlf + crlf);
end;
end;
SubPage.Free;
// remove trailing newline from description or comments
Value := GetField(fieldDescription);
While Copy(Value, Length(Value) - 1, 2) = #13#10 do
begin
Value := Copy(Value, 0, Length(Value) - 2);
SetField(fieldDescription, Value);
end;
Value := GetField(fieldComments);
While Copy(Value, Length(Value) - 1, 2) = #13#10 do
begin
Value := Copy(Value, 0, Length(Value) - 2);
SetField(fieldComments, Value);
end;
end;
// Adds movie titles from search results to tree
procedure AddMoviesTitles(Title : string{; NumResults: Integer});
var
Page: TStringList;
PageText : string;
SearchAddress : string;
MovieTitle, MovieAddress, MovieYear, MovieDirector, Temp: string;
begin
SearchAddress := 'https://www.allmovie.com/search/movies/' + Title;
Page := TStringList.Create;
Page.Text := GetPage(SearchAddress);
PageText := Page.Text;
Delete(PageText, 1, Pos('<ul class="search-results">', PageText)-1);
// Every movie entry begins with string "<tr>"
while Pos('<li class="movie">', PageText) > 0 do
begin
Temp := TextBetween(PageText, '<li class="movie">', '</li>');
MovieAddress := 'https://www.allmovie.com/movie' + TextBetween(Temp, '<a href="https://www.allmovie.com/movie', '"');
MovieTitle := UTF8Decode(TextBetween(Temp, MovieAddress+'">', '</a>'));
MovieYear := TextBetween(Temp, MovieTitle+'</a>', '</div>');
MovieYear := FullTrim(MovieYear);
MovieDirector := UTF8Decode(TextBetween(Temp, 'Directed by: ', '</div>'));
HTMLRemoveTags(MovieDirector);
MovieDirector := FullTrim(MovieDirector);
If MovieDirector <> '' then
MovieDirector := ' by ' + MovieDirector;
MovieTitle := MovieTitle + ' ' + MovieYear + MovieDirector;
// add movie to list
PickTreeAdd(MovieTitle, MovieAddress);
// remove the entry we just processed
CutAfter(PageText, '</li>');
end;
Page.Free;
end;
// Extracts single movie detail (like director, genre) from page
function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string;
begin
Result := '';
// recognition tag - if present, extract detail from page, otherwise assume detail is not present
if Pos(StartTag, Page) > 0 then begin
CutBefore(Page, StartTag);
// optional cut tag helps finding right string in html page
if Length(CutTag) > 0 then
CutAfter(Page, CutTag);
// movie detail copied with html tags up to end string
Result := Copy(Page, 0, Pos(EndTag, Page) - 1);
// remove html tags and decode html string
HTMLRemoveTags(Result);
HTMLDecode(Result);
Result := RemoveWhiteSpace(Result);
// ShowMessage('DEBUG: GetStringFromHTML - StartTag "'+StartTag+'", CutTag "'+CutTag+'", EndTag "'+EndTag+'", Result "'+Result+'" ___ '+Page);
end;
end;
// Delete substring of a string if end string
function deleteEnd(Value, EndValue : String) : String;
begin
if copy(Value,length(Value)-length(EndValue)+1,length(Value)) = EndValue then
Value := copy(Value,1,length(Value)-length(EndValue));
result := Value;
end;
//------------------------------------------------------------------------------
// Program
//------------------------------------------------------------------------------
begin
// Check StringUtils1 version and update if < version 7
if StringUtils1_Version < 7 then
begin
if ShowWarning('Old version of file "Stringutils1.pas" detected: v'+IntToStr(StringUtils1_Version)+#13#10+'The script requires at least version 7.'+#13#10+'Download and install latest version now ?') = True then
begin
UpdateFile := TStringList.Create;
UpdateFile.Text := GetPage('http://update.antp.be/amc/scripts/StringUtils1.pas');
UpdateFile.SaveToFile(dirScripts + 'StringUtils1.pas');
UpdateFile.Free;
ShowInformation('StringUtils1 has been updated. Please restart "All Movie Guide" script now. Thank you.');
Exit;
end
else
begin
ShowInformation('You can download latest version of "StringUtils1.pas" using script [ UPDATE SCRIPTS ] or via http://update.antp.be/amc/scripts');
Exit;
end;
end;
// Check AMC version
if CheckVersion(4,2,1) then
begin
MovieName := GetField(fieldUrl);
if (GetOption('BatchMode') = 1) and (Pos('allmovie.com', MovieName) > 0) then
begin
if Pos('https', MovieName) > 0 then
AnalyzePage(MovieName)
else
AnalyzePage(StringReplace(MovieName, 'http', 'https'));
end
else
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then MovieName := GetField(fieldTranslatedTitle);
if Input('All Movie Import', 'Enter title (only letters, digits and spaces) or URL:', MovieName) then
begin
if Pos('allmovie.com', MovieName) > 0 then
AnalyzePage(MovieName)
else
AnalyzeSearchResults( StringReplace(URLEncode(MovieName), '%20', '+') );
end;
end;
end
else
begin
if ShowWarning('This script requires a newer version of Ant Movie Catalog'+#13#10+'at least the 4.2.1 BETA version available here : '+#13#10+'http://forum.antp.be/phpbb2/viewtopic.php?t=4844'+#13#10#13#10+'Click on ''Ok'' to launch directly the adress in your browser') = True then
Launch('http://forum.antp.be/phpbb2/viewtopic.php?t=4844', '');
end
end.
Re: All Movie Guide script something went wrong
Fulvio, thank you for the work you have put in.
To do away with the problem of too many results, you can go to 'Script Options>MaxResults' and change the number therein.
Your script works, but there are three problems:
1. It does not accurately import the movie rating from 'All Movie Guide' website. (The script should pick 'AllMovie Rating' not 'User Ratings'.)
2. It imports the plot synopsis in the 'description' field, but there is a text formatting issue with the paragraphs not coming out right. It does not import the name of the synopsis writer.
3. The script does not import the review.
Thank you for some wonderful work which gives hope that the script will soon be restored back to pristine health soon.
To do away with the problem of too many results, you can go to 'Script Options>MaxResults' and change the number therein.
Your script works, but there are three problems:
1. It does not accurately import the movie rating from 'All Movie Guide' website. (The script should pick 'AllMovie Rating' not 'User Ratings'.)
2. It imports the plot synopsis in the 'description' field, but there is a text formatting issue with the paragraphs not coming out right. It does not import the name of the synopsis writer.
3. The script does not import the review.
Thank you for some wonderful work which gives hope that the script will soon be restored back to pristine health soon.
Last edited by Lemaireus on 2021-02-23 08:56:55, edited 1 time in total.
Re: All Movie Guide script something went wrong
Please use the title "The Kid" (1921) to test the description (AMG Synopsis) field because the text block is long enough to show formatting issues.
Please use the title "The Great Buck Howard" (2008) to test the comments (AMG Review) field because it is a two paragraph review and will thus show text formatting issues, if there are any.
Please use the title "The Great Buck Howard" (2008) to test the comments (AMG Review) field because it is a two paragraph review and will thus show text formatting issues, if there are any.
-
- Posts: 63
- Joined: 2009-03-11 14:36:10
- Location: Hungary
Re: All Movie Guide script something went wrong
fulvio53s03
Thank you so much for helping us.
The new script works, but for me the original title field is still blank, and AMG REVIEW I can't find it either. What have I done wrong?
thx
Thank you so much for helping us.
The new script works, but for me the original title field is still blank, and AMG REVIEW I can't find it either. What have I done wrong?
thx
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
Updated testing "The Great Buck Howard"
Code: Select all
deleted as incorrect
Last edited by fulvio53s03 on 2021-02-27 10:48:14, edited 1 time in total.
Re: All Movie Guide script something went wrong
Thank you once again, Fulvio, for all the work you have put in. However, the script still seems a little buggy, with the following two problems:
1. The plot synopsis does not get picked up.
2. The review does not get picked up.
Improvements over the last version you posted earlier:
1. The AMG movie rating is now being picked up correctly.
2. The plot synopsis (description) text box picks up the name of the synopsis writer.
I'll shortly post two screenshots: first, of the information imported by the old AMG script, and second, of the information imported by your version of the script.
1. The plot synopsis does not get picked up.
2. The review does not get picked up.
Improvements over the last version you posted earlier:
1. The AMG movie rating is now being picked up correctly.
2. The plot synopsis (description) text box picks up the name of the synopsis writer.
I'll shortly post two screenshots: first, of the information imported by the old AMG script, and second, of the information imported by your version of the script.
Last edited by Lemaireus on 2021-02-26 18:19:03, edited 1 time in total.
Re: All Movie Guide script something went wrong
Screenshot of the information for the title "The Great Buck Howard" imported by the earlier version of the script, when it was fully functional:
https://ibb.co/QNm7DXj
Screenshot of the information for the title "The Great Buck Howard" imported by the new version of the script:
https://ibb.co/5GgXvTn
https://ibb.co/QNm7DXj
Screenshot of the information for the title "The Great Buck Howard" imported by the new version of the script:
https://ibb.co/5GgXvTn
Re: All Movie Guide script something went wrong
This is how the imported information from All Movie Guide should look (Raoul's script [R_V], v. 0.7.4?):
This is how the imported information from All Movie Guide currently looks (Fulvio's script, v. 1.1):
PS: I have posted the screenshots solely to highlight the missing elements in the "Description" and "Comments" fields. The new script by Fulvio works well in all other respects, including importing the picture.
Once again, thank you, Fulvio, and looking forward to a perfect script sometime soon. Cheers!
This is how the imported information from All Movie Guide currently looks (Fulvio's script, v. 1.1):
PS: I have posted the screenshots solely to highlight the missing elements in the "Description" and "Comments" fields. The new script by Fulvio works well in all other respects, including importing the picture.
Once again, thank you, Fulvio, and looking forward to a perfect script sometime soon. Cheers!
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
Sorry for my mistake, giving you an incorrect pre-release...
I hope the following release could be satisfactory:
I hope the following release could be satisfactory:
Code: Select all
obsolete code deleted
Last edited by fulvio53s03 on 2021-02-28 14:15:00, edited 1 time in total.
Re: All Movie Guide script something went wrong
Thank you very much, Fulvio, the new version you have posted is nearly perfect. One little detail, about a formatting issue: the comments section picks the AMG reviews as one text block, even when the website has split the text in two paragraphs.
For example, "Comments" section of "The The Great Buck Howard" should show as:
But in the new AMG script it shows up as one text block:
The same text formatting issue is there in the "Description" (AMG Synopsis) section as well (tested with "The Kid" 1921). These are the only two minor bugs left in an otherwise perfect script.
Many, many thanks for helping out.
Re: All Movie Guide script something went wrong
PS: The new script is not picking up the "AllMovie Rating". Tested with the following titles:
The Kid
Zulu
The Wind Will Carry Us
The Kid
Zulu
The Wind Will Carry Us
-
- Posts: 744
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: All Movie Guide script something went wrong
please send me a screenshot about "Description" in "The Kid" as i cannot see what you are saying.
The page on web is the following?
https://www.allmovie.com/movie/the-kid-v27169
Have a good day.
Re: All Movie Guide script something went wrong
Here are the screenshots:
1. This is how the text block appears in the "Description" field with the new script, with the three extra line/paragraph breaks highlighted with a red arrow:
2. This is how the text block should appear in the "Description" (AMG Synopsis) field, without any line or paragraph breaks:
3. This is how the text block appears on the link you have provided: https://www.allmovie.com/movie/the-kid-v27169, without any line or paragraph breaks:
Once again, Fulvio, thank you very much, and wish you a wonderful day too!
1. This is how the text block appears in the "Description" field with the new script, with the three extra line/paragraph breaks highlighted with a red arrow:
2. This is how the text block should appear in the "Description" (AMG Synopsis) field, without any line or paragraph breaks:
3. This is how the text block appears on the link you have provided: https://www.allmovie.com/movie/the-kid-v27169, without any line or paragraph breaks:
Once again, Fulvio, thank you very much, and wish you a wonderful day too!