(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=(c) 2007-2010 AmBeR (mod zralek & ya_corp & jlatk) Title=filmweb.pl Description=Import data & picture from filmweb.pl Site=http://www.filmweb.pl Language=PL Version=2.0.1.3 Beta (11.07.2010) Requires=3.5.0.1 Comments=First AMC script for filmweb.pl was made by Piotr Kardasz in year 2002. 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] Plakat=1|1|0=Bez plakatu|1=Duży plakat|2=Mały plakat OpisFilmu=1|0|0=Wyświetl opisy do wyboru|1=Pobrać pierwszy Komentarze=1|2|0=Pozostawić puste|1=Pobrać domyślną recenzje|2=Pobrać recenzje z możliwością wyboru|3=Pobrać ciekawostki SeparatorKraju=0|0|0=Separatorem slash i spacje po obu stronach ' / '|1=Separatorem przecinek ', '|2=Separatorem slash bez spacji '/' SeparatorGatunku=0|0|0=Separatorem slash i spacje po obu stronach ' / '|1=Separatorem przecinek ', '|2=Separatorem slash bez spacji '/' UkladAktorow=1|1|0=Układ typu ' (jako )' roździelone przecinkami|1=Układ typu ' (jako )' każdy w osobnej linii|2=Układ typu ' - ' roździelone przecinkami|3=Układ typu ' - ' każdy w osobnej linii|4=Układ typu '' roździelone przecinkami|5=Układ typu '' każdy w osobnej linii IloscAktorow=0|0|0=Pobierz wszystkich dostępnych|1=Ogranicz do 10|2=Ogranicz do 20|3=Ogranicz do 30|4=Ogranicz do 40|5=Ogranicz do 50 LimitWynikow=3|1|0=Pobierz wszyskie filmy o podanej nazwie|1=Pobierz 10 najbardziej pasujących tytułów|2=Ogranicz do 50|3=Ogranicz do 100|4=Ogranicz do 500 CzyDodDaneWPoluAktorzy=1|1|0=Nie pobieraj danych o dodatkowych twórcach|1=Pobierz dodatkowe dane o twórcach i wpisz do pola "Obsada". ***************************************************) (********************************************************* * * * VERSION HISTORY * * * * 1.0.0.8 Alpha (08.03.2007) * * - initial release * * * * 1.0.0.22 Beta (20.12.2007) * * - minor fixes * * - public release * * * * 2.0.0.23 Beta (24.12.2007) * * - changing major version to 2.x.x.x * * - improved search when year exists * * - small changes * * * * 2.0.0.29 Beta (27.12.2007) * * - can get Film Review or Film Curiosities to * * description field * * - movies search improvements * * - small changes * * * * 2.0.0.36 Beta (07.01.2008) * * - when no akcepted description exist, search for * * no akcepted description * * - correct html codes in description field * * - minor changes and fixes * * * * 2.0.0.38 Beta (28.01.2008) * * - change in collecting film roles * * * * 2.0.0.39 Beta (03.02.2008) * * - fixed actors layout * * * * 2.0.0.40 Beta (08.02.2008) * * - small encoding fixes * * * * 2.0.0.41 Beta (12.03.2008) * * - small fixes * * * * 2.0.0.43 Beta (01.04.2008) * * - taking titles was corrected * * * * 2.0.0.45 Beta (03.04.2008) * * - adapted for changes on filmweb.pl * * - taking the review was improved * * * * 2.0.0.46 Beta (05.04.2008) * * - minor fixes * * * * 2.0.0.47 Beta (03.06.2008) * * - adapted for changes on filmweb.pl * * * * 2.0.0.48 Beta (04.06.2008) * * - small fixes * * * * 2.0.0.50 Beta (19.06.2008) * * - fixed encoding * * - fixed script loop * * * * 2.0.0.51 Beta (07.07.2008) * * - taking titles was corrected * * * * 2.0.0.52 Beta (16.07.2008) * * - small fixes * * * * 2.0.0.53 Beta (08.10.2008) * * - fixed Genre detection + separator * * - fixed FilmDescriptions garbage + "'" * * * * 2.0.0.54 Beta (18.10.2008) * * - fixed Oryginal & Translated title taking method * * - fixed Char translation with "szyjka" sugestion * * * * 2.0.0.55 Beta (05.01.2009) * * - much better serch result, mod by Zralek THX * * * * 2.0.0.56 Beta (12.01.2009) * * - fixed actors layout * * * * 2.0.0.57 Beta (05.02.2009) * * - fixed actors layout * * - taking the review and curiosities was improved * * - added google search results for unusual filenames * * * * 2.0.0.58 Beta (17.02.2009) * * - added to download a additional detailed * * description of the directors * * - added to download a additional detailed * * description of the producers * * - The inclusion of paragraphs * * in the procedure AnalyzeFilmDescriptionsPage * * - added a new parameter called * * "CzyDodDaneWPoluAktorzy". Available values: * * 0 (default value "Don't download additional data") * * 1 ("Download additional data and add * * them to the "fieldActors""). * * - added variable of type TStringList to search actors* * - to the "fieldActors" added the download * * the creators of scenario, additional materials to * * the scenario, music, photografy, the collection * * assembly, the scenery designers collection, * * the collection costume designers, the sound track * * * * 2.0.0.59 Beta (23.03.2009) * * - code cleanup * * - fixed getting small film poster bug * * - better google search results for unusual movienames* * * * 2.0.0.60 Beta (07.04.2009) * * - fixed description of the producers * * - fixed taking the review * * * * 2.0.0.61 Beta (08.07.2009) * * - fixed description of the producers * * - fixed taking the film descriptions * * * * 2.0.0.62 and 2.0.0.63 Beta (09 and 21.07.2009) * * - taking titles and year was corrected * * * * 2.0.0.64 Beta (13.08.2009) * * - small fixes * * * * 2.0.1.1 Beta (21.05.2010) * * - adapted for changes on filmweb.pl * * * * 2.0.1.2 Beta (03.07.2010) * * - adapted for changes on filmweb.pl * * - taking description and rating was corrected * * * * 2.0.1.3 Beta (11.07.2010) * * - fixed taking the review and curiosities * *********************************************************) program filmwebpl; uses StringUtils7552; var MovieName : String; SearchAddresses : TStringList; procedure GetMovieTitles(Address : String); var Page : TStringList; Line : String; i : Integer; LineNr, LineNr2 : Integer; MovieTitle, MovieAddress : String; Year : String; begin Page := TStringList.Create; Page.Text := UTF8Decode(GetPage(Address)); //W wynikach wyszukiwanaia wszystkie wpisy sa w jednej linii. //Rozdzielamy zeby kazdy wynik byl w osoblnej, bo tak sie latwiej na tym operuje Page.Text := StringReplace(Page.Text, '
  • ', #13#10 + '
  • '); Page.Text := StringReplace(Page.Text, ' -1 do begin //Pobieranie tytułu i URL Line := Page.GetString(LineNr); MovieAddress := 'http://www.filmweb.pl' + TextBetween(Line, 'href="', '">'); //Czasem w adresie strony sa dodatkowe spacje MovieAddress := StringReplace(MovieAddress, ' ', ''); MovieTitle := TextBetween(Line, '">', ''); HTMLRemoveTags(MovieTitle); MovieTitle := Trim(MovieTitle); CorrectTextError(MovieTitle); UniToPol(MovieTitle); //Pobierania roku produkcji Year := TextBetween(Line, '', ''); if (Year = '') then begin Line := Page.GetString(LineNr + 1); Year := TextBetween(Line, '', ''); end; HTMLRemoveTags(Year); Year := Trim(Year); CorrectTextError(Year); Year := TextBefore(Year, '|', ''); Year := StringReplace(Year, ' ', ''); MovieTitle := MovieTitle + ' (' + Year + ')'; //Dodanie do drzewka if (FindLine(MovieAddress, SearchAddresses, 0) < 0) then begin PickTreeAdd(MovieTitle, MovieAddress); SearchAddresses.Add(MovieAddress); end; LineNr := FindLine(' -1 then Page.Text := UTF8Decode(GetPage(Address)); Line := TextBetween(Page.Text, 'bg_search_res_no', ''); Line := TextBetween(Line, '', ''); MoviesCount := StrToInt(Line, 0); PickTreeClear; if MoviesCount = 1 then MovieVariety := ' film:' else if (MoviesCount >= 2) and (MoviesCount <= 3) then MovieVariety := ' filmy:' else if (MoviesCount >= 5) and (MoviesCount <= 21) then MovieVariety := ' filmów:' else begin if ((MoviesCount - ((MoviesCount div 10) * 10)) >= 2) and ((MoviesCount - ((MoviesCount div 10) * 10)) <= 4) then MovieVariety := ' filmy:' else MovieVariety := ' filmów:'; end; PickTreeAdd('Znaleziono ' + IntToStr(MoviesCount) + MovieVariety, ''); case GetOption('LimitWynikow') of 0: Count := 260; 1: Count := 1; 2: Count := 5; 3: Count := 10; 4: Count := 50; end; NumOfPages := (MoviesCount - 1) div 10 + 1; if NumOfPages < 1 then NumOfPages := 1; if NumOfPages > Count then NumOfPages := Count; SearchAddresses := TStringList.Create; for i := 1 to NumOfPages do GetMovieTitles(Address + '&page=' + IntToStr(i)); if SearchAddresses.Count > 0 then begin if (MoviesCount = 1) and (SearchAddresses.Count = 1) then begin SetField(fieldURL, SearchAddresses.GetString(0)); AnalyzeMoviePage(SearchAddresses.GetString(0)); end else if PickTreeExec(Address) then begin SetField(fieldURL, Address); AnalyzeMoviePage(Address); end; end else begin PickTreeClear; MovieName := SmartFormatMovieName(MovieName); win2utf(MovieName); AnalyzeGooglesResultsPage('http://www.google.pl/search?hl=pl&num=20&q=' + MovieName); if PickTreeExec(Address) then begin SetField(fieldURL, Address); AnalyzeMoviePage(Address); end; end; Page.Free; end; // Getting search results; spec = 1 - results, spec = 2 - www addresses function GooglesResultsPage(GoogleAddress: string; spec: Integer):TStringList; var PageText: string; Value: string; Address: string; begin Result := TStringList.Create; PageText := GetPage(GoogleAddress); repeat Value := TextBetween(PageText, '

    ', ''); PageText := RemainingText; Address := TextBetween(Value, ''); Value := StringReplace(Value, '"', '"'); Value := StringReplace(Value, '&', '&'); Value := StringReplace(Value, '€', '€'); Value := StringReplace(Value, 'Á', 'A'); Value := StringReplace(Value, 'ú', 'u'); Value := StringReplace(Value, #13#10, ''); end; procedure GetFilmCuriosities(Address : String); var Line, Value : String; LineNr, i : Integer; Page : TStringList; begin Page := TStringList.Create; Page.Text := UTF8Decode(GetPage(Address)); LineNr := FindLine('
    ', Page, 0); if LineNr > -1 then begin LineNr := LineNr + 1; Line := Page.GetString(LineNr); while (Pos('