Page 1 of 1

problems with charakters

Posted: 2002-12-20 00:20:52
by Luckybigpack
I just tried to write my first script and after hours I'm really close to get it. It's Just for importing covers and I need to get an URL like "...&search=...", but all I get from AMC is "...search=...". :(
Is there a posibility that I get a & in my URL??

Posted: 2002-12-20 04:32:46
by Twink
you may need to put a \ in front of the & to make it appear (can't really remember)

Posted: 2002-12-20 05:24:56
by luckybigpack
Nope, no chance. another proposal?
Or maybe one one you could write a script for getting the posters from that page?
http://www.allposters.com/

Posted: 2002-12-20 09:57:29
by antp
No, "\" has no special meaning in Pascal (unlike in some other languages).
If you do a ShowMessage it will display the letter following the "&" in underline. It is a Windows feature, like in the menus, you set &File as caption and it will display it as File, alt Alt+F will allow to access to it.
But event if it does not display right, it is right in the Pascal variable and it is right when sent to the server. So the problem should be somewhere else.

Posted: 2002-12-20 10:00:33
by antp
The URL seems to be:

http://www.allposters.com/GetThumb.asp? ... movietitle

You will need to disable javascript in your browser to avoid the frame when going to direct URL, but for the script it should not be a problem...

Posted: 2002-12-20 17:35:50
by Guest
The URL is:
http://www.allposters.com/gallery.asp?c=c&search= + MovieAddress
which you get from that page you pointed to. It is a numeric code.but disabling Javascript doesnt seem to work...Maybe you could try it, when you have some time?

Posted: 2002-12-20 20:45:12
by antp
My URL works when disabling javascript
Yours does not seem to work.

Posted: 2002-12-20 21:45:00
by Guest
Maybe you could take a look at my script and tell me whats wrong...:
procedure AddMoviesTitles();
var
Line, value: string;
Page: TStringList;
LineNr: Integer ;
MovieTitle, MovieAddress: string;
StartPos, beginpos, endpos, endp: Integer;
MovieURL: String;
begin
MovieName := GetField(fieldOriginalTitle);
Page := Tstringlist.create;
Page.Text := GetPage('http://www.allposters.com/GetThumb.asp?txtSearch=' + UrlEncode(MovieName));
//showMessage(Page.Text);
LineNr:= FindLine('<title>AllPosters.com Thumbnails', Page, LineNr);
// if LineNr = 0 then
//begin
LineNr := 0;
LineNr := FindLine('<a href="GetThumb.asp?c=c&search=', Page, LineNr);
Line := Page.GetString(LineNr);
//showMessage(Line);
StartPos := pos('<a href="GetThumb.', Line)+9;
endp := pos('search=', Line)+12 ;
if StartPos > 0 then
begin
Startpos := Startpos ;
MovieAddress := copy(Line, StartPos, endp - startpos );
//showMessage(MovieAddress)
//StartPos := pos('">', Line) + 2;
//MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
// HTMLDecode(Movietitle);
//if Length(Result) <= 0 then
MovieURL :=MovieAddress;
showMessage(MovieURL);
begin
// Picture
Page.Text := GetPage(MovieURL) ;
ShowMessage(Page.Text);

// end else
LineNr := 0 ;
LineNr := FindLine('<img src="http://imagecache2.allposters.com/images/', Page, 0);
if LineNr < 0 then
LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
ShowMessage(Line);
BeginPos := pos('<img src="http://imagecache2.allposters.com/images/', Line) + 9;
Delete(Line, 1, BeginPos);
EndPos := pos('"', Line);
Value := copy(Line, 1, EndPos - 1);
showMessage(Value);
// GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end;
end ;
end;
end;

Posted: 2002-12-20 21:58:42
by antp
Next time put the code between [code] and [/code] ;)

Posted: 2002-12-20 22:00:01
by antp
What's the problem actually :??:
And what's this code ? It is only a procedure, not a full program.

Posted: 2002-12-20 22:44:59
by Guest
Yes, it's the procedure of getting the poster. As you see, I have some ShowMessages in it and one shows the actual URL, which is besides the '&' correct, but the one which shows the page.text always shows the text of the Main Page. When I enter the URL manually in the Browser, It works...
Here's the complete Code:

Code: Select all

program batch;
const
  // Set the following constants to True to import field, or False to skip field
  ImportURL = false;
  ImportOriginalTitle = false;
    ImportTranslatedTitle = false;
      LeaveOriginalTitle = True; // True will get Translated Title, yet Original Title field will remain same
  ImportYear = false;
  ImportRating = false;
  ImportPicture = True;
    ImportLargePicture = true; // If set to False small pic will be imported
  ImportDirector = false;
  ImportActors = false;
  ImportCountry = false;
  ImportCategory = false;
  ImportDescription = false;
    UseLongestDescription = False; // If set to False shortest description available will be imported
  ImportComments = false;
  ImportLength = True;
  ImportLanguage = false;
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 AddMoviesTitles();
var
  Line, value: string;
  Page: TStringList;
  LineNr: Integer ;
  MovieTitle, MovieAddress: string;
  StartPos, beginpos, endpos, endp: Integer;
  MovieURL: String;
begin
  MovieName := GetField(fieldOriginalTitle);
  Page := Tstringlist.create;
  Page.Text := GetPage('http://www.allposters.com/GetThumb.asp?txtSearch=' + UrlEncode(MovieName));
  //showMessage(Page.Text);
  LineNr:=  FindLine('<title>AllPosters.com Thumbnails', Page, LineNr);
 // if LineNr = 0 then
  //begin
    LineNr := 0;
    LineNr := FindLine('<a href="GetThumb.asp?c=c&search=', Page, LineNr);
    Line := Page.GetString(LineNr);
    //showMessage(Line);
    StartPos := pos('<a href="GetThumb.', Line)+9;
    endp := pos('search=', Line)+12 ;
    if StartPos > 0 then
    begin
      Startpos := Startpos ;
      MovieAddress := copy(Line, StartPos, endp - startpos );
      //showMessage(MovieAddress)
      //StartPos := pos('">', Line) + 2;
      //MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
     // HTMLDecode(Movietitle);
      //if Length(Result) <= 0 then
        MovieURL :=MovieAddress;
        showMessage(MovieURL);
         begin
     // Picture
        Page.Text := GetPage(MovieURL)     ;
        ShowMessage(Page.Text);

         // end else
       LineNr := 0    ;
       LineNr := FindLine('<img src="http://imagecache2.allposters.com/images/', Page, 0);
    if LineNr < 0 then
      LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', Page, 0);
    if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      ShowMessage(Line);
      BeginPos := pos('<img src="http://imagecache2.allposters.com/images/', Line) + 9;
      Delete(Line, 1, BeginPos);
      EndPos := pos('"', Line);
      Value := copy(Line, 1, EndPos - 1);
      showMessage(Value);
     // GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
     end;
      end ;
    end;
  end;
begin
  if CheckVersion(3,4,0) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if MovieName = '' then
      MovieName := Input('IMDb Import', 'Enter the title of the movie:', MovieName);
    if MovieName <> '' then
    begin
//      AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName)+'&restrict=Movies+only');
      AddMoviesTitles();
      //ShowMessage('http://www.allposters.com/GetThumb.asp?txtSearch='+UrlEncode(MovieName));
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
As you see, I only took the Imdb(batch) Code and tried to change it. I said already that It was my first time programming...:)

Posted: 2002-12-20 23:32:46
by antp
That's quite difficult to say where's the problem. The code is not very clear, and it is always even harder to read someone else's code :/

Posted: 2002-12-21 00:17:10
by luckybigpack
[quote="Anonymous"]

Code: Select all

      LineNr := FindLine('<a href="GetThumb.asp?c=c&search=', Page, LineNr);
    Line := Page.GetString(LineNr);
    //showMessage(Line);
    StartPos := pos('<a href="GetThumb.', Line)+9;
    endp := pos('search=', Line)+12 ;
    if StartPos > 0 then
    begin
      Startpos := Startpos ;
      MovieAddress := copy(Line, StartPos, endp - startpos );
      //showMessage(MovieAddress)
      //StartPos := pos('">', Line) + 2;
      //MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
     // HTMLDecode(Movietitle);
      //if Length(Result) <= 0 then
        MovieURL :='www.allposters.com/gallery.asp?c=c&search=' +movieAddress;
        showMessage(MovieURL);
Here I get an Adress like:
http://www.allposters.com/gallery.asp?c=c[u]s[/u]earch=13280
instead of
http://www.allposters.com/gallery.asp?c=c&search=13280
But as you said, that doesn't matter

Code: Select all

         begin
     // Picture
        Page.Text := GetPage(MovieURL)     ;
        ShowMessage(Page.Text);
But here I get the code of the mainpage. I tried entering the URL in the Browser and it worked, but as soon as one character is missing or false I land on the Mainpage, so I thought it has to be somewhere in the part shown above...
The next part does actually funtion as it should.

Code: Select all


         // end else
       LineNr := 0    ;
       LineNr := FindLine('<img src="http://imagecache2.allposters.com/images/', Page, 0);
    if LineNr < 0 then
      LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', Page, 0);
    if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      ShowMessage(Line);
      BeginPos := pos('<img src="http://imagecache2.allposters.com/images/', Line) + 9;
      Delete(Line, 1, BeginPos);
      EndPos := pos('"', Line);
      Value := copy(Line, 1, EndPos - 1);
      showMessage(Value);
I really hope, somone can help, or tell me, where to get a script, which imports pictures of that quality...

Posted: 2002-12-21 11:08:01
by antp
Why do not you use http://www.allposters.com/GetThumb.asp?txtSearch= + Movietitle as URL ?
The Gallery.asp page seems to be only the frameset, so it does not containt anything useful...
E.g. for the link you gave the "real" page is http://www.allposters.com/getposter.asp ... &fid=13280

Posted: 2002-12-21 11:32:36
by luckybigpack
Yes, I know that this is the real URL, but I don't know how to get that number after apnum...I also tried that link:
http://www.allposters.com/GetThumb.asp?txtSearch= + Movietitle
but on that site I didn't get a link for the Poster. There is just a link to another site which contains the Poster...

Posted: 2002-12-21 15:53:53
by antp

Posted: 2002-12-21 18:32:23
by luckybigpack
yes, for matrix you're right. but try it with the four feathers. it won't work.

Posted: 2002-12-21 18:53:38
by antp
You have to use the URLEncode function to make the movie title compliant.
So four feathers will become either four+feathers or four%20feathers.
Both seems to work fine on the site ;)

Posted: 2002-12-22 11:58:01
by luckybigpack
Thans for helping me, but I gave up... :( Maybe someday someone who knows what he's doing writes a script for importing HiQuality Pictures. That will be my Christmas! ;)