[UPD ITA] FilmScoop.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
mrobama
Posts: 85
Joined: 2009-04-03 12:34:34

[UPD ITA] FilmScoop.it

Post by mrobama »

Fixed 1 bug: sometimes synopsis was void

Code: Select all

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

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

[Infos]
Authors=Claudio Rinaldi ( rinaldiclaudio@gmail.com ), MrObama
Title=FilmScoop
Description=Get movie info from FilmScoop.it
Site=www.filmscoop.it
Language=IT
Version=1.2
Requires=3.5.1
Comments=
License=
GetInfo=1
RequiresMovies=1

[Options]

[Parameters]

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

program FilmScoopIT;

uses
  Pivlib; // Pivello's scripts common library

const
  UrlBase = 'http://www.filmscoop.it';
  UrlRicerca = '&to=&r=&i=&n=&g=0&a=&o=Titolo&Submit=Cerca';
  QueryBase = UrlBase + '/ricerca/risultati.asp?t=';
  QueryFilm = UrlBase + '/film_al_cinema/';
  ImagePath = UrlBase + '/locandine/';

  cStartNumRis = 'Numero di risultati: <strong>'; // Result Number start Marker
  cEndNumRis = '</strong> - Pagin';               // Result Number end Marker
  cStartId = ' <a href="/film_al_cinema/'; // ID start marker
  cEndId = '"'; // ID end marker
  cStartTitle = '<h1 class="TitoloFilmUpper" style="clear:both;">'; // Title start marker
  cEndTitle = '</h1>';              // Title end marker
  cStartTranslTitle = '<h2><strong>Titolo Originale</strong>:';        // Translated title start marker
  cEndTranslTitle = '</h2>';         // Translated title end marker
  cStartImg = '<img src="http://www.filmscoop.it/locandine/';               // Image start marker
  cEndImg = '" alt';             // Image end marker
  cStartDirector = 'Regia</strong>:';    // Director start marker
  cStartCast = 'Interpreti</strong>:';              // Actor start marker
  cStartCategory = 'Genere</strong>:';       // Catogory start marker
  cEndCategory = '</a>';            // Category end marker
  cStartDuration = 'Durata</strong>:';       // Duration start marker
  cEndDuration = '<br />';          // Duration end marker
  cStartCountry = '<strong>Nazionalit&agrave;</strong>:&nbsp;';     // Country start Marker
  cEndCountry = '</a> <a';               // Country end marker
  cStartYear = ' ';              // Year start marker
  cEndYear = '<br />';                 // Year end marker
  cStartDesc = '<p style="margin-top:0;margin-left:0;padding-top:0;padding-left:0;"';         // Description start marker
  cEndDesc = '</p>';                 // Description end marker
  cStartTitleList = '<strong>';            // Title list start marker
  cEndTitleList = '</strong>';            // Title list end marker
var
  MovieUrl, MovieName, TranslatedStr, PageStr:  string;
  

// -----------------------
// ANALYZE MOVIE DATA PAGE
// IN:  none
// OUT: set Ant fields
// -----------------------
procedure AnalyzeMoviePage;
var
  cImage,cValue,cValue2 : string;
begin
  // Get packed title main page
  PageStr := RemoveExtraChars(MovieUrl);
 
  // TRANSLATED TITLE & YEAR
  cValue := GetValueEx(PageStr, cStartTitle, cEndTitle, true, true);
  cValue2 := AnsiUpFirstLetter(AnsiLowerCase(GetValueEx(' .' + cValue, '.', ' (', false, false)));
  if cValue2 <> '' then
    SetField(fieldTranslatedTitle, cValue2);
  cValue := GetValueEx(cValue, ' (', ')', false, false);
  if cValue <> '' then
    SetField(fieldYear, cValue);
  //PageStr := GetPageStr;
 
  // FILM IMAGE
  cImage := GetValueEx(PageStr, cStartImg, cEndImg, true, false);
  if cImage <> '' then
    GetPicture(ImagePath + cImage);
 
  // ORIGINAL TITLE
  cValue := GetValueEx(PageStr, cStartTranslTitle, cEndTranslTitle, true, true);
  if cValue <> '' then
    SetField(fieldOriginalTitle, AnsiUpFirstLetter(AnsiLowerCase(cValue)));
 
  // DIRECTOR
  cValue := GetValueEx(PageStr, cStartDirector, cStartCast, false, false);
  if cValue <> '' then
    SetField(fieldDirector, cValue);

  // ACTORS
  cValue := GetValueEx(PageStr, cStartCast, cStartDuration, false, false);
  if cValue <> '' then
    SetField(fieldActors, cValue);
 
  // DURATION
  // cValue := GetValueEx(PageStr, cStartDuration, cEndDuration, true, false);
  // SetField(fieldLength, cValue);

  // COUNTRY
  cValue := GetValueEx(PageStr, cStartCountry, cEndCountry, false, false);
  if cValue <> '' then
    SetField(fieldCountry, cValue);

  // CATEGORY
  cValue := AnsiUpFirstLetter(AnsiLowerCase(GetValueEx(PageStr, cStartCategory, cEndCategory, true, false)));
  if cValue <> '' then
    SetField(fieldCategory, cValue);

  // DESCRIPTION
  cValue := GetValueEx(PageStr, cStartDesc, cEndDesc, true, false) + cEndDesc;
  if length(cValue) > length(cEndDesc) then
    begin
      cValue := '<p ' + cValue;
      HTMLRemoveTags(cValue);
      SetField(fieldDescription, cValue);
    end;

  // 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,false); // Get Title
        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;
  TmpPageStr: string;
begin
  Value := '';
  StartPos := pos(cStartMarker, MyPageStr);
  if ( StartPos = 0 ) then exit; // Not found

  //Delete(MyPageStr, 1, StartPos -1);
  //StartPos := pos(cStartMarker, MyPageStr);
  if (StartPos > 0) then begin
    TmpPageStr := copy(MyPageStr, (StartPos + length(cStartMarker) - 1), (length(MyPageStr) - StartPos - length(cStartMarker) + 1));
    EndPos := pos(cEndMarker, TmpPageStr);
    EndPos := EndPos + 0;
  end else
    EndPos := 0;
  if ( (StartPos > 0) and (EndPos > 0) ) then begin
    EndPos := EndPos + Startpos + length(cStartMarker) - 2;
    StartPos := StartPos + length(cStartMarker);
    Value := copy(MyPageStr, StartPos, EndPos-Startpos);
    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: 764
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ITA] FilmScoop.it

Post by fulvio53s03 »

obviousely...... "Italians do it better!"
:clapping: :innocent: :naughty:
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: [UPD ITA] FilmScoop.it

Post by antp »

A lot of updated italian scripts today indeed :lol:
ZuperMario
Posts: 4
Joined: 2018-03-15 08:09:43

Re: [UPD ITA] FilmScoop.it

Post by ZuperMario »

Buongiorno,
sono nuovo del programma e ho appena aggiornato questo script facendo copia/incolla sull'editor, approfitto per 2 domande:
1) ho fatto bene a fare copia/incolla o il programma avrebbe docuto trovare da solo l'aggiornamento? (non lo ha fatto)
2) non si puo' skippare la richiesta del titolo per ogni film, e prendere per buono il nome file?

Grazie.

Good morning,
I'm new with the program and I've just updated this script by copying / pasting on the editor, I have 2 questions:
1) I was right to do copy / paste, or the software would have been able to find the update itself? (he did not)
2) I can't skip the title request for each movie, and take for good the file name?

Thanks.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: [UPD ITA] FilmScoop.it

Post by antp »

Hi,
Normally once I updated it on the server (which is the case here) you can update it by running the script named "update scripts" at the top of the scripts list.
For a more automatic processing, without title entering and things like that, it depends on the script: some have options for that (e.g. batch mode, etc.) - options are displayed at the right of the script window.
Post Reply