(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Goster Title=film.sarnet.pl Description=film.sarnet.pl info & picture Site=http://www.film.sarnet.pl/ Language=PL Version= Requires=3.5.0 Comments= Movie information & picture importation 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 Megafilm; var MovieName: string; Link: string; pozycja, pozycja2, pozycja3: integer; cover, nocover: boolean; 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 DecodeHTML(var Value: String); var FullValue, CharCode: String; Counter: Integer; begin if Value <> '' then begin FullValue := ''; Counter := 1; repeat if StrGet(Value, Counter) <> '&' then begin CharCode := copy(Value, Counter, 1); case CharCode of '': CharCode := ''; '': CharCode := ''; '': CharCode := ''; '': CharCode := ''; '': CharCode := ''; '': CharCode := ''; end; FullValue := FullValue + CharCode; Counter := Counter + 1; end else begin CharCode := copy(Value, Counter, 7); case CharCode of 'ą': FullValue := FullValue + ''; 'ć': FullValue := FullValue + ''; 'ę': FullValue := FullValue + ''; 'ł': FullValue := FullValue + ''; 'ń': FullValue := FullValue + ''; 'ó': FullValue := FullValue + ''; 'ś': FullValue := FullValue + ''; 'ź': FullValue := FullValue + ''; 'ż': FullValue := FullValue + ''; 'Ą': FullValue := FullValue + ''; 'Ć': FullValue := FullValue + ''; 'Ę': FullValue := FullValue + ''; 'Ł': FullValue := FullValue + ''; 'Ń': FullValue := FullValue + ''; 'Ó': FullValue := FullValue + ''; 'Ś': FullValue := FullValue + ''; 'Ź': FullValue := FullValue + ''; 'Ż': FullValue := FullValue + ''; 'Š': FullValue := FullValue + ' '; 'š': FullValue := FullValue + ''; 'Ţ': FullValue := FullValue + ''; 'ţ': FullValue := FullValue + ''; 'Ť': FullValue := FullValue + ''; 'ť': FullValue := FullValue + ''; 'Ŧ': FullValue := FullValue + ''; 'ŧ': FullValue := FullValue + ''; 'Ũ': FullValue := FullValue + ''; 'ũ': FullValue := FullValue + ''; 'Ű': FullValue := FullValue + ''; 'ű': FullValue := FullValue + ''; 'Ų': FullValue := FullValue + ''; 'ų': FullValue := FullValue + ''; 'Ŵ': FullValue := FullValue + ''; 'ŵ': FullValue := FullValue + ''; 'Ŷ': FullValue := FullValue + ''; 'ŷ': FullValue := FullValue + ''; 'Ÿ': FullValue := FullValue + ''; 'ƀ': FullValue := FullValue + ''; 'Ɓ': FullValue := FullValue + ''; 'Ƃ': FullValue := FullValue + ''; 'ƃ': FullValue := FullValue + ''; 'Ƅ': FullValue := FullValue + ''; 'ƅ': FullValue := FullValue + ''; 'Ɔ': FullValue := FullValue + ''; 'Ƈ': FullValue := FullValue + ''; 'ƈ': FullValue := FullValue + ''; 'Ɖ': FullValue := FullValue + ''; 'Ɛ': FullValue := FullValue + ''; 'Ƒ': FullValue := FullValue + ''; 'ƒ': FullValue := FullValue + ''; 'Ɠ': FullValue := FullValue + ''; 'Ɣ': FullValue := FullValue + ''; 'ƕ': FullValue := FullValue + ''; 'Ɩ': FullValue := FullValue + ''; 'Ɨ': FullValue := FullValue + ''; 'Ƙ': FullValue := FullValue + ''; 'ƙ': FullValue := FullValue + ''; 'Ȁ': FullValue := FullValue + ''; 'ȁ': FullValue := FullValue + ''; 'Ȃ': FullValue := FullValue + ''; 'ȃ': FullValue := FullValue + ''; 'Ȅ': FullValue := FullValue + ''; 'ȅ': FullValue := FullValue + ''; 'Ȇ': FullValue := FullValue + ''; 'ȇ': FullValue := FullValue + ''; 'Ȉ': FullValue := FullValue + ''; 'ȉ': FullValue := FullValue + ''; 'Ȑ': FullValue := FullValue + ''; 'ȑ': FullValue := FullValue + ''; 'Ȓ': FullValue := FullValue + ''; 'ȓ': FullValue := FullValue + ''; 'Ȕ': FullValue := FullValue + ''; 'ȕ': FullValue := FullValue + ''; 'Ȗ': FullValue := FullValue + ''; 'ȗ': FullValue := FullValue + ''; 'Ș': FullValue := FullValue + ''; 'ș': FullValue := FullValue + ''; 'Ƞ': FullValue := FullValue + ''; 'ȡ': FullValue := FullValue + ''; 'Ȣ': FullValue := FullValue + ''; 'ȣ': FullValue := FullValue + ''; 'Ȥ': FullValue := FullValue + ''; 'ȥ': FullValue := FullValue + ''; 'Ȧ': FullValue := FullValue + ''; 'ȧ': FullValue := FullValue + ''; 'Ȩ': FullValue := FullValue + ''; 'ȩ': FullValue := FullValue + ''; 'Ȱ': FullValue := FullValue + ''; 'ȱ': FullValue := FullValue + ''; 'Ȳ': FullValue := FullValue + ''; 'ȳ': FullValue := FullValue + ''; 'ȴ': FullValue := FullValue + ''; 'ȵ': FullValue := FullValue + ''; 'ȶ': FullValue := FullValue + ''; 'ȷ': FullValue := FullValue + ''; 'ȸ': FullValue := FullValue + ''; 'ȹ': FullValue := FullValue + ''; 'ɀ': FullValue := FullValue + ''; 'Ɂ': FullValue := FullValue + ''; 'ɂ': FullValue := FullValue + ''; 'Ƀ': FullValue := FullValue + ''; 'Ʉ': FullValue := FullValue + ''; 'Ʌ': FullValue := FullValue + ''; 'Ɇ': FullValue := FullValue + ''; 'ɇ': FullValue := FullValue + ''; 'Ɉ': FullValue := FullValue + ''; 'ɉ': FullValue := FullValue + ''; 'ɐ': FullValue := FullValue + ''; 'ɑ': FullValue := FullValue + ''; 'ɒ': FullValue := FullValue + ''; 'ɓ': FullValue := FullValue + ''; 'ɔ': FullValue := FullValue + ''; 'ɕ': FullValue := FullValue + ''; '&#x%DF;': FullValue := FullValue + ''; '4': FullValue := FullValue + '"'; '–': FullValue := FullValue + '-'; '‘': FullValue := FullValue + '"'; '’': FullValue := FullValue + '"'; '“': FullValue := FullValue + '"'; '”': FullValue := FullValue + '"'; '„': FullValue := FullValue + '"'; else FullValue := FullValue + CharCode; end; Counter := Counter + 7; end; until Counter > Length(Value); HTMLDecode(FullValue); Value := FullValue; end end; procedure AnalyzePage(); var Page: TStringList; pozycja, startPos, endPos: integer; linia, adres, tytul: string; begin Page := TStringList.Create; link := URLEncode('http://www.film.sarnet.pl//?show=szukaj&SID=da2725d4cbff8d2cea3a1d67120aeb5f&word=' + MovieName); Page.Text := GetPage(link); pozycja := FindLine('0 znalezionych', Page, 0); if pozycja = -1 then begin pozycja := FindLine('znalezionych', Page, 0); if (pozycja >-1) then begin PickTreeClear; linia := Page.GetString(pozycja); startPos := pos('znalezionych', Linia); delete(linia, 1, startPos + 11); if (pos('[Film]', linia) > 0) then begin while (pos('[Film]', linia) > 0) do begin startPos := pos('[Film]', Linia); delete(linia, 1, startPos + 5); startPos := pos('', Linia); adres := copy(linia, 1, endPos - 1); delete(linia, 1, endPos); adres := 'http://www.film.sarnet.pl/' + adres; endPos := pos('• ', Linia); if endPos = 0 then begin endPos := length(linia); tytul := copy(linia, 1, endPos); end else tytul := copy(linia, 1, endPos - 1); HTMLRemoveTags(tytul); DecodeHTML(tytul); if pos('Newsy', tytul) > 0 then delete(tytul, pos('Newsy', tytul), length(tytul)); if pos('Artykuy', tytul) > 0 then delete(tytul, pos('Artykuy', tytul), length(tytul)); if pos('Napisy', tytul) > 0 then delete(tytul, pos('Napisy', tytul), length(tytul)); PickTreeAdd(tytul, adres); end; end else begin DecodeHTML(MovieName); ShowMessage('Nie znaleziono adnego filmu speniajcego kryteria: "'+MovieName+'".'); end; end else begin DecodeHTML(MovieName); ShowMessage('Nie znaleziono adnego filmu speniajcego kryteria: "'+MovieName+'".'); end; end else begin DecodeHTML(MovieName); ShowMessage('Nie znaleziono adnego filmu speniajcego kryteria: "'+MovieName+'".'); end; if PickTreeExec(adres) then begin Page.Text := GetPage(adres); link := adres; AnalyzeMoviePage(page); end; Page.Free; end; procedure AnalyzeMoviePage(Page: TStringList); var Linia, tytul, line, Obsada, OrgLine: string; LineNr, licznik: Integer; StartPos, EndPos, i: Integer; begin if cover = false then begin // Tytu polski i oryginalny pozycja := FindLine('Szukaj:', Page, 0); pozycja := pozycja + 1; repeat begin linia := Page.GetString(pozycja); HTMLRemoveTags(linia); DecodeHTML(linia); while ((copy(linia, 1, 1) = ' ') or (copy(linia, 1, 1) = ' ') or (copy(linia, 1, 1) = '')) do delete(linia, 1, 1); if (linia = '') then pozycja := pozycja +1; end; until (linia <> ''); startPos := pos('(', linia); endPos := pos(')', linia); if ((startPos = 0) and (endPos = 0)) then begin tytul := copy(linia, 1, length(linia)); while ((copy(tytul, 1, 1) = ' ') or (copy(tytul, 1, 1) = ' ')) do delete(tytul, 1, 1); while ((copy(tytul, length(tytul), 1) = ' ') or (copy(tytul, length(tytul), 1) = ' ') or (copy(tytul, length(tytul), 1) = '')) do delete(tytul, length(tytul), 1); setField(fieldTranslatedTitle, tytul); setField(fieldOriginalTitle, tytul); end else begin tytul := copy(linia, 1, startPos - 1); while ((copy(tytul, 1, 1) = ' ') or (copy(tytul, 1, 1) = ' ') or (copy(tytul, 1, 1) = '')) do delete(tytul, 1, 1); while ((copy(tytul, length(tytul), 1) = ' ') or (copy(tytul, length(tytul), 1) = ' ') or (copy(tytul, length(tytul), 1) = '')) do delete(tytul, length(tytul), 1); setField(fieldTranslatedTitle, tytul); tytul := copy(linia, startPos + 1, endPos - startPos - 1); while ((copy(tytul, 1, 1) = ' ') or (copy(tytul, 1, 1) = ' ') or (copy(tytul, 1, 1) = '')) do delete(tytul, 1, 1); while ((copy(tytul, length(tytul), 1) = ' ') or (copy(tytul, length(tytul), 1) = ' ') or (copy(tytul, length(tytul), 1) = '')) do delete(tytul, length(tytul), 1); setField(fieldOriginalTitle, tytul); end; // Opis filmu tytul := ''; pozycja := pozycja + 1; repeat begin linia := Page.GetString(pozycja); HTMLRemoveTags(linia); while ((copy(linia, 1, 1) = ' ') or (copy(linia, 1, 1) = ' ') or (copy(linia, 1, 1) = '')) do delete(linia, 1, 1); DecodeHTML(linia); if (linia = '') then pozycja := pozycja +1; end; until (linia <> ''); pozycja2 := FindLine('ocena:', Page, 0); repeat begin linia := Page.GetString(pozycja); while ((copy(linia, 1, 1) = ' ') or (copy(linia, 1, 1) = ' ') or (copy(linia , 1, 1) = '')) do delete(linia, 1, 1); if (linia = '') then begin pozycja := pozycja + 1; linia := Page.GetString(pozycja); end; pozycja3 := pos('