i tried myself on writing a picture import script.
thats the code so far, please could someone with more experience help me.
as i'm not really into programming there will be many errors in it, and it doesn't work yet.
so please could someone teach me how to get this one to work.
Code: Select all
program DVDasian;
// search pc-id
Function pcID:string;
var
HomePageText:string;
begin
HomePageText := GetPage('http://www.dvdasian.com/');
pcID := TextBetween(HomePageText, 'ACTION="http://www.dvdasian.com/cgi-bin/dvdasian/search.html?', '">');
end;
// movie search
Procedure SearchMovie(Name:string; id:string);
var
ResultsPage:string;
begin
PostPage('http://www.dvdasian.com/cgi-bin/dvdasian/search.html?' + 'id', URLEncode(Name));
Sleep(1000);
ResultsPage := GetPage('http://www.dvdasian.com/cgi-bin/dvdasian/search.html?' + 'pcID');
if Pos('No item is found for', ResultsPage) > 0 then
begin
ShowMessage('No movie found for this search');
end
else
begin
PickTreeClear;
until not AddMovieTitles(ResultsPage);
if PickTreeExec(Address) then
GetPicture(Address);
end;
end;
// getting pictureaddress
function AddMovieTitles(List: string): Boolean;
var
Value: string;
Address: string;
name: string;
begin
Value := TextBetween(List, '<TD width="90" VALIGN="top">', 'BORDER="0"></A><BR>');
List := RemainingText;
while Value <> '' do
begin
name := TextBetween(Value, 'ALT="', '"');
Address := TextBetween(Value, '<IMG SRC="', '.1.jpg"');
PickTreeAdd(name, 'http://dvdasian.com' + Address + '.3.jpg');
Value := TextBetween(List, '<TD width="90" VALIGN="top">', 'BORDER="0"></A><BR>');
List := RemainingText;
end;
AddMovieTitles := True;
end;
// program
var
MovieName:string;
begin
MovieName := '';
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
Input('DVDasian.com Import', 'Enter the title of the movie:', MovieName) Exit;
end
if MovieName <> '' then
begin
SearchMovie(MovieName, pcID);
end
Vagnard