After a total redesign and VERY long time of beta testing, the development of FILMSTARTS.de seems now to be stable for a while and so I decided to write a complete new script for it. Because of some page design changes, the script functionality also has changed slightly. Take a look in the options.
It´s roughly tested but should work for most of the movies.
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=J
Title=Filmstarts.de
Description=Script for Filmstarts.de with options
Site=www.filmstarts.de
Language=DE
Version=2.0.1 - 11/01/2011
Requires=3.5.0
Comments=V 1.0.0|Only description & big poster import||V 1.1.0|Import of all data with options||V1.1.1|Added selection for IMDB at rating option|Added IMDB-Rating fom Filmstarts.de if available|Small Code changes - no change of functionality||V1.2|Adaption to several site changes|No new functionality||V2.0.1|Totally new rewritten script after filmstarts.de redesign|Some different options.
License=IMPORTANT NOTICE:||THIS SCRIPT IS FOR PERSONAL USE ONLY ! |DO NOT REDISTRIBUTE ANY DATA WITHOUT THE PERMISSION OF THE COPYRIGHT OWNER ! RESPECT COPYRIGHTS !||The script itself 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]
Title=3|3|0=No import|1=German --> original|2=German --> translated|3=German --> original & Original --> translated|4=German --> translated & Original --> original
Review=4|4|0=No review or comments import|1=Review --> description|2=Review --> comments|3=Review --> description & guest comment --> comments|4=Summary --> description & Reviev --> comments
Actors=2|2|0=No import|1=Only actor names, separated by commas|2=Actors names with character names between parenthesis separated by commas
Rating=1|1|0=No import|1=FILMSTARTS rating|2=press average
Picture=2|2|0=No import|1=Small poster|2=Big poster
Category=1|1|0=No import|1=Oh yes, import me pls!
***************************************************)
// FILMSTARTS.de - Script Version 2.0 (20110111/J)
//
// v2.0.1 - 11/01/2011 - Totally new version after page redesign
program FILMSTARTS;
uses
StringUtils1;
var
MovieName: string;
procedure AnalyzePage(Address: string);
var
PageText, RealAddress, TextBody, Value, Value1: string;
Counter: Integer;
begin
Value := '';
Value1 := '';
TextBody := '';
Counter := 0;
// ***** Find movie(s)
begin
PageText := GetPage(Address);
PageText := UTF8Decode(PageText);
PickTreeClear;
// Looking for search result(s)
If Pos('Filme</h2>', PageText) = 0 then
// No movie found
begin
ShowMessage('Leider keinen Film zu diesem Namen gefunden.');
Exit;
end;
// Get movie list
begin
TextBody := TextBetween(PageText, 'totalwidth">', '/table');
Value := FullTrim(TextBetween(TextBody, 'html' + #39 + '>', '</a>'));
Value := StringReplace(value, '<b>', '');
Value := StringReplace(value, '</b>', '');
Value := Value + ' (' + FullTrim(TextBetween(TextBody, 'fs11">', '<br')) + ')';
RealAddress := 'http://www.filmstarts.de/kritiken/' + TextBetween(TextBody, 'kritiken/', 'html') + 'html';
PickTreeAdd(Value, RealAddress);
Counter := Counter + 1;
// More than one result?
while Pos('totalwidth', TextBody) <> 0 do
begin
// Name & real movie URL
Delete (TextBody, 1 , Pos('totalwidth', TextBody));
Value := FullTrim(TextBetween(TextBody, 'html' + #39 + '>', '</a>'));
Value := StringReplace(value, '<b>', '');
Value := StringReplace(value, '</b>', '');
Value := Value + ' (' + FullTrim(TextBetween(TextBody, 'fs11">', '<br')) + ')';
RealAddress := 'http://www.filmstarts.de/kritiken/' + TextBetween(TextBody, 'kritiken/', 'html') + 'html';
PickTreeAdd(Value, RealAddress);
Counter := Counter + 1;
end;
// Choose movie from list if more than one
If counter > 1 then PickTreeExec(RealAddress);
// Load movie-page
PageText := GetPage(RealAddress);
PageText := UTF8Decode(PageText);
end
end;
// ***** Title
begin
// German title
Value := FullTrim(TextBetween(PageText, '<h1 property="v:name">', '</h1>'));
// Original title <> German title?
if Pos('Originaltitel', PageText) > 0 then
begin
Value1 := TextBetween(PageText, 'class="purehtml"><em>', '</em>');
end
else
Value1 := Value;
case GetOption('Title') of
1:
setField (fieldOriginalTitle, Value);
2:
setField (fieldTranslatedTitle, Value);
3:
begin
setField (fieldOriginalTitle, Value);
setField (fieldTranslatedTitle, Value1);
end;
4:
begin
setField (fieldTranslatedTitle, Value);
setField (fieldOriginalTitle, Value1);
end;
end;
end;
// ***** Picture
begin
Value := TextBetween(PageText, 'r_160_214/b_1_cfd7e1/medias/nmedia/', #39);
If Value <> '' then
begin
case GetOption('Picture') of
1:
GetPicture('http://bilder.filmstarts.de/r_160_214/b_1_cfd7e1/medias/nmedia/' + Value);
2:
begin
GetPicture('http://bilder.filmstarts.de/r_760_x/medias/nmedia/' + Value);
end;
end;
end;
end;
// ***** Rating
case GetOption('Rating') of
1:
begin
Value := FloatToStr(StrToFloat(TextBetween(PageText, 'stareval n', ' '))/5);
setField (fieldRating, Value);
end;
2:
begin
if pos('Presseschnitt', PageText) >0 then
begin
Textbody := TextBetween(PageText, 'Presseschnitt', ')');
Value := TextAfter(Textbody, '(');
Value := StringReplace(Value, ',', '.');
Value := FloatToStr(StrToFloat(Value)*2);
setField(fieldRating, Value);
end;
end;
end;
// ***** Countries
begin
Textbody := TextBetween(PageText, 'Produktionsland', 'Genre');
Value := TextBetween(Textbody, '">', '<');
Delete (Textbody, 1, Pos('</', Textbody));
while Pos('">', Textbody) > 0 do
begin
Value := Value + ', ' + TextBetween(Textbody, '">', '<');
Delete (Textbody, 1, Pos('</', Textbody));
end;
Value := StringReplace(Value, 'Vereinigte Staaten', 'USA');
setField(fieldCountry, Value);
end;
// ***** Categories
If GetOption('Category') =1 Then
begin
Textbody := TextBetween(PageText, 'Genre', '<br />');
Value := TextBetween(Textbody, '">', '<');
Delete (Textbody, 1, Pos('</', Textbody));
while Pos('">', Textbody) > 0 do
begin
Value := Value + ', ' + TextBetween(Textbody, '">', '<');
Delete (Textbody, 1, Pos('</', Textbody));
end;
setField(fieldCategory, Value);
end;
// ***** Lenght
Value := FullTrim(TextBetween(PageText, 'Laufzeit:', ' Minuten'));
setField(fieldLength, Value);
// ***** Year
Textbody := TextBetween(PageText, 'Produktionsjahr', '/span');
Value := TextBetween(Textbody, '">', '<');
setField(fieldYear, Value);
// ***** URL *****
setField(fieldURL, RealAddress);
// ***** Description / Summary & Comments
begin
Value1 := TextBetween(PageText, 'summary">', '</span>');
HTMLRemoveTags(Value1);
if Pos('kritik.html', PageText) <> 0 then
begin
Address := StringReplace(RealAddress, '.html', '/kritik.html');
// Load description-page
PageText := GetPage(Address);
Value := TextBetween(PageText, 'purehtml">', '</p>');
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
// Deletes old formatting CR
while Pos(#13#10 + #13#10 + #13#10, Value) > 0 do
Value := StringReplace(Value, #13#10+#13#10+#13#10, #13#10);
case GetOption('Review') of
1:
setField (fieldDescription, Value);
2:
setField (fieldComments, Value);
3:
begin
setField (fieldDescription, Value);
If Pos('gastkritiken.html', PageText) > 0 then
begin
Address := StringReplace(RealAddress, '.html', '/gastkritiken.html');
// Load user-comments-page
PageText := GetPage(Address);
TextBody := TextBetween(PageText, 'Kritik:', 'morezone');
TextBody := UTF8Decode(TextBody);
while Pos('/mainzone', TextBody) <> 0 do
begin
Value := FullTrim(TextBetween(TextBody, '</span>', '</p>'));
// Add comment to selection list
PickListAdd(Value);
TextBody := TextAfter (TextBody, 'Kritik:');
end;
// Choose comment from list
PickListExec('Wählen sie einen Kommentar für "' + GetField(fieldOriginalTitle) + '"', Value1)
while Pos(#13#10 + #13#10 + #13#10, Value1) > 0 do
Value1 := StringReplace(Value1, #13#10+#13#10+#13#10, #13#10);
SetField (fieldComments, Value1);
end;
end;
4:
begin
setField (fieldComments, Value);
setField (fieldDescription, Value1);
end;
end;
end
else setField (fieldDescription, Value1);
end;
// ***** Director(s)
begin
Address := StringReplace(RealAddress, '.html', '/castcrew.html');
// Load actors-page
PageText := GetPage(Address);
PageText := UTF8Decode(PageText);
TextBody := TextBetween(PageText, '<h3>', '<h2>');
Value := TextBetween(TextBody, 'E48">', '</span>');
Delete (Textbody, 1, Pos('</h3>', Textbody));
while Pos('<h3>', Textbody) > 0 do
begin
Delete (Textbody, 1, Pos('<h3>', Textbody));
Value := Value + ', ' + TextBetween(Textbody, 'E48">', '</span>');
Delete (Textbody, 1, Pos('</h3>', Textbody));
end;
setfield (fieldDirector, Value);
end;
// ***** Actors & voices
Value := '';
Counter := GetOption('Actors');
If counter > 0 then
begin
// Actors
If Pos('<h2>Schauspieler', PageText) > 0 then
begin
TextBody := TextBetween(PageText, '<h2>Schauspieler', '<h2>');
case Counter of
1,2:
begin
while Pos('<h3>', TextBody) > 0 do
begin
Value1 := TextBetween(TextBody, '<h3>', '"spacer"');
if (Counter = 2) then Value := Value + TextBetween(Value1, '">', '</') + ' (' + FullTrim(TextBetween(Value1, 'Rolle: ', '</p>')) + '), '
else Value := Value + TextBetween(Value1, '">', '</') + ', ';
Delete (Textbody, 1, Pos('</h3>', TextBody));
end;
// Delete last comma (if no voices)
If Pos('<h2>Synchronstimmen', PageText) = 0 then Delete (Value, length(Value) - 1, 1);
end;
end;
end;
// Voices
If Pos('<h2>Synchronstimmen', PageText) > 0 then
begin
TextBody := TextBetween(PageText, '<h2>Synchronstimmen', '<h2>');
case Counter of
1,2:
begin
while Pos('<h3>', TextBody) > 0 do
begin
Value1 := TextBetween(TextBody, '<h3>', '"spacer"');
if (Counter = 2) then Value := Value + TextBetween(Value1, '">', '</') + ' (' + FullTrim(TextBetween(Value1, 'Rolle: ', '</p>')) + '), '
else Value := Value + TextBetween(Value1, '">', '</') + ', ';
Delete (Textbody, 1, Pos('</h3>', TextBody));
end;
// Delete last comma
Delete (Value, length(Value) - 1, 1);
end;
end;
end;
setField (fieldActors , Value);
end;
end; // End of procedure AnalyzePage
// ***** Start of program
begin
if AcceptLicense(1) = False then
Exit;
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('Filmstarts.de Import', 'Enter the title of the movie:', MovieName) then
begin
// FILMSTARTS.de handles apostrophes with different & changing characters in search function and title-URL,
// but works mostly with auto-cutting apostrophe and rest of word. (e.g. I´ve --> I).
// -- If that wouldn´t work, type in title without apo-word (e.g. "not there" instead of "i´m not there")
MovieName := StringReplace (MovieName, #39, '´');
if Pos('´', MovieName) > 0 then
Delete (MovieName, Pos('´', MovieName), Length(TextBetween(Moviename, '´', ' ')) + 1);
// Needed for internat. special characters like german Umlaute
MovieName := UTF8Encode(MovieName);
// Use FILMSTARTS.de internal search function to get working title-URL
AnalyzePage('http://www.filmstarts.de/suche/1/?q='+UrlEncode(MovieName));
end;
end
else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.