[REL][FR] script dvd-bonus (menus cachés) pour AMC 3.5.0

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
KenoKles
Posts: 2
Joined: 2005-01-28 05:09:45

[REL][FR] script dvd-bonus (menus cachés) pour AMC 3.5.0

Post by KenoKles »

Ce script permet d'ajouter des informations concernant l'accès aux menus cachés à la suite de vos commentaires.
C'est pas encore parfait mais bon, quand ca marche... ca marche! ;).
Le moteur de recherche semble avoir du mal avec les titres compliqués (":", "-",...)

Tout le monde doit déjà le savoir mais pour faire marcher ce script il faut sauvegarder le code ci-dessous dans un fichier ifs (dvd-bonus.ifs) dans le sous repertoire Scripts de AMC.

ATTENTION : comme precisé dans le topic, ce script a été conçu avec AMC 3.5.0 BETA-2

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=Johan Venant
Title=dvd-bonus(Menus cachés)
Description=Ajoute des informations concernant l'accès aux menus cachés dans les commentaires
Site=www.dvd-bonus.com
Language=FR
Version=0.3 (28 Jan 2005)
Requires=3.5.0 BETA-2
Comments=Pas encore parfait mais bon, quand ca marche... ca marche! ;).|Le moteur de recherche semble avoir du mal avec les titres compliqués (":", "-",...)
License=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. |
GetInfo=1

[Options]
Appends=1|1|0=Remplace les commentaires existant|1=S'ajoute aux commentaires existant

***************************************************)

program dvdworld;

uses
    StringUtils7552;

const
    baseUrl = 'http://www.dvd-bonus.com/';
    searchUrl = baseUrl + 'moteur/recherche.php';
    startStr = 'resultat_fiche.php?ID=';
    endStr = '&type=Bonus cachés"';
    dataStrStart = '<strong><span class="paragraphenoir">Comment faire ?</span></strong><br>';
    dataStrEnd = '</span>';
    separatorStart = CRLF+CRLF+CRLF+ '--------------------------------Bonus cachés--------------------------------' + CRLF;
    separatorEnd =   CRLF + '----------------------------------------------------------------------------' + CRLF;
var
    MovieName: string;
Function FindBefore(wordToFind: string; text: string; sPos: Integer):Integer;
var
    iPos, iFound: Integer;
begin
    Text:= Copy(Text, 1, sPos);
    iPos:= Pos(wordToFind, Text);
    iFound:= iPos;
    while iPos > 0 do
    begin
      Delete(Text, 1, iPos);
      iPos:= Pos(wordToFind, Text);
      iFound:= iFound + iPos;
    end;
    result:= iFound;
end;
Procedure searchMovie(title : string);
var
    page,params,address,nodeName: string;
    adrStart,adrEnd: Integer;
    found: Boolean;
begin
    PickTreeClear;
    found := False;
    params := 'mot='+title+'&operateur=et';
    PickTreeAdd('Résultats de la recherche de "' + title + '"', '');
    page := PostPage(searchUrl,URLEncode(params));
    adrEnd := Pos(endStr, page) ;
    while adrEnd > 0 do
    begin
      found := True;
      adrStart := FindBefore( '<a href="../'+startStr,page,adrEnd + Length(endStr))+Length('<a href="../')-1;
      Delete(page, 1, adrStart);
      address := TextBefore(page,'">','');
      Delete(page, 1, Pos('">',page)+1);
      nodeName := TextBefore(page,'</a>','');
      HTMLRemoveTags(nodeName);
      PickTreeAdd(nodeName,address);
      Delete(page, 1, Pos('</a>',page)+1);
      adrEnd := Pos(endStr, page);
    end;
    if found then
    begin
      if PickTreeExec(address)then
        retreiveData(address);
    end
    else
      ShowInformation('Aucun film trouvé pour "' + MovieName + '"');
end;
Procedure retreiveData(address : string);
var
    page,data,curComments: string;
    dataStart,dataEnd : Integer;
begin
    page := GetPage(URLEncode(baseUrl+address));
    dataStart := Pos(dataStrStart, page) + Length(dataStrStart);
    Delete(page,1,dataStart );
    data := TextBefore(page,dataStrEnd,'');
    data := StringReplace(data, #9, '');
    data := StringReplace(data, #10, '');
    data := StringReplace(data, #13, '');
    data := StringReplace(data, '<br>', CRLF);
    HTMLDecode(data)
    HTMLRemoveTags(data);
    data := Trim(data);
    if GetOption('Appends') = 1 then
      SetField(fieldComments, GetField(fieldComments) +  separatorStart + data + separatorEnd)
    else
      SetField(fieldComments, data);
end;

begin
    if CheckVersion(3,5,0) then
    begin
      MovieName := GetField(fieldTranslatedTitle);
      if MovieName = '' then
        MovieName := GetField(fieldOriginalTitle);
      if Input('Importation DVDFR', 'Entrez le titre du film :', MovieName) then
        searchMovie(MovieName);
    end
    else
      ShowError('Ce script requiert une version plus récente de Ant Movie Catalog (au moins la version 3.5)');
end.
Amusez vous bien! :D
Post Reply