[RU] Kinoshara.com

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
LA

[RU] Kinoshara.com

Post by LA »

the script was written for 3.4.3 version of AMC

Code: Select all

// GETINFO SCRIPTING
// Imports russian movies info with large picture from kinoshara.com
// (с) LA, 2005

program KinoShara;
const
  BaseAddress = 'http://kinoshara.com/';
var
  MovieName: string;

function ParseURL(Text:String):String;
var
  BeginPos : Integer;
  EndPos : Integer;
  Value : String;
begin

  repeat
    BeginPos := Pos('<b>',Text);
    If BeginPos > 0 Then
    Begin
      EndPos := Pos('</b>',Text);
      Value := copy(Text, BeginPos, EndPos - BeginPos);
      Value := StringReplace(Value,'<BR>',', ');
      Value := StringReplace(Value,'<br>',', ');
      HTMLRemoveTags(Value);
      Delete(Text,1,EndPos);
      If Length(result)>0 Then
        result := result + ', ' + Value
      else
        result := Value;
    end;
  until BeginPos < 1;

end;

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;

procedure AnalyzePage(Address: string);
var
  ID, FilmName, Line: String;
  Page: TStringList;
  FilmPage: TStringList;
  BeginPos, EndPos: Integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  BeginPos := FindLine('    <tr valign=top bgcolor=#EEEEEE>', Page,0);
  if  BeginPos > 0 then
    begin
      // Вывод фильмов в дерево
      Line:= Page.GetString(BeginPos+1); // Получить строку с адресами
      PickTreeClear; // Очистка дерева фильмов
      PickTreeAdd('Поиск по слову: ' + MovieName, '');
      repeat
            BeginPos := Pos('        <td>',Line);
            If BeginPos>0 Then
            // поиск возможных вариантов
            Begin
              Delete(Line,1,BeginPos); //Удаление начала
              // получаем адрес
              BeginPos:=Pos('<a href="',Line)+9;
              EndPos := Pos('">',Line);
              ID := copy(Line, BeginPos, EndPos - BeginPos); // Получить адрес страницы

              // вытаскиваем название
              BeginPos := Pos('/">',Line)+3;
              EndPos := Pos('</a>',Line);
              FilmName := Copy(Line, BeginPos, EndPos - BeginPos); // Получить название для выбора
              FilmName := StringReplace(FilmName,' ',' ');
              FilmName := StringReplace(FilmName,'<font color=red>',' ');
              FilmName := StringReplace(FilmName,'</font>',' ');

              PickTreeAdd(FilmName, ID);

            end;
      until BeginPos < 1;
    end;

  If  PickTreeExec(Address) Then
      AnalyzeMoviePage(Address); // Проанализировать страницу с фильмом
end;

procedure AnalyzeMoviePage(Address: String);
var
  Page: TStringList;
  LineNr : Integer;
  Line, Value, TmpStr : String;
  BeginPos, EndPos : Integer;

begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  //Page.SaveToFile('c:\inet\page.txt'); //!Отладка

  // URL
  SetField(fieldURL,Address);

  //Rating

  // Translated Title
  TmpStr := '<td><b>Название:</b> ';
  LineNr := FindLine(TmpStr, Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    SetField(fieldTranslatedTitle,Value);
  end;

  // Original Title
  TmpStr := '<td><b>Название в оригинале:</b> ';
  LineNr := FindLine(TmpStr, Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    if Value='' then Value := GetField(fieldTranslatedTitle);
    SetField(fieldOriginalTitle, Value);
  end;

  // Year
  TmpStr := '<td><b>Год выпуска:</b> ';
  LineNr := FindLine(TmpStr, Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    SetField(fieldYear, Value);
  end;

  //Category
  TmpStr :='<td><b>Жанр:</b> ';
  LineNr := FindLine(TmpStr, Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    Value := StringReplace(Value,'/',', ');
    SetField(fieldCategory, Value);
  end;

  //Country

  // Director
  TmpStr := '<td><b>Режиссер:</b> ';
  LineNr := FindLine(TmpStr, Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    SetField(fieldDirector, Value);
  end;

  // Producer

  // Actors
  TmpStr := '<td><b>В ролях:</b> ';
  LineNr := FindLine(TmpStr, Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    SetField(fieldActors, Value);
  end;

  // Description
  TmpStr := '<td><b>О фильме:</b> ';
  LineNr := FindLine(TmpStr, Page, 0); //Начало строки описания
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Line := StringReplace(Line,TmpStr,'');
    Line := StringReplace(Line, '<br>', #13#10);
    Line := StringReplace(Line, '<BR>', #13#10);
    HTMLDecode(Line);
    HTMLRemoveTags(Line);
    Value := Trim(Line);
    SetField(fieldDescription,Value);
  end;

  // Picture
  TmpStr := '    <td valign=top><a href="http://kinoshara.com/uploads/';
  LineNr := FindLine(TmpStr, Page, 0); // Начало строки с рисунком
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := 29;
    EndPos := pos('" ', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    Address := Value;
    GetPicture(Address, False);
  end;
DisplayResults;
end;

begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('Import from Kinoshara', 'Enter the title of the movie:', MovieName) then
      AnalyzePage('http://kinoshara.com/search.php?search='+UrlEncode(MovieName));
end.
please change it to newest version :)))
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Anybody can do that :
viewtopic.php?t=1837
(that's what I used to convert most of the scripts)
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

By the way, if you want that I include it with AMC setup, could you please send it to me by e-mail ? I can't copy/past russian characters to ANSI text (I should try to find a solution since there are often russian scripts posted in the forum)
LA

Post by LA »

antp
of course, I can convert this script into new version format wo help of any tool :)
and I did it already :)))
also, I have written new RU script and both of them were sent to you by mail. You may include it in your next version of the program.

and to be able to download RU scripts from the forum, please add ability to attach files to message...

and I have one small suggestion: in Scripts Window please add ability to group scripts by different parameters (for ex., by language)... or please support subfolders in your scripts folder (it will help people to sort their scripts as they want)
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

LA wrote: and to be able to download RU scripts from the forum, please add ability to attach files to message...
I did not want to install phpbb mods because it makes the upgrades more difficult :/
LA wrote: and I have one small suggestion: in Scripts Window please add ability to group scripts by different parameters (for ex., by language)... or please support subfolders in your scripts folder (it will help people to sort their scripts as they want)
I already added a "language filter" menu for that. I don't know if more advanced things are really useful.
Post Reply