Page 1 of 1

Script to fix (FilmTV)

Posted: 2007-12-01 08:49:41
by bagalin97
Ciao

volevo segnalare che lo script di FilmTV non funziona più da alcuni giorni. Se qualcuno cortesemente fosse in grado di correggerlo farebbe cosa grata a chi come me non è purtroppo in grado di farlo.

FilmTV script doesn't work properly for some days anymore. If kindly someone could correct it in the meantime it would do a pleasure to whom as me it is not able unfortunately to do it personally.

Grazie/Thanks a lot

Posted: 2007-12-01 09:14:52
by admeis
Fixed! :)

Code: Select all

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

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

[Infos]
Authors=Pivello (see comments for changes authors)
Title=FilmTV
Description=Get movie info from Film TV
Site=www.Film.TV.it
Language=IT
Version=01.12.2007
Requires=3.5.0
Comments=Modified by:|02.02.2005 adapted to v.3.5.0 (Dinolib)|10.03.2005 Revised for pivlib.pas Library use (Pivello)|01.12.2007 fixed search results (admeis)
License=The source code of the script can be used in another program only if full credits to script author and a link to Ant Movie Catalog website are given in the About box or in the documentation of the program
GetInfo=1

[Options]
LargePicture=1|1|0=Get a small picture|1=Try to get the big picture

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

program FilmTVIt;

uses
  Pivlib; // Pivello's scripts common library

const
  UrlBase = 'http://www.film.tv.it';
  QueryBase = UrlBase + '/cerca.php?ricerca=avanzata&titolo=';
  QueryFilm = UrlBase + '/scheda.php?film=';
  ImagePath = UrlBase + '/imgbank/';

  cStartId = 'Verde"><a href="scheda.php?film='; // ID start marker
  cEndId = '" class="fTitolettoFilm"';           // ID end marker
  cStartTitle = 'style="margin: 2px 5px 40px 0; float: left; " />'; // Title start marker
  cEndTitle = '</a></span>';                     // Title end marker
  cStartTranslTitle = 'fTitoloFilmBianco">';     // Translated title start marker
  cEndTranslTitle = '</span>';                   // Translated title end marker
  cStartImg = 'img src="imgbank/';               // Image start marker
  cEndImg = '" width="';                         // Image end marker
  cStartGeneric = 'Lite" bgcolor="#5B6E80" valign="top">';
  cEndGeneric = ' ';                        // Generic field marker
  cStartDirector = 'fLinkBianco>';               // Director start marker
  cEndDirector = '</a>';                         // Director end marker
  cStartCast = 'fLinkBianco>';                   // Actor start marker
  cEndCast = '</a>';                             // Actor end marker
  cEndGeneric2 = '</td>';                        // Generic end marker 2
  cBeginDesc = '"La Trama" /></p>';              // Description begin marker
  cStartDesc = '<p class="testo">';              // Description start marker
  cEndDesc = '</p>';                             // Description end marker
  cStartComm = '<p class="testo"><i>';           // Comment start marker
  cEndComm = '</i></p>';                         // Comment end marker

var
  MovieUrl, MovieName, OriginalStr, TranslatedStr, PageStr:  string;


// ---------------------------------
// READ PICTURE
// OUT: none
// ---------------------------------
procedure ReadPicture;
var
  ImageLink: string;
Begin
  ImageLink := ImagePath + getValue(PageStr, cStartImg, cEndImg, true, true);
  PageStr := GetPageStr;
  if Pos('DUMMY/locandina.gif',ImageLink)>0 then
    exit;
  if GetOption('LargePicture')=1 then
    ImageLink := StringReplace(ImageLink,'/LOC/','/GALLERY/');
  GetPicture(ImageLink);
end;


// -----------------------
// ANALYZE MOVIE DATA PAGE
// IN:  none
// OUT: set Ant fields
// -----------------------
procedure AnalyzeMoviePage;
var
  i, h, m: integer;
  Duration, Description, Cast, TempStr, TempImg, hh, mm: string;
begin
  // Get packed title main page
  PageStr := RemoveExtraChars(MovieUrl);
  // Translated Title field
  SetField(fieldTranslatedTitle, getValue(PageStr, cStartTranslTitle, cEndTranslTitle, true, true));
  PageStr := GetPageStr;
  // Get film image
  ReadPicture;
  // Original Title field
  SetField(fieldOriginalTitle, getValue(PageStr, cStartGeneric, cEndGeneric, true, true));
  PageStr := GetPageStr;
  if(GetField(fieldOriginalTitle)='')then
    SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));
  // Country field
  SetField(fieldCountry, getValue(PageStr, cStartGeneric, cEndGeneric, true, true));
  PageStr := GetPageStr;
  // YearField
  SetField(fieldYear, getValue(PageStr, cStartGeneric, cEndGeneric, true, true));
  PageStr := GetPageStr;
  // Director Field
  SetField(fieldDirector, getValue(PageStr, cStartDirector, cEndDirector, true, true));
  PageStr := GetPageStr;
  // Actors Field
  Cast := '';
  repeat
    TempStr := getValue(PageStr, cStartCast, cEndCast, true, true);
    PageStr := GetPageStr;
    if ((Cast<>'') and (TempStr<>'')) then
      Cast := Cast + ', ';
    Cast := Cast + TempStr;
  until((TempStr='')or(Length(TempStr)>40));
  SetField(fieldActors, Cast);
  // Category Field
  SetField(fieldCategory, getValue(PageStr, cStartGeneric, cEndGeneric2, true, true));
  PageStr := GetPageStr;
  // Duration field
  TempStr := getValue(PageStr, cStartGeneric, cEndGeneric2, true, true);
  PageStr := GetPageStr;
  SetField(fieldLength, Copy(TempStr,1,Length(TempStr)-1));
  // Producer Field
  //SetField(fieldProducer, getValue(PageStr, , , true, true));
  //PageStr := GetPageStr;
  // Description Field
  Delete(PageStr, 1, Pos(cBeginDesc, PageStr) + Length(cBeginDesc));
  SetField(fieldDescription, getValue(PageStr, cStartDesc, cEndDesc, true, true));
  PageStr := GetPageStr;
  // Comments Field
  SetField(fieldComments, getValue(PageStr, cStartComm, cEndComm, true, true));
  PageStr := GetPageStr;
  // Movie URL field
  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
  TempIdFilm: string;
  TempTitle: string;
  StartPos: integer;
  EndPos: integer;
begin
  if OneFilm then
    begin
      StartPos := pos(cStartId, PageStr);
      EndPos := pos(cEndId, PageStr);
      StartPos := StartPos + Length(cStartId);
      TempIdFilm := copy(PageStr, StartPos, EndPos-Startpos); // Get ID
      result := QueryFilm + TempIdFilm;
    end
  else
    begin
      PickTreeClear;
      repeat
        StartPos := pos(cStartId, PageStr);
        EndPos := pos(cEndId, PageStr);
        if StartPos > 0 then
          begin
            StartPos := StartPos + Length(cStartId);
            TempIdFilm := copy(PageStr, StartPos, EndPos-Startpos);  // Get ID
            Delete(PageStr, 1, EndPos);
            StartPos := pos(cStartTitle, PageStr);
            EndPos := pos(cEndTitle, PageStr);
            StartPos := StartPos + Length(cStartTitle);
            TempTitle := copy(PageStr, StartPos, EndPos-Startpos); // Get Title
            PickTreeAdd(TempTitle, QueryFilm + TempIdFilm);
          end;
      until(StartPos = 0);
      result := '';
    end
end;


// ---------------------------------
// ANALYZE FIRST SEARCH RESULT PAGE:
// IN:  page Url (string)
// OUT: none
// ---------------------------------
procedure AnalyzeSearchPage(Url: string);
var
  FilmId: string;
begin
  PageStr := RemoveExtraChars(Url);
  if pos('Non ho trovato nessun film', PageStr) > 0 then
    ShowMessage('Title not found / Nessun film trovato.')
  else if pos('Si è verificato un errore',PageStr) > 0 then
    ShowMessage('Server not available, try later / Server non disponibile, prova più tardi')
  else
    begin
      if pos('Ho trovato 1 film', PageStr) <> 0 then
        MovieUrl := PopulatePickTree(true)   // One title found
      else
        begin
          PopulatePickTree(false);           // More titles found..
          if not PickTreeExec(MovieUrl) then // ..select one
          exit;
        end;
      AnalyzeMoviePage;
    end;
end;


// ----------
// MAIN:
// IN:  none
// OUT: none
// ----------
begin
  if CheckVersion(3,5,0) then
    begin
      TranslatedStr := GetField(fieldTranslatedTitle);
      OriginalStr := GetField(fieldOriginalTitle);
      if (TranslatedStr <> '') then
        MovieName := TranslatedStr
      else
        MovieName := OriginalStr;
      if(Input('Film.TV.It - By Pivello (and others)', 'Enter the title of the movie / Inserire titolo del film:', MovieName)) then
        begin
          InitializePivLib;
          MovieUrl := QueryBase + UrlEncode(MovieName);
          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.
Best regards.
admeis

Posted: 2007-12-01 11:39:31
by antp
Thanks!

Posted: 2007-12-02 09:24:41
by bagalin97
Thanks very much Admeis!

Best Regards

Script to fix (FilmTV)

Posted: 2008-01-23 17:32:26
by bagalin97
I'm sorry but FilmTV script doesn't work again anymore. Someone can be so kind to correct it? Thanks a lot in advance

Posted: 2008-01-23 19:10:43
by bad4u
Here's a fixed version (results list and picture import):
http://www.bad4u.741.com/full/Film.tv.it.ifs (copy link into a NEW browser window !)

Please report if something else is missing..

Posted: 2008-01-23 20:39:55
by bagalin97
Many many thanks bad4u, for your time and for your prompt action: very appreciated. Regards

Posted: 2008-06-27 12:26:40
by zedone
tnx for all bad4u, but now the script for filmtv doesn't work again...can you update this script again??you are the only hope, i think..

tnx in advance!!

Posted: 2008-06-27 12:44:32
by antp
As he said there: viewtopic.php?p=25941#25941
The script requires major changes, and he does not have the time for that...