DVDzone2 FR

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
Candyghost

DVDzone2 FR

Post by Candyghost »

Code: Select all

// GETINFO SCRIPTING
// DVDZone2 (Français)

(***************************************************
 *  Movie importation script for:                  *
 *      DVD Zone 2, http://www.dvdzone2.com        *
 *                                                 *
 *  Rewritten by Antoine Potten                    *
 *  Currently it is only possible to get           *
 *  information in english : cookie or session     *
 *  support is needed to change language           *
 *                                                 *
 *  For use with Ant Movie Catalog 3.4.0           *
 *  www.antp.be/software/moviecatalog              *
 *                                                 *
 *  This program is free software; you can         *
 *  redistribute it and/or modify it under the     *
 *  terms of the GNU General Public License as     *
 *  published by the Free Software Foundation;     *
 *  either version 2 of the License, or (at your   *
 *  option) any later version.                     *
 ***************************************************)

program DVDZone2_FR;
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
  Line, MovieItem, MovieTitle, MovieAddress: string;
  TitlePos, BeginPos, EndPos: Integer;
  List: TStringList;
begin
  Line := GetPage(Address);
  PickTreeClear;
  if Pos('</b> : 0 item(s) found<br>', Line) = 0 then
  begin
    PickTreeAdd('Search results from DVDZone2', '');
    BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
    EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
    Line := Copy(Line, BeginPos, EndPos - BeginPos);
    List := TStringList.Create;
    repeat
      TitlePos := Pos('<a href="http://www.dvdzone2.com/dvd/detail.asp', Line);
      if TitlePos > 0 then
      begin
        Delete(Line, 1, TitlePos);
        MovieItem := Copy(Line, 1, Pos('add2basket', Line));
        BeginPos := Pos('"', MovieItem) + 1;
        EndPos := Pos('" class', MovieItem);
        MovieAddress := Copy(MovieItem, BeginPos, EndPos - BeginPos);
        BeginPos := Pos('">', MovieItem) + 2;
        EndPos := Pos('</a>', MovieItem);
        MovieTitle := Copy(MovieItem, BeginPos, EndPos - BeginPos);
        List.Text := MovieItem;
        MovieItem := Trim(List.GetString(3));
        if MovieItem <> '' then
          MovieTitle := MovieTitle + ' [' + MovieItem + ']';
        MovieItem := Trim(List.GetString(9));
        if MovieItem <> '' then
          MovieTitle := MovieTitle + ' (' + MovieItem + ')';
        PickTreeAdd(MovieTitle, MovieAddress);
        Delete(Line, 1, 25);
      end;
    until TitlePos = 0;
    List.Free;
  end;
  if PickTreeExec(Address) then
    AnalyzeMoviePage(Address);
end;

procedure AnalyzeMoviePage(Address: string);
var
  Line, Value, FullValue: string;
  LineNr: Integer;
  BeginPos, EndPos: Integer;
  Page: TStringList;
begin
  Line := GetPage(Address);
  BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  Line := Copy(Line, BeginPos, EndPos - BeginPos);
  
  // title
  BeginPos := Pos('<span class="detail-title">', Line);
  Delete(Line, 1, BeginPos);
  BeginPos := Pos('>', Line) + 1;
  EndPos := Pos('</', Line);
  Value := Copy(Line, BeginPos, EndPos - BeginPos);
  HTMLDecode(Value);
  SetField(fieldTranslatedTitle, Value);
  
  // picture
  BeginPos := Pos('http://www.dvdzone2.com/pictures/big/', Line);
  if BeginPos > 0 then
  begin
    Delete(Line, 1, BeginPos - 1);
    EndPos := Pos('"', Line);
    Value := Copy(Line, 1, EndPos - 1);
    GetPicture(Value, False);
  end;
  
  // description
  BeginPos := Pos('<p>', Line);
  Delete(Line, 1, BeginPos + 2);
  EndPos := Pos(#13, Line);
  Value := StringReplace(Copy(Line, 1, EndPos - 1), '<p>', #13#10#13#10);
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(FieldDescription, Value);

  // rating
  BeginPos := Pos('note globale', Line);
  if BeginPos > 0 then
  begin
    Delete(Line, 1, BeginPos);
    BeginPos := Pos('<b>', Line);
    if BeginPos > 0 then
    begin
      BeginPos := BeginPos + 3;
      EndPos := Pos(',', Line);
      Value := Copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldRating, Value);
    end;
  end;
  
  Page := TStringList.Create;
  BeginPos := Pos('<td height="120" width="50%" class="dvd-detail-border-c" valign="top" align="left">', Line);
  Delete(Line, 1, BeginPos);
  EndPos := Pos('</table>', Line);
  Page.Text := Copy(Line, 1, EndPos);
  
  // titre original
  SetField(fieldOriginalTitle, GetInfo('<b>Titre original', Page));

  // director
  SetField(fieldDirector, GetInfo('<b>Réalisateur(s)', Page));

  // actors
  SetField(fieldActors, StringReplace(GetInfo('<b>Acteurs', Page), ' - ', ', '));
  
  // country
  SetField(fieldCountry, GetInfo('<b>Pays', Page));

  // year
  SetField(fieldYear, GetInfo('<b>Année', Page));

  // studio (producer)
  SetField(fieldProducer, GetInfo('<b>Studio', Page));

  // category
  SetField(fieldCategory, GetInfo('<b>Genres', Page));
  
  // format vidéo
  SetField(fieldVideoFormat, GetInfo('<b>Format vidéo', Page));

  // length
  Value := GetInfo('<b>Durée', Page);
  EndPos := Pos('&', Value);
  SetField(fieldLength, Copy(Value, 1, EndPos - 1));

  // special features (comments)
  BeginPos := Pos('<span class="detail-title">Les Bonus</span>', Line);
  Delete(Line, 1, BeginPos);
  EndPos := Pos('</table>', Line);
  Delete(Line, EndPos, Length(Line));
  FullValue := '';
  repeat
    BeginPos := Pos('</tr>', Line);
    Delete(Line, 1, BeginPos);
    BeginPos := Pos('<tr>', Line);
    if BeginPos > 0 then
    begin
      BeginPos := Pos('<b>', Line);
      if BeginPos > 0 then
      begin
        Value := Copy(Line, BeginPos + 3, Length(Line));
        EndPos := Pos(#10, Value);
        Value := StringReplace(Copy(Value, 1, EndPos - 1), '<br>', ' ');
        HTMLRemoveTags(Value);
        HTMLDecode(Value);
        FullValue := FullValue + '- ' + Value + #13#10;
      end;
    end;
  until (Pos('<tr>', Line) = 0) or (Pos('<b>', Line) = 0);
  if FullValue <> '' then
    SetField(fieldComments, 'Bonus:' + #13#10 + FullValue);

  Page.Free;
  DisplayResults;
end;

function GetInfo(Name: string; Page: TStringList): string;
var
  LineNr, BeginPos, EndPos: Integer;
  Value, Line: string;
begin
  LineNr := FindLine(Name, Page, 0);
  if LineNr > 0 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := Pos(': ', Line) + 7;
    EndPos := Pos('<br>', Line);
    Value := Copy(Line, BeginPos, EndPos - BeginPos);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    Result := Value;
  end else
    Result := '';
end;

begin
  if CheckVersion(3,4,0) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('DVDZone2 (FR) Import', 'Entrer le titre du film:', MovieName) then
    begin
      GetPage('http://www.dvdzone2.com/language.asp?id=fra&dest=dvd');
      AnalyzePage('http://www.dvdzone2.com/dvd/search.asp?t=1&kw=' + UrlEncode(MovieName) + '&kwt=t&pl=all');
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Il n'était qu'en anglais actuellement si ma mémoire est bonne ?
Merci pour ce nouveau script ;) J'ai rajouté les balises

Code: Select all

 pour le rendre plus lisible
Candyghost
Posts: 2
Joined: 2005-01-31 12:01:23

Post by Candyghost »

Je ne l'ai en effet trouvé qu'en anglais. Comme j'avais un peu de temps ce matin, je me suis amusé à le modifier. Par contre j'ai toujours un petit problème pour récupérer la durée.

Ah oui, j'ai aussi oublié de modifier le header avec les commentaire qui disent que pour des raisons de cookies il est pas possible de changer le langue.

Moi je l'ai essayé avec la dernière version finale et j'ai bien récupéré les infos en français.

Comme gt pas enregistré ce matin, je l'ai mis en tant que guest et il m'est pas possible de l'éditer. Si j'ai le temps, j'ajouterais aussi les autres champs comme les sous-titres, les langues,... et je le rajouterais à la fin de ce post.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Candyghost wrote: Ah oui, j'ai aussi oublié de modifier le header avec les commentaire qui disent que pour des raisons de cookies il est pas possible de changer le langue.
Soit j'ai entre-temps activé les cookies dans l'objet qui gère le HTTP sans retester leur fonctionnement, soit à l'époque où j'avais fait l'autre script il y avait un bug dans la gestion des cookies et je ne l'avais pas réessayé récemment.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

En voulant sauver ton script je m'aperçois qu'il y en avait déjà fourni avec le soft pour DVDZone2 FR :??:
Vu qu'il date de juillet, tu ne dois pas avoir la dernière version d'AMC (j'ai corrigé quelques bugs dans la v 3.4.3 plus récemment que ça)
Candyghost
Posts: 2
Joined: 2005-01-31 12:01:23

Post by Candyghost »

En voulant sauver ton script je m'aperçois qu'il y en avait déjà fourni avec le soft pour DVDZone2 FR
Vu qu'il date de juillet, tu ne dois pas avoir la dernière version d'AMC (j'ai corrigé quelques bugs dans la v 3.4.3 plus récemment que ça)
Et moi qui ai passé une partie de ma soirée à fixer le problème de la durée et ajouter la récupération des sous-titres :cry:

J'ai pourtant la version 2004-22-12. Il se peut que j'ai pas desinstallé la version précedente et qu'il aurait pas copié tous les fichiers. Ca m'apprendra :lol:

par contre dans ce script les accents sont des codes html mais ils sont interprétes lors du cut & paste ici...

Code: Select all

// GETINFO SCRIPTING
// DVDZone2 (Français)

(***************************************************
 *  Movie importation script for:                  *
 *      DVD Zone 2, http://www.dvdzone2.com        *
 *                                                 *
 *  Rewritten by Antoine Potten                    *
 *  Adapted by Candyghost                          *
 *  Fixed Lenght + added subtitles                 *
 *                                                 *
 *  For use with Ant Movie Catalog 3.4.3           *
 *  www.antp.be/software/moviecatalog              *
 *                                                 *
 *  This program is free software; you can         *
 *  redistribute it and/or modify it under the     *
 *  terms of the GNU General Public License as     *
 *  published by the Free Software Foundation;     *
 *  either version 2 of the License, or (at your   *
 *  option) any later version.                     *
 ***************************************************)

program DVDZone2_FR;
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
  Line, MovieItem, MovieTitle, MovieAddress: string;
  TitlePos, BeginPos, EndPos: Integer;
  List: TStringList;
begin
  Line := GetPage(Address);
  PickTreeClear;
  if Pos('</b> : 0 item(s) found<br>', Line) = 0 then
  begin
    PickTreeAdd('Search results from DVDZone2', '');
    BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
    EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
    Line := Copy(Line, BeginPos, EndPos - BeginPos);
    List := TStringList.Create;
    repeat
      TitlePos := Pos('<a href="http://www.dvdzone2.com/dvd/detail.asp', Line);
      if TitlePos > 0 then
      begin
        Delete(Line, 1, TitlePos);
        MovieItem := Copy(Line, 1, Pos('add2basket', Line));
        BeginPos := Pos('"', MovieItem) + 1;
        EndPos := Pos('" class', MovieItem);
        MovieAddress := Copy(MovieItem, BeginPos, EndPos - BeginPos);
        BeginPos := Pos('">', MovieItem) + 2;
        EndPos := Pos('</a>', MovieItem);
        MovieTitle := Copy(MovieItem, BeginPos, EndPos - BeginPos);
        List.Text := MovieItem;
        MovieItem := Trim(List.GetString(3));
        if MovieItem <> '' then
          MovieTitle := MovieTitle + ' [' + MovieItem + ']';
        MovieItem := Trim(List.GetString(9));
        if MovieItem <> '' then
          MovieTitle := MovieTitle + ' (' + MovieItem + ')';
        PickTreeAdd(MovieTitle, MovieAddress);
        Delete(Line, 1, 25);
      end;
    until TitlePos = 0;
    List.Free;
  end;
  if PickTreeExec(Address) then
    AnalyzeMoviePage(Address);
end;

procedure AnalyzeMoviePage(Address: string);
var
  Line, Value, FullValue: string;
  LineNr: Integer;
  BeginPos, EndPos: Integer;
  Page: TStringList;
begin
  Line := GetPage(Address);
  BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  Line := Copy(Line, BeginPos, EndPos - BeginPos);
  
  // title
  BeginPos := Pos('<span class="detail-title">', Line);
  Delete(Line, 1, BeginPos);
  BeginPos := Pos('>', Line) + 1;
  EndPos := Pos('</', Line);
  Value := Copy(Line, BeginPos, EndPos - BeginPos);
  HTMLDecode(Value);
  SetField(fieldTranslatedTitle, Value);
  
  // nbr de disques
  BeginPos := Pos('<b>Nombre de disque(s)</b>: ', Line);
  Delete(Line, 1, BeginPos);
  BeginPos := Pos(';', Line) + 1;
  EndPos := Pos('<br', Line);
  Value := Copy(Line, BeginPos, EndPos - BeginPos);
  HTMLDecode(Value);
  SetField(fieldDisks, Value);
  
  // picture
  BeginPos := Pos('http://www.dvdzone2.com/pictures/big/', Line);
  if BeginPos > 0 then
  begin
    Delete(Line, 1, BeginPos - 1);
    EndPos := Pos('"', Line);
    Value := Copy(Line, 1, EndPos - 1);
    GetPicture(Value, False);
  end;
  
  // description
  BeginPos := Pos('<p>', Line);
  Delete(Line, 1, BeginPos + 2);
  EndPos := Pos(#13, Line);
  Value := StringReplace(Copy(Line, 1, EndPos - 1), '<p>', #13#10#13#10);
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  SetField(FieldDescription, Value);

  // rating
  BeginPos := Pos('note globale', Line);
  if BeginPos > 0 then
  begin
    Delete(Line, 1, BeginPos);
    BeginPos := Pos('<b>', Line);
    if BeginPos > 0 then
    begin
      BeginPos := BeginPos + 3;
      EndPos := Pos(',', Line);
      Value := Copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldRating, Value);
    end;
  end;
  
  Page := TStringList.Create;
  BeginPos := Pos('<td height="120" width="50%" class="dvd-detail-border-c" valign="top" align="left">', Line);
  Delete(Line, 1, BeginPos);
  EndPos := Pos('</table>', Line);
  Page.Text := Copy(Line, 1, EndPos);

  // titre original
  SetField(fieldOriginalTitle, GetInfo('<b>Titre original', Page));

  // director
  SetField(fieldDirector, GetInfo('<b>Réalisateur(s)', Page));

  // actors
  SetField(fieldActors, StringReplace(GetInfo('<b>Acteurs', Page), ' - ', ', '));
  
  // country
  SetField(fieldCountry, GetInfo('<b>Pays', Page));

  // year
  SetField(fieldYear, GetInfo('<b>Année', Page));

  // studio (producer)
  SetField(fieldProducer, GetInfo('<b>Studio', Page));

  // category
  SetField(fieldCategory, GetInfo('<b>Genres', Page));
  
  // format vidéo
  SetField(fieldVideoFormat, GetInfo('<b>Format vidéo', Page));

  // length
  Value := GetInfo('<b>Durée', Page);
  EndPos := Pos('min', Value);
  SetField(fieldLength, Copy(Value, 1, EndPos - 2));
  
  // Sous-titres
  BeginPos := Pos('<span class="px11">SOUS-TITRES</span>', Line);
    Delete(Line, 1, BeginPos);
  BeginPos := Pos('</td>', Line);
    Delete(Line, 1, BeginPos);
  BeginPos := Pos('<td class=""dvd-detail-border-left"" align=""center"" valign=""middle"" colspan=""2"">', Line);
    Delete(Line, 1, BeginPos + 96);
  Value := Copy(Line , BeginPos  , Length(Line));
  EndPos := Pos('</td>', Value);
  Value := Copy(Value , 1, EndPos -5);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
  SetField(fieldSubtitles, Value);

  // special features (comments)
  BeginPos := Pos('<span class="detail-title">Les Bonus</span>', Line);
  Delete(Line, 1, BeginPos);
  EndPos := Pos('</table>', Line);
  Delete(Line, EndPos, Length(Line));
  FullValue := '';
  repeat
    BeginPos := Pos('</tr>', Line);
    Delete(Line, 1, BeginPos);
    BeginPos := Pos('<tr>', Line);
    if BeginPos > 0 then
    begin
      BeginPos := Pos('<b>', Line);
      if BeginPos > 0 then
      begin
        Value := Copy(Line, BeginPos + 3, Length(Line));
        EndPos := Pos(#10, Value);
        Value := StringReplace(Copy(Value, 1, EndPos - 1), '<br>', ' ');
        HTMLRemoveTags(Value);
        HTMLDecode(Value);
        FullValue := FullValue + '- ' + Value + #13#10;
      end;
    end;
  until (Pos('<tr>', Line) = 0) or (Pos('<b>', Line) = 0);
  if FullValue <> '' then
    SetField(fieldComments, 'Bonus:' + #13#10 + FullValue);

  Page.Free;
  DisplayResults;
end;

function GetInfo(Name: string; Page: TStringList): string;
var
  LineNr, BeginPos, EndPos: Integer;
  Value, Line: string;
begin
  LineNr := FindLine(Name, Page, 0);
  if LineNr > 0 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := Pos(': ', Line) + 7;
    EndPos := Pos('<br>', Line);
    Value := Copy(Line, BeginPos, EndPos - BeginPos);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    Result := Value;
  end else
    Result := '';
end;

begin
  if CheckVersion(3,4,0) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('DVDZone2 (FR) Import', 'Entrez le titre du film:', MovieName) then
    begin
      GetPage('http://www.dvdzone2.com/language.asp?id=fra&dest=dvd');
      AnalyzePage('http://www.dvdzone2.com/dvd/search.asp?t=1&kw=' + UrlEncode(MovieName) + '&kwt=t&pl=all');
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
Post Reply