Подправил скрипт. Получилось сразу два
За баги лучше не бить, а писать в PM. Постараюсь исправить. К сообщению Гостя от 2005-02-02 не имею никакого отношения, может у него лучше получится.
Code: Select all
// GETINFO SCRIPTING
// Use only for sharereactor.ru releases
(***************************************************
* Movie information import script for: *
* Sharereactor Russian, *
* http://www.sharereactor.ru/ *
* *
* (c) 2003 By AIG *
* corrected by KoSeA & Leonid_Z *
* *
* Update: 18.06.2004 *
* - Fixed some false checkboxes *
* *
* Known issues: *
* - time can't be added to catalog in some cases *
* *
* For use with Ant Movie Catalog 3.4.3 *
* http://www.antp.be/software/moviecatalog *
* *
* The source code of the script can be used in *
* another program only if full credits to *
* script author and a link to Ant Movie Catalog *
* website are given in the About box or in *
* the documentation of the program *
* *
***************************************************)
program Sharereactorru;
var
MovieName: string;
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
PickTreeClear;
LineNr := 0;
LineNr := FindLine('По вашему запросу отобрано', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('По вашему запросу отобрано', '');
AddMoviesTitles(Page, LineNr);
end;
if PickTreeExec(Address) then
begin
Page.Free;
Page := TStringList.Create;
Page.Text := GetPage(Address);
SetField(fieldURL, Address);
AnalyzeMoviePage(Page)
end
Page.Free;
end;
procedure AnalyzeMoviePage(Page: TStringList);
var
Line, Value, value1, cuchr: string;
LineNr, i: Integer;
time_length: Integer;
BeginPos, EndPos: Integer;
begin
// Original Title & TranslatedTitle & Year
LineNr := FindLine('<TD VALIGN="TOP"><IMG SRC=', Page, 0); // Картинка
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('SRC=', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := pos('></TD>', Line);
if EndPos > 0 then
EndPos := EndPos - 1;
Value := copy(Line, BeginPos, EndPos - BeginPos );
GetPicture(Value, False);
end
LineNr := FindLine(' ', Page, LineNr+1); // Поиск имени фильма РУС
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<H1>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 4;
EndPos := pos('</H1>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldTranslatedTitle, Value);
end
LineNr := FindLine(' ', Page, LineNr+1); // Переведенное название
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
end
LineNr := FindLine(' ', Page, LineNr+1); // Год выхода
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
SetField(fieldYear, Value);
end;
//Category
LineNr := FindLine(' ', Page, LineNr+1); // Жанр
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('("', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 2;
EndPos := pos('")', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Режисcер
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldDirector,Value);
end
LineNr := FindLine(' ', Page, LineNr+1); // Актеры
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldActors,value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Описание
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldDescription, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Продюссер
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Продолжительность
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
time_length := strtoint( copy( Value, 0, 1 ), 0) * 60 + strtoint( copy( Value, 2, 3 ), 0 ) * 10 + strtoint( copy( Value, 3, 4 ), 0 );
SetField(fieldLength, inttostr(time_length));
end;
LineNr := FindLine(' ', Page, LineNr+1); // Язык
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldLanguages, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Комментарии
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldComments, Value);
end;
DisplayResults;
end;
procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos,EndPos,AddPos: Integer;
begin
LineNr := LineNr + 10;
Line := Page.GetString(LineNr);
StartPos := pos('<A', Line);
repeat
if StartPos > 0 then
begin
StartPos:=StartPos+8;
EndPos := Length(Line);
Line:=copy(Line,StartPos,EndPos - StartPos);
MovieAddress := copy(Line, 2, pos('">', Line) -2 );
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
HTMLDecode(Movietitle);
PickTreeAdd(MovieTitle, 'http://sharereactor.ru' + MovieAddress);
end;
StartPos := Length(Movietitle)+StartPos;
StartPos := pos('<A', Line);
until StartPos <= 0;
end;
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('IMDb Import', 'Enter the title of the movie:', MovieName) then
begin
AnalyzePage('http://sharereactor.ru/cgi-bin/mzsearch.cgi?search='+UrlEncode(MovieName));
end;
end else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
--------------------------------------------------------------------------------------------------------------------------------------------------------
Code: Select all
// GETINFO SCRIPTING
// Use only for sharereactor.ru releases
(***************************************************
* Movie information import script for: *
* Sharereactor Russian, *
* http://www.sharereactor.ru/ *
* *
* (c) 2003 By AIG *
* corrected by KoSeA & Leonid_Z *
* *
* Update: 18.06.2004 *
* - Fixed some false checkboxes *
* *
* Known issues: *
* - time can't be added to catalog in some cases *
* *
* For use with Ant Movie Catalog 3.4.3 *
* http://www.antp.be/software/moviecatalog *
* *
* The source code of the script can be used in *
* another program only if full credits to *
* script author and a link to Ant Movie Catalog *
* website are given in the About box or in *
* the documentation of the program *
* *
***************************************************)
program Sharereactorru;
var
MovieName: string;
function TextBetween(WholeText: string; BeforeText: string; AfterText: string; var Found: integer ): string;
var
FoundPos: Integer;
WorkText: string;
begin
Result := '';
FoundPos := Pos(BeforeText, WholeText);
if FoundPos = 0 then
Exit;
WorkText := Copy(WholeText, FoundPos + Length(BeforeText), Length(WholeText));
Found := FoundPos + Length(BeforeText);
if AfterText = '\n' then begin
FoundPos := Length(WorkText) + 1;
end else begin
FoundPos := Pos(AfterText, WorkText);
end;
if FoundPos = 0 then
Exit;
Result := Copy(WorkText, 1, FoundPos - 1);
end;
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
PickTreeClear;
LineNr := 0;
LineNr := FindLine('По вашему запросу отобрано', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('По вашему запросу отобрано', '');
AddMoviesTitles(Page, LineNr);
end;
if PickTreeExec(Address) then
begin
Page.Free;
Page := TStringList.Create;
Page.Text := GetPage(Address);
SetField(fieldURL, Address);
AnalyzeMoviePage(Page)
end
Page.Free;
end;
procedure AnalyzeMoviePage(Page: TStringList);
var
Line, Value, value1, cuchr: string;
LineNr, i: Integer;
time_length: Integer;
FoundPos, FoundPos2: Integer;
BeginPos, EndPos: Integer;
begin
// Original Title & TranslatedTitle & Year
LineNr := FindLine('<TD VALIGN="TOP"><IMG SRC=', Page, 0); // Картинка
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('SRC=', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := pos('></TD>', Line);
if EndPos > 0 then
EndPos := EndPos - 1;
Value := copy(Line, BeginPos, EndPos - BeginPos );
GetPicture(Value, False);
end
LineNr := FindLine(' ', Page, LineNr+1); // Поиск имени фильма РУС
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<H1>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 4;
EndPos := pos('</H1>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldTranslatedTitle, Value);
end
LineNr := FindLine(' ', Page, LineNr+1); // Переведенное название
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
end
LineNr := FindLine(' ', Page, LineNr+1); // Год выхода
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
SetField(fieldYear, Value);
end;
//Category
LineNr := FindLine(' ', Page, LineNr+1); // Жанр
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('("', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 2;
EndPos := pos('")', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Режисcер
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldDirector,Value);
end
LineNr := FindLine(' ', Page, LineNr+1); // Актеры
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldActors,value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Описание
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldDescription, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Продюссер
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Продолжительность
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
time_length := strtoint( copy( Value, 0, 1 ), 0) * 60 + strtoint( copy( Value, 2, 3 ), 0 ) * 10 + strtoint( copy( Value, 3, 4 ), 0 );
SetField(fieldLength, inttostr(time_length));
end;
LineNr := FindLine(' ', Page, LineNr+1); // Язык
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldLanguages, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Комментарии
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldComments, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Дополнительно
LineNr := FindLine(' ', Page, LineNr+1); // Рейтинг
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
Value := TextBetween(Line, '</B> ', '/10', FoundPos);
if Value <> '' then begin
HTMLDecode(Value);
for i := 0 to length(Value) do begin
if copy(Value, i, 1) = '.' then begin
Value := copy(Value, 1, i-1);
break;
end;
end;
SetField(fieldRating, Value);
end;
end;
LineNr := FindLine('<TABLE ', Page, LineNr+1);
if LineNr > -1 then
begin
LineNr := FindLine(' ', Page, LineNr+1); // Формат
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldVideoFormat, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Качество
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos+1 );
HTMLDecode(Value);
SetField(fieldMediaType, Value);
end;
LineNr := FindLine(' ', Page, LineNr+1); // Видео
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
Value := TextBetween(Line, '</B> ', ';', FoundPos);
if Value <> '' then begin
Delete( Line, 1, FoundPos - 1 );
HTMLDecode(Value);
SetField(fieldResolution, Value);
end;
Value := TextBetween(Line, '; ', ' fps', FoundPos);
if Value <> '' then begin
Delete( Line, 1, FoundPos - 1 );
HTMLDecode(Value);
SetField(fieldFramerate, Value);
end;
Value := TextBetween(Line, '; ', ' Кбит/с', FoundPos);
if Value <> '' then begin
Delete( Line, 1, FoundPos - 1 );
HTMLDecode(Value);
for i := 0 to length(Value) do begin
if copy(Value, i, 1) = '.' then begin
Value := copy(Value, 1, i-1);
break;
end;
end;
SetField(fieldVideoBitrate, Value);
end;
Value := TextBetween(Line, '; ', '\n', FoundPos);
if Value <> '' then begin
Delete( Line, 1, FoundPos - 1 );
HTMLDecode(Value);
SetField(fieldVideoFormat, Value);
end;
end;
LineNr := FindLine(' ', Page, LineNr+1); // Звук
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
Value := TextBetween(Line, '</B> ', ' kbit/s', FoundPos);
if Value <> '' then begin
Delete( Line, 1, FoundPos - 1 );
FoundPos := Length(Value);
for i := Length(Value) downto 0 do begin
if (copy(Value, i, 1) < '0') or (copy(Value, i, 1) > '9') then begin
Break;
end;
end;
Value := Left( Line, i-2 );
HTMLDecode(Value);
SetField(fieldAudioFormat, Value);
Delete( Line, 1, i-1 );
Value := TextBetween(Line, ' ', ' kbit/s', FoundPos);
if Value <> '' then begin
HTMLDecode(Value);
SetField(fieldAudioBitrate, Value);
end;
end else begin
Value := Trim(TextBetween(Line, '</B> ', '\n', FoundPos));
HTMLDecode(Value);
SetField(fieldAudioFormat, Value);
end;
end;
LineNr := FindLine(' ', Page, LineNr+1); // Размер
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
Value := TextBetween(Line, '</B> ', ' Мб', FoundPos);
if Value <> '' then begin
HTMLDecode(Value);
SetField(fieldSize, Value);
end;
end;
LineNr := FindLine(' ', Page, LineNr+1); // Количество дисков
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
FoundPos := 0;
i := 0;
while pos( 'href', Line ) > 0 do begin
i := i+1;
Delete( Line, 1, pos( 'href', Line ) + 2 );
end;
SetField(fieldDisks, inttostr(i));
end;
end;
DisplayResults;
end;
procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos,EndPos,AddPos: Integer;
begin
LineNr := LineNr + 10;
Line := Page.GetString(LineNr);
StartPos := pos('<A', Line);
repeat
if StartPos > 0 then
begin
StartPos:=StartPos+8;
EndPos := Length(Line);
Line:=copy(Line,StartPos,EndPos - StartPos);
MovieAddress := copy(Line, 2, pos('">', Line) -2 );
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
HTMLDecode(Movietitle);
PickTreeAdd(MovieTitle, 'http://sharereactor.ru' + MovieAddress);
end;
StartPos := Length(Movietitle)+StartPos;
StartPos := pos('<A', Line);
until StartPos <= 0;
end;
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('IMDb Import', 'Enter the title of the movie:', MovieName) then
begin
AnalyzePage('http://sharereactor.ru/cgi-bin/mzsearch.cgi?search='+UrlEncode(MovieName));
end;
end else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.