Page 1 of 1

Script for CSFD.cz???

Posted: 2003-09-03 13:18:34
by bloody.vc
Can anybody do a script for CSFD.cz?

Posted: 2003-09-04 04:21:46
by Dmitry501
I can :) Please, wait for result.

Posted: 2003-09-04 06:21:05
by Guest
Dmitry501 wrote:I can :) Please, wait for result.
COOL :-)

Posted: 2003-09-04 11:00:10
by Dmitry501

Code: Select all

// GETINFO SCRIPTING
// Imports from csfd.cz
// Dmitry501

program Csfd_cz;
const
  BaseAddress = 'http://csfd.cz/';
var
  MovieName: string;

function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
  i: Integer;
begin
  result := -1;
  if StartAt < 0 then
    StartAt := 0;
  for i := StartAt to List.Count-1 do
    if Pos(Pattern, List.GetString(i)) <> 0 then
    begin
      result := i;
      Break;
    end;
end;

function GetDirector(Line: string): String;
var BeginPos : Integer;
begin
    result := '';
    BeginPos := Pos('Režie:', Line);
    if BeginPos > 0 then
    begin
      Delete(Line,1,BeginPos+5);
      BeginPos := Pos('<br>', Line);
      if BeginPos = 0 then BeginPos := Length(Line);
      result := copy(Line, 1, BeginPos);
      HTMLDecode(result);
      HTMLRemoveTags(result);
    end;
  result := Trim(result);
end;

function GetActor(Line: string): String;
var BeginPos : Integer;
begin
    result := '';
    BeginPos := Pos('Hrají:', Line);
    if BeginPos > 0 then
    begin
      Delete(Line,1,BeginPos + 5);
      BeginPos := Pos('<br>', Line);
      if BeginPos = 0 then BeginPos := Length(Line);
      result := copy(Line, 1, BeginPos);
      HTMLDecode(result);
      HTMLRemoveTags(result);
    end;
  result := Trim(result);
end;

function GetTitle(Line: string): String;
var BeginPos : Integer;
begin
    result := '';
    BeginPos := Pos('<img src=''/images/flag_52.gif', Line);
    if BeginPos > 0 then
    begin
      Delete(Line,1,BeginPos-1);
      BeginPos := Pos('</table>', Line);
      if BeginPos = 0 then BeginPos := Length(Line);
      result := copy(Line, 1, BeginPos);
      HTMLDecode(result);
      HTMLRemoveTags(result);
      MovieName := GetField(fieldTranslatedTitle);
      MovieName := MovieName + ' (' + result + ')';
      SetField(fieldTranslatedTitle,MovieName);
      Delete(Line,1,BeginPos-1);
    end

    BeginPos := Pos(' ', Line);
    if BeginPos > 0 then
    begin
      Delete(Line,BeginPos, Length(Line));
      result := Line;
      HTMLDecode(result);
      HTMLRemoveTags(result);
    end;
  result := Trim(result);
end;

function GetCategory(Line: string): String;
var BeginPos : Integer;
begin
    result := '';
    BeginPos := Pos(' ', Line);
    if BeginPos > 0 then
    begin
      Delete(Line,1,BeginPos + 9);
      BeginPos := Pos('<br>', Line);
      if BeginPos = 0 then BeginPos := Length(Line);
      result := copy(Line, 1, BeginPos-1);
      HTMLDecode(result);
      HTMLRemoveTags(result);
    end;
    result := Trim(result);
    SetField(fieldCategory, result);
    result := '';
    Delete(Line,1,BeginPos-1);
    BeginPos := Pos('<br>', Line);
    if BeginPos > 0 then
    begin
      Delete(Line,1,BeginPos + 3);
      BeginPos := Pos('<p>', Line);
      if BeginPos = 0 then BeginPos := Length(Line);
      result := copy(Line, 1, BeginPos-1);
      HTMLDecode(result);
      HTMLRemoveTags(result);
    end;
    result := Trim(result);
    SetField(fieldCountry, result);
end;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr : Integer;
  Line, Value : String;
  BeginPos, EndPos : Integer;
  FilmName, FilmAddr : String;
begin
    Page := TStringList.Create;
    Page.Text := GetPage(Address);
    LineNr := FindLine('databáze</title>', Page, 0);
    if LineNr = -1 then
    begin
        AnalyzeMoviePage(Address);
    end
    else
    begin
     LineNr := FindLine('Nebyly nalezeny žádné', Page, 0);
      if LineNr = -1 then
      begin
        LineNr := FindLine('<a href="film.', Page, 0);
        if LineNr > -1 then
        begin
          PickTreeClear;
          PickTreeAdd('Filmy: ' + MovieName, '');
          Line := Page.GetString(LineNr);
          repeat
            BeginPos := Pos('<a href="',Line);
            If BeginPos > 0 Then
            begin
              EndPos := Pos('">',Line);
              if EndPos = 0 Then EndPos := Length(Line);
              FilmAddr := Copy(Line, BeginPos+9, EndPos-BeginPos-9);
              HTMLDecode(FilmAddr);
              HTMLRemoveTags(FilmAddr);
              EndPos := Pos('<br>',Line);
              if EndPos = 0 Then EndPos := Length(Line);
              FilmName := Copy(Line, BeginPos, EndPos-BeginPos);
              HTMLDecode(FilmName);
              HTMLRemoveTags(FilmName);
              PickTreeAdd(FilmName, BaseAddress + FilmAddr);
              Delete(Line,1,EndPos+3);
            end;
          until BeginPos <1;
         If  PickTreeExec(Address) Then
           AnalyzeMoviePage(Address);
        end;
      end;
    end;
end;

procedure AnalyzeMoviePage(Address: string);
var
  Page: TStringList;
  LineNr : Integer;
  Line, Value : String;
  BeginPos, EndPos : Integer;
begin
    Page := TStringList.Create;
    Page.Text := GetPage(Address);
    LineNr := FindLine('<div class="nazovfilmu">', Page, 0);
    if LineNr > -1 then
    begin
 
      Line := Page.GetString(LineNr+1);
      HTMLDecode(Line);
      HTMLRemoveTags(Line);
      Value := Trim(Line);
      SetField(fieldTranslatedTitle, Value);

      Line := Page.GetString(LineNr+2);
      Value := GetDirector(Line);
      SetField(fieldDirector, Value);
      Value := GetActor(Line);
      SetField(fieldActors, Value);
      Value := GetTitle(Line);
      SetField(fieldOriginalTitle, Value);
      Value := GetCategory(Line);
    end;
    // picture
    LineNr := FindLine('style="padding-left: 10px"', Page, 0);
    if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      BeginPos := pos('<img src="', Line) + 10;
      if BeginPos > 10 then
        begin
          EndPos := pos('" width="', Line);
          Value := copy(Line, BeginPos, EndPos - BeginPos);
          Value := BaseAddress + Value;
          GetPicture(Value, False);
        end;
    end;
    // Info
    LineNr := FindLine('id="plot_full"', Page, 0);
    if LineNr > -1 then
    begin
      Value := Page.GetString(LineNr+1);
      HTMLDecode(Value);
      HTMLRemoveTags(Value);
      SetField(fieldDescription, Trim(Value));
    end;
   // URL
   SetField(fieldURL, Address);
  DisplayResults;
end;

begin
  if CheckVersion(3,4,0) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('Import movie from www.csfd.cz', 'Enter the title of the movie:', MovieName) then
    begin
			AnalyzePage('http://csfd.cz/index.php?action=hledat&hledej='+UrlEncode(MovieName));
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
This is BETA ;)
Changed 09/12/2003

Posted: 2003-09-04 12:01:47
by bloody.vc
can u speak czech? / mluvis cesky, at se pripadne zbytecne nebavime v anglictine? ;-)

THANK YOU FOR A GREAT JOB :-))

little bug i found: in "Country" it imports also "Year" and "Lenght"

Posted: 2003-09-05 02:00:51
by Dmitry501
can u speak czech?
No, I speak only on Russian.
little bug i found: in "Country" it imports also "Year" and "Lenght"
Yes, this thus. Server in no way separates these fields. Look itself. Sometimes there are no some values. For example the country, duration. Or year, the country. Or year, the country, duration. In this beta version this problem is not solved. I will possibly make more lately.

Posted: 2003-09-05 06:42:00
by bloody.vc
ok, thank you anyway :-)

Posted: 2003-09-08 11:03:39
by Peca
Thank you very much for this script!

THX

Posted: 2003-09-09 08:18:32
by vykupitel
Thank you very much for your work on this script,very helpfull

Posted: 2003-09-10 07:29:42
by bloody.vc
Dmitry501 wrote:
can u speak czech?
No, I speak only on Russian.
little bug i found: in "Country" it imports also "Year" and "Lenght"
Yes, this thus. Server in no way separates these fields. Look itself. Sometimes there are no some values. For example the country, duration. Or year, the country. Or year, the country, duration. In this beta version this problem is not solved. I will possibly make more lately.
The CSFD.cz changed a little bit and now i see this bug:

error msg: Script error: CSFD_CZ at position 4458 (assigment expected)

Can anybody help?

Posted: 2003-09-11 05:35:30
by dmitry
The CSFD.cz changed a little bit and now i see this bug:

error msg: Script error: CSFD_CZ at position 4458 (assigment expected)

Can anybody help?
Example please. Movie name?

Posted: 2003-09-11 07:02:38
by bloody.vc
dmitry wrote:
The CSFD.cz changed a little bit and now i see this bug:

error msg: Script error: CSFD_CZ at position 4458 (assigment expected)

Can anybody help?
Example please. Movie name?
For example: Citizen Kane, City by the Sea, Casino, i think every film i tried. Strange thing is that when i tried it yesterday, when one man told me about this error, its doesnt happen to me. Maybe active cash? But few tries later i got this error in 100% of cases.

Posted: 2003-09-12 02:18:00
by Guest
For example: Citizen Kane, City by the Sea, Casino, i think every film i tried. Strange thing is that when i tried it yesterday, when one man told me about this error, its doesnt happen to me. Maybe active cash? But few tries later i got this error in 100% of cases.
Yes, the mistake is. I do not use this server, therefore I can not trace change :) . The corrected script look above. :up:

Posted: 2003-09-12 07:01:14
by bloody.vc
Anonymous wrote:
For example: Citizen Kane, City by the Sea, Casino, i think every film i tried. Strange thing is that when i tried it yesterday, when one man told me about this error, its doesnt happen to me. Maybe active cash? But few tries later i got this error in 100% of cases.
Yes, the mistake is. I do not use this server, therefore I can not trace change :) . The corrected script look above. :up:
THX :-)))

Question

Posted: 2003-09-25 08:57:35
by vykupitel
How could I change this script to load from WWW only: Translated title, Director, Producer, Country, Actors, Plot? Please help me someone. I don`t want to overwrite my data with this script from csfd.cz. :(

Is there any change to cut year from category?

anyone???

Posted: 2003-10-20 11:42:37
by vykupitel
PLEASE, is there anyone who can help me??? :cry:

:( :( :(

Posted: 2003-10-20 12:10:09
by antp
What do you want to remove from the script ? Picture and URL ?

RE

Posted: 2003-10-20 12:17:41
by vykupitel
Yes, I don`t want to download pictures,category,year `cos I have it already and the script is always overwite it to me :(

Posted: 2003-10-20 15:19:23
by antp
To disable the picture, remove the code between "// picture" and "// Info"
To disable category and year (and others) remove the "SetField(...)" lines that contain the name of the field that you do not want to overwrite.