[UPD][ITA] www.ibs.it

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
seraphico
Posts: 12
Joined: 2007-12-11 18:48:44
Location: Italy

[UPD][ITA] www.ibs.it

Post by seraphico »

Hi all, i've fixed the script when there is only one match for the searched title. that's it:

Code: Select all

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

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

[Infos]
Authors=Claudio Rinaldi ( rinaldiclaudio@gmail.com )
Title=IBS
Description=Get movie info from ibs.it
Site=www.ibs.it
Language=IT
Version=1.0
Requires=3.5.1
Comments=
License=
GetInfo=1

[Options]

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

program InternetBookShop;

uses
  LibSeraph; // Seraphico's functions library

const
  UrlBase = 'http://www.ibs.it';
  QueryBase = UrlBase + '/dvd/ser/serpge.asp?ty=kw&x=';
  QueryFilm = UrlBase + '/dvd/';
  ImagePath = UrlBase + '/locandine/';

  cStartNumRis = 'Titoli 1-'; // Result Number start Marker
  cEndNumRis = ' di ';               // Result Number end Marker
  cStartNumRis1 = 'Un solo titolo '; // Result Number start Marker
  cEndNumRis1 = '.';               // Result Number end Marker
  cStartId = '<a href=http://www.ibs.it/dvd/'; // ID start marker
  cEndId = '>'; // ID end marker
  cStartTitleList = '<b>';            // Title list start marker
  cEndTitleList = '</b>';            // Title list end marker
  cStartTitle = '<b>Titolo</b></td><td'; // Title start marker
  cEndTitle = '</td>';              // Title end marker
  cStartTranslTitle = '<b>Titolo originale</b></td><td';        // Translated title start marker
  cEndTranslTitle = '</td>';         // Translated title end marker
  cStartImg = 'href="javascript:Jackopen(';               // Image start marker
  cEndImg = ')">';             // Image end marker
  cStartCast = '<b>Principali interpreti</b></td><td';              // Actor start marker
  cEndCast = '</td>'; // Actor end marker
  cStartCategory = '<b>Genere</b></td><td';       // Catogory start marker
  cEndCategory = '</td>';            // Category end marker
  cStartDuration = '<b>Dati tecnici</b></td><td';       // Duration start marker
  cEndDuration = '</td>';          // Duration end marker
  cStartCountry = '<b>Paese, Anno</b></td><td';     // Country start Marker
  cEndCountry = '</td>';               // Country end marker
  cStartYear = ''; // Year start marker
  cEndYear = '';                 // Year end marker
  cStartDesc = '<b>Descrizione</b>';         // Description start marker
  cEndDesc = '</span>';                 // Description end marker
  cStartProducer = '<b>Produzione</b></td><td'; // Production start marker
  cEndProducer = '</td>'; // Production end marker
var
  MovieUrl, MovieName, TranslatedStr:  string;

// -----------------------
// ANALYZE MOVIE DATA PAGE
// IN:  none
// OUT: set Ant fields
// -----------------------
procedure AnalyzeMoviePage;
var
  cField,cValue : string;
  iPos : integer;
begin
  // Get packed title main page
  GetCleanPage(MovieUrl);
 
  // FILM IMAGE
  cField := StringReplace(GetValue(cStartImg, cEndImg, true, false),'''','');
  if cField <> '' then
    GetPicture(cField);
 
  // TRANSLATED TITLE
  cValue := GetValue(cStartTitle, cEndTitle, true, true);
  SetField(fieldTranslatedTitle, AnsiUpFirstLetter(AnsiLowerCase(cValue)));

  // ORIGINAL TITLE
  cValue := GetValue(cStartTranslTitle, cEndTranslTitle,true,true);
  SetField(fieldOriginalTitle, AnsiUpFirstLetter(AnsiLowerCase(cValue)));

  cValue := GetValue(cStartCountry, cEndCountry, true, true);
  iPos := pos(',',cValue);
  if ( iPos > 0 ) then begin
    cField := Copy(cValue,1,iPos-1);
    SetField(fieldCountry,cField);
    cField := Copy(cValue,iPos+2,Length(cValue));
    SetField(fieldYear, cField);
  end;
 
  SetField(fieldActors, GetValue(cStartCast, cEndCast, true, true));
  SetField(fieldCategory, GetValue(cStartCategory, cEndCategory, true, true));
  SetField(fieldProducer, GetValue(cStartProducer, cEndProducer, true, true));
  SetField(fieldLength, GetValue(cStartDuration, cEndDuration, true, false));
  SetField(fieldDescription, GetValue(cStartDesc, cEndDesc, true, false));
  SetField(fieldURL, MovieUrl);
end;


// ------------------------------------------------------------------
// FILL PICKTREE CONTROL WITH LINKS & TITLES
// IN: 
// OUT:
// ------------------------------------------------------------------
procedure PickTreeFill;
var
  cFilmId,cFilmTitle: string;
  StartPos,EndPos: integer;
begin
  PickTreeClear;
  repeat
    StartPos := pos(cStartId, Page);
    if StartPos > 0 then begin
      cFilmId := GetValue(cStartId,cEndId,true,false); // Get ID
      cFilmTitle := GetValue(cStartTitleList,cEndTitleList,true,false); // Get Title
      PickTreeAdd(cFilmTitle, QueryFilm + cFilmId);
    end;
  until(StartPos = 0);
end;

// ---------------------------------
// ANALYZE FIRST SEARCH RESULT PAGE:
// IN:  page Url (string)
// OUT: none
// ---------------------------------
procedure AnalyzeSearchPage;
var
  NumRisultati : string;
begin
  GetCleanPage(MovieUrl);
  NumRisultati := GetValue(cStartNumRis, cEndNumRis, true, false);

  if ( NumRisultati = '') then
    NumRisultati := GetValue(cStartNumRis1, cEndNumRis1, true, false);

  if ( NumRisultati = '') then
  begin
    ShowMessage('Title not found / Nessun film trovato.');
    exit;
  end

  MovieUrl := '';
  if NumRisultati = 'trovato' then
    MovieUrl := QueryFilm + GetValue(cStartId,cEndId,false,false)
  else
    begin
      PickTreeFill;
      PickTreeExec(MovieUrl);
    end
end;

// ----------
// MAIN:
// IN:  none
// OUT: none
// ----------
begin
  if not CheckVersion(3,5,0) then
  begin
   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
   exit;
  end;
   
  TranslatedStr := GetField(fieldTranslatedTitle);
  MovieName := GetField(fieldOriginalTitle);
  if (TranslatedStr <> '') then
    MovieName := TranslatedStr;

  if(Input('IBS.it', 'Enter the title of the movie', MovieName)) then
  begin
    MovieUrl := QueryBase + URLEncode(MovieName);
    AnalyzeSearchPage;
    
    if (MovieUrl = '') then
      AnalyzeMoviePage;
  end;
end. 
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks.
I changed version number to 1.1 then.
otreux
Posts: 194
Joined: 2008-10-22 16:55:46

Post by otreux »

thank's but error in:

LibSeraph Seraphico's functions library
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Do you have LibSeraph.pas in your scripts folder? Else you can get it through "update scripts" script or http://update.antp.be/amc/scripts/

But anyway I am not sure that this script still works: for the few movies I tested it returns empty results.
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

antp wrote:But anyway I am not sure that this script still works: for the few movies I tested it returns empty results.
There's a logical error in the script. If you follow script execution you'll see that it uses variable MovieURL for PickTreeExec function, but in the next step it stops executing as it checks if MovieURL is empty :

Code: Select all

    if (MovieUrl = '') then
      AnalyzeMoviePage; 
There are only few cases where MovieURL would be empty (if at all), so I wonder how this should have worked correct ;)

Here's an update from original 1.0 script version, that should fix these issues without using additional variables (as the version above did). It has been tested with few searches that delivered different results (no result, 1 movie only, list of movies).

ibs 1.2: http://www.bad4u.741.com/full/ibs.ifs (copy link into a NEW browser window, do NOT click on it !)
Post Reply