Moviemeter.nl Alternative Title
Posted: 2007-07-09 13:36:44
Hello,
I think Moviemeter changed something to there site, because the 'alternative title' isn't working well anymore. Just a simple change in the script will solve the problem, here's the new script:
The only change I had to make was
Line := TextBetween(PageText, 'Alternatieve titel', '<br/>');
into Line := TextBetween(PageText, 'Alternatieve titel', ' </p>');
I think Moviemeter changed something to there site, because the 'alternative title' isn't working well anymore. Just a simple change in the script will solve the problem, here's the new script:
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Antoine Potten
Title=MovieMeter.nl
Description=MovieMeter.nl import script
Site=www.moviemeter.nl
Language=NL
Version=2.7.0
Requires=3.5.0
Comments=Previous version made by JanC and corrections by <link>rolandb5@hotmail.com</link>|Rewritten by Antoine Potten after a site change (v 2.0)|Updated/Fixed by bad4u (v 2.7)
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]
AllCountries=1|0|0=Take only first country|1=Take all countries (separated by "/")
ImportComments=1|0|0=Do not import users' comments|1=Import users' comments
***************************************************)
program MovieMeter;
uses
StringUtils1;
var
MovieName: string;
procedure AnalyzeMoviePage(Address: string);
var
PageText, Line, Value: string;
begin
PageText := GetPage(Address);
// URL
SetField(fieldURL, Address);
// title & year
Line := TextBetween(PageText, '<h1>', '</h1>');
Value := TextBetween(Line, '(', ')');
SetField(fieldYear, Value);
Value := Trim(TextBefore(Line, '(', ''));
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
// translated title
Line := TextBetween(PageText, 'Alternatieve titel', ' </p>');
if Line <> '' then
begin
Line := TextAfter(Line, ': ');
if Line <> '' then
begin
HTMLDecode(Line);
SetField(fieldTranslatedTitle, Line);
end;
end;
Value := TextBetween(PageText, '<div id="film_info"', '<br />');
Line := RemainingText;
Value := TextAfter(Value, '>');
// Country
if (GetOption('AllCountries') = 0) and (Pos(' / ', Value) > 0) then
Value := TextBefore(Value, ' / ', '');
HTMLDecode(Value);
SetField(fieldCountry, Value);
// Category
Value := TextBefore(Line, '<br />', '');
Line := RemainingText;
HTMLDecode(Value);
SetField(fieldCategory, Value);
// Length
Value := TextBefore(Line, ' minuten', '');
Line := RemainingText;
HTMLDecode(Value);
SetField(fieldLength, Value);
// Director
Value := TextBetween(Line, 'geregisseerd door ', '<br />');
Line := RemainingText;
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
// Actors
Value := TextBetween(Line, 'met ', '<br />');
Line := RemainingText;
HTMLDecode(Value);
SetField(fieldActors, Value);
// Description
Value := TextBetween(Line, '<br />', '</div>');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDescription, Value);
// Picture
Value := TextBetween(PageText, '<img class="poster" src="', '" ');
if Value <> '' then
begin
GetPicture(Value);
end;
// Rating
Value := TextBetween(PageText, '</span>gemiddelde <b>', '<');
Value := StringReplace(FloatToStr(StrToFloat(StringReplace(Value, ',', '.')) * 2), ',', '.');
SetField(fieldRating, Value);
// Comments
if GetOption('ImportComments') = 1 then
begin
Value := TextBetween(PageText, '<div class="forum_message_user">', '<div class="to_page entitypages" id="pages_bottom"></div>');
Value := StringReplace(Value, ' uur', ' uur : ' + #13#10);
// Value := StringReplace(Value, '<div class="forum_message_message">', #13#10);
Value := StringReplace(Value, '</div><div class="form_horizontal_divider" ', '-------------------------------------------------------------' + #13#10 + #13#10 + '<');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldComments, Value);
end;
end;
procedure AnalyzeResultsPage(Address: string);
var
Page: TStringList;
Line: string;
MovieAddress: string;
MovieTitle: string;
begin
// get results page
Page := TStringList.Create;
Page.Text := GetPage(Address);
// get redirect javascript
Line := Page.GetString(Page.Count-2);
// more than 1 movie found
if Pos('location.href = "http://www.moviemeter.nl/film/searchresults', Line) <> 0 then
begin
PickTreeClear;
PickTreeAdd('Zoekresultaten voor ' + MovieName, '');
// get results page
Page.Text := GetPage('http://www.moviemeter.nl/film/searchresults');
if Pos('Zoekresultaten in films:', Page.Text) > 0 then
Line := TextBetween(Page.Text, 'Zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
if Pos('Alle zoekresultaten in films:', Page.Text) > 0 then
Line := TextBetween(Page.Text, 'Alle zoekresultaten in films:</p>', '<form action="http://www.moviemeter.nl/film/search/"');
Line := TextBetween(Line, '</p></div>', '<p><br /></p>');
while Pos('filmresults_row', Line) > 0 do
begin
MovieAddress := TextBetween(Line, 'href="', '" >');
MovieTitle := TextBefore(Line, '</p></div>', '');
Line := RemainingText;
HTMLRemoveTags(MovieTitle);
HTMLDecode(MovieTitle);
PickTreeAdd(Trim(MovieTitle), MovieAddress);
end;
// if user picks a movie from the results list, import movie details
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end
else
begin
MovieAddress := TextBetween(Line, '"', '";');
if MovieAddress <> 'http://www.moviemeter.nl/film/' then
// if only 1 movie found --> redirect to movie page
AnalyzeMoviePage(MovieAddress)
else
// no movies found
ShowMessage('Geen zoekresultaat voor "'+MovieName+'".');
end;
Page.Free;
end;
begin
if CheckVersion(3,5,0) then
begin
if StringUtils1_Version >= 2 then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('MovieMeter.nl Import', 'Geef de titel van de film:', MovieName) then
begin
AnalyzeResultsPage('http://www.moviemeter.nl/film/search/'+UrlEncode(MovieName));
end;
end
else
ShowMessage('The file "StringUtils1.pas" is outdated, please find a new version of it (at least version 2)');
end
else
ShowMessage('Dit script vereist een nieuwere versie van Ant Movie Catalog (minstens versie 3.5.0)');
end.
Line := TextBetween(PageText, 'Alternatieve titel', '<br/>');
into Line := TextBetween(PageText, 'Alternatieve titel', ' </p>');