Цитата: Как там обстоят дела со скриптом для sharereactor'а?
Наконец-то добрались
Код: // 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;
BeginPos, EndPos: Integer;
begin
// Original Title & TranslatedTitle & Year
LineNr := FindLine(' ', Page, 0); //Поиск имени фильма РУС
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(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('</B>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 5;
EndPos := Length(Line);
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 );
HTMLDecode(Value);
SetField(fieldLength, 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(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); //Дополнительно
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 );
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 );
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 := Value+ ', ' + copy(Line, BeginPos, EndPos - BeginPos+1 );
value:='';
HTMLDecode(Value);
SetField(fieldVideoFormat, Value);
end;
end;
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 );
value:='';
HTMLDecode(Value);
SetField(fieldResolution, 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 );
value:='';
HTMLDecode(Value);
SetField(fieldAudioFormat, 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 );
value:='';
HTMLDecode(Value);
SetField(fieldSize, Value);
end;
LineNr := FindLine('/covers/', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<I', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 1;
EndPos:=Length(Line);
Line := copy(Line, BeginPos,EndPos-BeginPos);
Value := copy(Line,10, pos('">', Line) - 10 );
Value := 'http://sharereactor.ru'+Value;
GetPicture(Value, False);
end
else
begin
LineNr := FindLine('amazon.com/', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<I', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 1;
EndPos:=Length(Line);
Line := copy(Line, BeginPos,EndPos-BeginPos);
Value := copy(Line,10, pos('">', Line) - 10 );
GetPicture(Value, False);
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.