Page 1 of 1

New German Script (for www.darktown.com)

Posted: 2002-12-28 17:30:43
by luckybigpack
As I had lots of time I tried my second script for importing covers @ darktown.com...it is a batch script and it is working! :D But I still have few problems:
first, the code:

Code: Select all

program batch;
var
  MovieName: string;

procedure AddMoviesTitles();
var
  Value, Value2, Value3: string;
  Line, moviename2: string;
  MovieAddress: string;
  StartPos, endp: Integer;
  MovieURL: String;
begin
  MovieName := GetField(fieldTranslatedTitle);
  moviename:= ansilowercase(moviename);
    Value := (Moviename);
    Line:=Moviename;
    Value2 := '';
    if  Pos(',', value) <> 0  then
    begin

    startpos:=0;
    endp:=0;
     startpos:= Pos(Moviename, line)  ;
     endp := pos(',',line)-2;
        Value2 := Copy(Value, 1, endp+startpos);
    startpos:=0;
    endp:=0;
     startpos:= Pos(',',line)+2  ;
     endp := pos(Moviename, Line);
        Value3 := Copy(Value, startpos, endp+startpos);

     Moviename:=value3+' '+value2   ;
     end;
        moviename2:=StringReplace(Moviename,' ','_');
        moviename2:=StringReplace(Moviename2,'ß','ss');
        moviename2:=StringReplace(Moviename2,'!','');
        moviename2:=StringReplace(Moviename2,'?','');
        moviename2:=StringReplace(Moviename2,'.','');
        moviename2:=StringReplace(Moviename2,'ä','ae');
        moviename2:=StringReplace(Moviename2,'ö','oe');
        moviename2:=StringReplace(Moviename2,'ü','ue');
        moviename2:=StringReplace(Moviename2,':','_-');
            Line := (Moviename);
    startpos:=0;
    endp:=0;
     StartPos := pos(Moviename, Line);
     endp := pos(Moviename, Line)+1 ;
        MovieAddress := copy(Line, StartPos, endp - startpos );
         movieURL:='http://img.darktown.com/cover/vcd/download/'+movieaddress+'/'+moviename2+'_a.jpg' ;
         showmessage(movieurl);
     GetPicture(MovieURL, False); // False = do not store picture externally ; store it in the catalog file
     end;
begin
  if CheckVersion(3,4,0) then
  begin
      MovieName := GetField(fieldTranslatedTitle);
    if MovieName = '' then
      MovieName := Input('IMDb Import', 'Enter the title of the movie:', MovieName);
    if MovieName <> '' then
    begin
      AddMoviesTitles();
    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 had to replace certain characters to fit in the script. Now I wanted to replace the ' with nocthing, but i didn't get it.
Second, there are lots of "404 not found"-errors, because that way of getting the pictures is not the best way. How can i remove these messages automatically? I want that script to run over night, and it isn't very satisfiing, when I come back in the morning, and the script isn't through because of that error message...

PS.:As soon as I had that script finished, darktown included a search-routine on the page. Maybe someone could write a script using the search routine?that should get lot more covers than my script...

Posted: 2002-12-28 17:35:58
by antp
It is not possible to bypass the error for the moment.
To replace the ' by nothing simply do:

Code: Select all

s := StringReplace(s, '''', '');
where s = the string to modify