[REL][ITA] AlCinemaInCasa.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

[REL][ITA] AlCinemaInCasa.it

Post by seraphico »

This is the script for www.alcinemaincasa.it i've not tested too much if there's something wrong let me know. :grinking:

Code: Select all

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

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

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

[Options]

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

program AlCinemaInCasaIT;

uses
  Pivlib; // Pivello's scripts common library

const
  UrlBase = 'http://www.alcinemaincasa.it';
  UrlRicerca = '&ORDER=prodottoasc';
  QueryBase = UrlBase + '/commy/prodotti_lista_public.asp?action=Cerca&TX_CM_PRODOTTO=';
  QueryFilm = UrlBase + '/commy/prodotti_view.asp?PRODOTTO_ID=';
  ImagePath = UrlBase + '/locandine/';

  cStartNumRis = '</span> di ';
  cEndNumRis = '</td>';
  cStartId = 'PRODOTTO_ID=';
  cEndId = '"';
  cStartTitle = 'CommyHeading4';
  cEndTitle = '</h1>';
  cStartTranslTitle = 'Titolo Originale</strong>: ';
  cEndTranslTitle = '</h2>';
  cStartImg = 'CommyThumbsAna" src="';
  cEndImg = '" alt';
  cStartDirector = 'Regista</li>';
  cEndDirector = '</li>';
  cStartCast = 'Attori</li>';
  cEndCast = '</li>';
  cStartCategory = 'Genere</li>';
  cEndCategory = '</li>';
  cStartDuration = 'Durata</li>';
  cEndDuration = '</li>';
  cStartCountry = 'Nazionalità</strong>:';
  cEndCountry = ' ';
  cStartYear = 'Anno di produzione</li>';
  cEndYear = '</li>';
  cStartDesc = '<p class="CommyDesc4">';
  cEndDesc = '</p>';
  cStartTitleList = 'title=';
  cEndTitleList = '</a>';
var
  MovieUrl, MovieName, TranslatedStr, PageStr:  string;

// -----------------------
// ANALYZE MOVIE DATA PAGE
// IN:  none
// OUT: set Ant fields
// -----------------------
procedure AnalyzeMoviePage;
var
  cImage,cValue : string;
begin
  // Get packed title main page
  PageStr := RemoveExtraChars(MovieUrl);
  
  // ORIGINAL TITLE
  SetField(fieldOriginalTitle, GetValueEx(PageStr, cStartTitle, cEndTitle,true,true));
  PageStr := GetPageStr;

  // FILM IMAGE
  cImage := GetValueEx(PageStr, cStartImg, cEndImg, true, false);
  PageStr := GetPageStr;
  if cImage <> '' then
    GetPicture(cImage);

  // YEAR
  SetField(fieldYear, GetValueEx(PageStr, cStartYear, cEndYear, true, false));
  PageStr := GetPageStr;

  // ACTORS
  SetField(fieldActors, GetValueEx(PageStr, cStartCast, cEndCast, false, false));
  PageStr := GetPageStr;
  
  // DURATION
  SetField(fieldLength, GetValueEx(PageStr, cStartDuration, cEndDuration, true, false));
  PageStr := GetPageStr;

  // CATEGORY
  cValue := GetValueEx(PageStr, cStartCategory, cEndCategory, true, false);
  SetField(fieldCategory, AnsiUpFirstLetter(AnsiLowerCase(cValue)));
  PageStr := GetPageStr;

  // DIRECTOR
  SetField(fieldDirector, GetValueEx(PageStr, cStartDirector, cEndDirector, false, false));
  PageStr := GetPageStr;

  // DESCRIPTION
  SetField(fieldDescription, GetValueEx(PageStr, cStartDesc, cEndDesc, true, false));
  PageStr := GetPageStr;

  // COMMENTS

  // URL
  SetField(fieldURL, MovieUrl);
end;


// ------------------------------------------------------------------
// FILL PICKTREE CONTROL WITH LINKS & TITLES or RETURN ONE PAGE LINK
// if OneFilm flag true return Film Id else populate PickTree
// IN:  OneFilm flag (bool)
// OUT: one page ID  (string)
// ------------------------------------------------------------------
function PopulatePickTree(OneFilm: boolean): string;
var
  cFilmId,cFilmTitle: string;
  StartPos,EndPos: integer;
begin
  if OneFilm then begin
    cFilmId := GetValueEx(PageStr,cStartId,cEndId,false,false);
    result := QueryFilm + cFilmId;
  end
  else begin
    PickTreeClear;
    repeat
      StartPos := pos(cStartId, PageStr);
      if StartPos > 0 then begin
        Delete(PageStr, 1, StartPos - 1);
        cFilmId := GetValueEx(PageStr,cStartId,cEndId,true,false); // Get ID
        cFilmTitle := GetValueEx(PageStr,cStartTitleList,cEndTitleList,true,true); // Get Title
        if cFilmTitle <> '' then
          PickTreeAdd(cFilmTitle, QueryFilm + cFilmId);
          
        EndPos := pos(cStartId,PageStr);
        Delete(PageStr, 1, EndPos);
      end;
    until(StartPos = 0);
    result := '';
  end
end;

// ---------------------------------
// ANALYZE FIRST SEARCH RESULT PAGE:
// IN:  page Url (string)
// OUT: none
// ---------------------------------
procedure AnalyzeSearchPage(Url: string);
var
  NumRisultati : string;
begin
  PageStr := RemoveExtraChars(Url);
  NumRisultati := GetValueEx(PageStr, cStartNumRis, cEndNumRis, true, false);
  
  if ( (NumRisultati = '0') or (NumRisultati = '')) then
    begin
      ShowMessage('Title not found / Nessun film trovato.');
      exit;
    end

  if NumRisultati = '1' then
    MovieUrl := PopulatePickTree(true)
  else
    begin
      PopulatePickTree(false);
      if not PickTreeExec(MovieUrl) then // ..select one
        exit;
    end;

  AnalyzeMoviePage;
end;

// --------------------------------------------------
// GET FIELD VALUES FROM PACKED PAGE
// IN:  Start marker     (String)
//      End marker       (string)
//      Cut Start Marker (bool)
//      Cut End Marker   (bool)
// OUT: value            (string)
// --------------------------------------------------
function GetValueEx(MyPageStr,cStartMarker,cEndMarker: string;bCutEnd,bAdjust: boolean): string;
var
  StartPos: integer;
  EndPos: integer;
  Value: string;
begin
  Value := '';
  StartPos := pos(cStartMarker, MyPageStr);
  if ( StartPos = 0 ) then exit; // Not found
  
  StartPos := StartPos + length(cStartMarker);
  Delete(MyPageStr, 1, StartPos -1);
  EndPos := pos(cEndMarker, MyPageStr);
  
  if EndPos > 0 then begin
    Value := copy(MyPageStr, 0, EndPos-1);
    if bCutEnd then
      EndPos := EndPos + length(cEndMarker);
    Delete(MyPageStr, 1, EndPos -1);
    if bAdjust then
      Value := '<' + Value;
  end;
  TmpPageStr := MyPageStr;
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  result := Trim(Value);
end;

// ----------
// MAIN:
// IN:  none
// OUT: none
// ----------
begin
  if CheckVersion(3,5,0) then
    begin
      TranslatedStr := GetField(fieldTranslatedTitle);
      MovieName := GetField(fieldOriginalTitle);
      if (TranslatedStr <> '') then
        MovieName := TranslatedStr;

      if(Input('MyMovies.It', 'Enter the title of the movie', MovieName)) then
        begin
          InitializePivLib;
          MovieUrl := QueryBase + StringReplace(MovieName,' ','+') + UrlRicerca;
          AnalyzeSearchPage(MovieUrl);
          FinalizePivLib;
        end;
    end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
fulvio53s03
Posts: 744
Joined: 2007-04-28 05:46:43
Location: Italy

Post by fulvio53s03 »

The script is not showed between those able to load information from the net pressing (F6)..... is there any mistake in the code? :??:
thanks.
seraphico
Posts: 12
Joined: 2007-12-11 18:48:44
Location: Italy

Post by seraphico »

I've made a few test and i find that the script is the archive but not in the script dir.
With this situation the updater didn't download the script,
so if you want to use it download it manually from the archive
and put in the script dir on your local drive.
I also think that Antoine can solve this copying the file.
Hope he read us! :D
See you all soon

:grinking:
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

the script dir as you name it only contains scripts that were updated since the last AMC release, so that's normal.
seraphico
Posts: 12
Joined: 2007-12-11 18:48:44
Location: Italy

Post by seraphico »

Ok, but why the updater don't get the script?
I've check the header of the script and it seems to be fine...
i've forget something?
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Isn't there an option to check in all scripts (including archive) ? Or a link to find all scripts ?
(it is not me who made that so I do not remember exactly :D)
fulvio53s03
Posts: 744
Joined: 2007-04-28 05:46:43
Location: Italy

Post by fulvio53s03 »

antp wrote:Isn't there an option to check in all scripts (including archive) ? Or a link to find all scripts ?
(it is not me who made that so I do not remember exactly :D)
Sorry... the problem is now solved (but I can't understand what happened) and the script is correctly loaded using F6.
Thank you all (hope you didn't waste too much time) :(
DjDiabolik
Posts: 17
Joined: 2009-07-16 11:08:39

Post by DjDiabolik »

The script no more appears from the updater script......... because ?
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Because the latest version of the script is included in latest AMC release.
You have to click "find more" or "additional scripts" to see the whole list.
Post Reply