(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Karamov Ilshat aka KAA (kaasoft@gmail.com) Title=Kino-Govno (RU) Description=Import from www.kino-govno.com Site=www.kino-govno.com Language=RU Version=1.0.0 Requires=3.5.0 Comments=Доступ к рецензиям, размещенным на сайте www.kino-govno.com License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GetInfo=1 [Options] ***************************************************) program kinogovnokom; const BaseAddress = 'http://kino-govno.com/'; var MovieName: string; //============================================================================== procedure AnalyzePage(Address: string); var Page: TStringList; AddressText: string; HTMLText: string; BeginPos, EndPos: Integer; begin Page := TStringList.Create; if Address <> 'http://kino-govno.com/?search&s_str=' then begin Page.Text := GetPage(Address); HTMLText := GetText(Page.Text, 'Рецензии', 'Новости'); if Pos('ничего не найдено', HTMLText) > 0 then begin ShowWarning('Увы и ах - по вашему запросу ничего не найдено. Попробуйте позвонить позднее.'); Exit; end else begin PickTreeClear; PickTreeAdd('Найденные фильмы:', ''); AddMoviesTitles(HTMLText); end; end else begin PickTreeClear; PickTreeAdd('Рецензии на Кино-Говно.ком в алфавитном порядке', ''); AddAlphabet(); if PickTreeExec(AddressText) then begin Page.Text := GetPage(AddressText); HTMLText := Page.Text; end; BeginPos := Pos('>Все

', HTMLText); HTMLText := Copy(HTMLText, BeginPos+Length('>Все

'), Length(HTMLText)); EndPos := Pos('Архив рецензий', HTMLText); HTMLText := Copy(HTMLText, 0, EndPos-1); Page.Text:=Trim(HTMLText); PickTreeClear; PickTreeAdd('Фильмы на выбранный символ', ''); AddMoviesTitles1(Page); end; if PickTreeExec(AddressText) then begin // URL if CanSetField(fieldURL) then SetField(fieldURL, AddressText); Page.Text := GetPage(AddressText); AnalyzeVideoPage(Page); end Page.Free; end; //============================================================================== procedure AddAlphabet(); var i: integer; Alphabet, Addresses, MovieTitle, MovieAddress: string; StartPos, EndPos: Integer; begin MovieTitle:=''; Alphabet :='===========Английские-названия========== '+ '0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z '+ '============Русские-названия============ '+ '0-9 А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я '; Addresses:='@ '+ '0eng A B C D E F G H I J K L M N O P Q R S T U V W X Y Z '+ '@ '+ '0рус А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я '; StartPos:=1; for i:=1 to 57 do begin EndPos:=Pos(' ', Alphabet); MovieTitle := Copy(Alphabet, 1, EndPos); Alphabet:=Copy(Alphabet, EndPos+1, Length(Alphabet)); EndPos:=Pos(' ', Addresses); MovieAddress := Copy(Addresses, 1, EndPos-1); Addresses:=Copy(Addresses, EndPos+1, Length(Addresses)); if MovieAddress='@' then PickTreeAdd(MovieTitle, '') else PickTreeAdd(MovieTitle, BaseAddress+'?reviews&letter='+MovieAddress); end; end; //============================================================================== procedure AddMoviesTitles(HTMLText: String); var i: integer; Line, Text: string; Page: TStringList; MovieTitle, MovieAddress: string; StartPos, EndPos: Integer; begin Page:=TStringList.Create; HTMLText := StringReplace(HTMLText, '
', ''); HTMLText := StringReplace(HTMLText, '
', Line); MovieAddress := Copy(Line, 0, EndPos-1); Line:=Copy(Line, EndPos+Length('">'), Length(Line)); EndPos := Pos('', Line); MovieTitle := Copy(Line, 0, EndPos-1); HTMLDecode(MovieTitle); HTMLRemoveTags(MovieTitle); MovieTitle := Trim(MovieTitle); if MovieTitle='()' then MovieTitle := '(НАЗВАНИЕ ОТСУТСТВУЕТ)'; PickTreeAdd(MovieTitle, BaseAddress+MovieAddress); end; Page.Free; end; //============================================================================== procedure AddMoviesTitles1(Page: TStringList); var i: integer; Line, Text: string; MovieTitle, MovieAddress: string; StartPos, EndPos: Integer; begin Text := StringReplace(Page.Text, '"', Line); MovieAddress := Copy(Line, 0, EndPos-1); Line:=Copy(Line, EndPos+Length('">"'), Length(Line)); //EndPos := Pos('', Line); EndPos := Pos(' (', Line); MovieTitle := Copy(Line, 0, EndPos-1); Line:=Copy(Line, EndPos+Length(' ('), Length(Line)); HTMLDecode(MovieTitle); HTMLRemoveTags(MovieTitle); MovieTitle := StringReplace(MovieTitle, ')"', ') "'); MovieTitle := StringReplace(MovieTitle, '" (', ' ('); PickTreeAdd(MovieTitle, BaseAddress+MovieAddress); end; end; //============================================================================== function GetText (Line: string; sBegin, sEnd: string): string; var BeginPos, EndPos: Integer; s: string; begin Result := ''; BeginPos := Pos(sBegin, Line) + Length(sBegin); EndPos := Pos(sEnd, Line); if (BeginPos = 0) or (sBegin='') then BeginPos := 1; if (EndPos = 0) or (sEnd='') then EndPos := Length(Line); s := Copy(Line, BeginPos, EndPos - BeginPos); Result := s; end; //============================================================================== procedure AnalyzeVideoPage(Page: TStringList); var HTMLText, Rating, Text: string; BeginPos, EndPos: Integer; MovieName, MovieNameTrans, MovieNameOrig, MovieRating, MoviePictureAddress, MovieDescription, MovieComments: string; begin HTMLText:=Page.Text; BeginPos := Pos('
«', HTMLText)+Length('
«'); HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText)); EndPos := Pos('
', HTMLText); HTMLText := Copy(HTMLText, 0, EndPos-1); HTMLText:=Trim(StringReplace(HTMLText,'

',#13#10)); // Наименование if CanSetField(fieldTranslatedTitle) then begin EndPos := Pos('»

', HTMLText); MovieNameTrans := Trim(Copy(HTMLText, 0, EndPos-1)); HTMLDecode(MovieNameTrans); HTMLRemoveTags(MovieNameTrans); SetField(fieldTranslatedTitle, MovieNameTrans); end; BeginPos := Pos('»
', HTMLText)+Length('»
'); HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText)); // Оригинальное наименование if CanSetField(fieldOriginalTitle) then begin EndPos := Pos('

', HTMLText); MovieNameOrig := Trim(Copy(HTMLText, 0, EndPos-1)); HTMLDecode(MovieNameOrig); HTMLRemoveTags(MovieNameOrig); SetField(fieldOriginalTitle, MovieNameOrig); end; BeginPos := Pos('

', HTMLText)+Length('

'); HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText)); // Рейтинг if CanSetField(fieldRating) then begin BeginPos := Pos('Читательский рейтинг

', HTMLText)+Length('Читательский рейтинг


'); Rating := Copy(HTMLText, BeginPos, Length(HTMLText)); BeginPos := Pos('

', HTMLText)+Length('

'); Rating := Copy(HTMLText, BeginPos, Length(HTMLText)); EndPos := Pos('%', Rating); Rating := Trim(Copy(Rating, 0, EndPos-1)); Rating := StringReplace(Rating, ' ',''); HTMLRemoveTags(Rating); Rating:=Trim(Rating); if StrToInt(Rating, 0) <> 0 then begin Rating:=FloatToStr(StrToFloat(Rating)/10); SetField(fieldRating, Rating); end; end; // Описание if CanSetField(fieldDescription) then begin EndPos := Pos('', HTMLText); MovieDescription := Copy(HTMLText, 0, EndPos-1); MovieDescription:=Trim(StringReplace(MovieDescription,'−','-')); MovieDescription:=Trim(StringReplace(MovieDescription,'–','-')); MovieDescription:=Trim(StringReplace(MovieDescription,'—','-')); MovieDescription:=Trim(StringReplace(MovieDescription,'…','...')); MovieDescription:=Trim(StringReplace(MovieDescription,'Кадры из фильма','')); MovieDescription:=Trim(StringReplace(MovieDescription,'
',#13#10)); MovieDescription:=Trim(StringReplace(MovieDescription,'
',#13#10)); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, ' ', ' '); MovieDescription:=StringReplace(MovieDescription, #13#10+' ', #13#10); MovieDescription:=StringReplace(MovieDescription, #13#10+#13#10+' ', #13#10); HTMLDecode(MovieDescription); HTMLRemoveTags(MovieDescription); SetField(fieldDescription, 'Рецензия на Кино-Говно.ком:'+#13#10+MovieDescription); end; // Коментарий-отзыв if CanSetField(fieldComments) then begin MovieComments := 'Вердикт:'; BeginPos := Pos('' ,HTMLText)+Length(''); HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText)); EndPos := Pos('' ,HTMLText); MovieComments := MovieComments + Copy(HTMLText, 0, EndPos-1)+#13#10; MovieComments := MovieComments+'Перевод:'; BeginPos := Pos('' ,HTMLText)+Length(''); HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText)); EndPos := Pos('' ,HTMLText); MovieComments := MovieComments + Copy(HTMLText, 0, EndPos-1)+#13#10; BeginPos := Pos('Мнения

', HTMLText)+Length('Мнения

');; if BeginPos>0 then begin Text := Copy(HTMLText, BeginPos, Length(HTMLText)); EndPos:=Pos('
', Text); MovieComments:=MovieComments+Copy(Text, 0, EndPos-1); end; MovieComments:=Trim(StringReplace(MovieComments,'"','"')); HTMLDecode(MovieComments); HTMLRemoveTags(MovieComments); SetField(fieldComments, 'Комментарий редакции Кино-Говно.ком на фильм:'+#13#10+MovieComments); end; end; //============================================================================== begin if CheckVersion(3,5,0) then begin MovieName := GetField(fieldTranslatedTitle); if MovieName = '' then MovieName := GetField(fieldOriginalTitle); if Input('Поиск на Кино-говно.ком', 'Название фильма (пусто для доступа по алфавиту):', MovieName) then begin AnalyzePage('http://kino-govno.com/?search&s_str='+UrlEncode(MovieName)); end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.