
Przydałaby się jeszcze poprawka pobierająca czas trwania
niestety za wysokie progi jak dla mnieZnalazłem też mały mankament, po wyszukaniu filmu w filwebie nie wyświetla jego roku produkcji co jest trochę uciążliwe jak się trafi film z takim samym tytułem i różnymi rokami produkcji. Na obrazku to widać dobrze
Znowu coś namieszali i nie pobiera gatunku filmu .... Możesz zerknąć?Master_Rafael wrote: 2024-09-24 12:09:05 Uprzedzam, że może to nie działać ze wszystkimi filmami dobrze bo nie testowałem tego na dużą skalę. Dodatkowo mogę stwierdzić, że raczej jestem zielony w kodowaniu![]()
Code: Select all
// Gatunek
Line := TextBetween(Page.Text, '"filmPosterSection__buttons tags-container"', '<div class="LinkButton linkButton"');
if Length(Line) > 0 then
begin
case GetOption('SeparatorGatunku') of
0: Separator := ' / ';
1: Separator := ', ';
2: Separator := '/';
end;
Value := '';
while Pos('linkButton__label', Line) > 0 do
begin
Line2 := TextBetween(Line, 'linkButton__label', '/span>');
Line := RemainingText;
Line2 := TextBetween(Line2, 'itemprop="genre"> ', ' <');
Value := Value + Line2 + Separator;
end;
Value := Copy(Value, 1, Length(Value) - Length(Separator));
Value := StringReplace(Value, ', ', Separator);
UniToPol(Value);
if Length(Value) > 0 then
SetField(fieldCategory, Trim(Value));
end;
Code: Select all
//Dystrybucja
if (CanSetCustomField('Dystrybucja') and (Pos('filmMainOtherInfo">dystrybucja', Page.Text) > 0)) then
begin
Line := TextBetween(Page.Text, 'filmMainOtherInfo">dystrybucja', '/div></div>');
Value := TextBetween(Line, 'filmInfo__info">', '<');
if Pos('nofollow', Value) > 0 then
Value := TextBetween(Value, 'nofollow">', '<');
UniToPol(Value);
if Length(Value) > 0 then
SetCustomField('Dystrybucja', Value);
end;
Code: Select all
//Budżet
if (CanSetCustomField('Budzet') and (Pos('filmMainOtherInfo">budżet', Page.Text) > 0)) then
begin
Line := TextBetween(Page.Text, 'filmMainOtherInfo">budżet', '/span></div></div>');
Value := TextBetween(Line, 'filmMainOtherInfo">', '<');
if Length(Value) > 0 then
SetCustomField('Budzet', Value);
end;
Code: Select all
//BoxOffice
if (CanSetCustomField('Boxoffice') and (Pos('<div class="boxoffice"', Page.Text) > 0)) then
begin
Line := TextBetween(Page.Text, '<div class="boxoffice"', '<div class="filmInfo__header">');
Value := TextBetween(Line, 'filmMainOtherInfo">', '</span></div></div>');
Value := StringReplace(Value, '</span></div><div>', ', ');
Value := StringReplace(Value, ' <span data-i18n="film:info.gross.label" data-cacheId="filmMainOtherInfo">', ' ');
UniToPol(Value);
if Length(Value) > 0 then
SetCustomField('Boxoffice', Value);
end;
Code: Select all
procedure GetMovieTitles(Address: string);
var
Page: TStringList;
Line, Year, MovieTitle, MovieAddress: string;
LineNr: integer;
begin
Page := TStringList.Create;
Page.Text := UTF8ToCP1250(GetPage(Address));
Page.Text := StringReplace(Page.Text, 'class="preview__link"', #13#10 + 'class="preview__link"');
Line := Page.Text;
LineNr := FindLine('class="preview__link"', Page, 0);
while LineNr > -1 do
begin
Line := Page.GetString(LineNr);
Line := Czysc(Line);
MovieAddress := 'https://www.filmweb.pl' + TextBetween(Line, 'preview__link" href="', '"');
MovieTitle := TextBetween(Line, '>', '</');
// HTMLRemoveTags(MovieTitle);
MovieTitle := Trim(MovieTitle);
CorrectTextError(MovieTitle);
UniToPol(MovieTitle);
//Year := TextBetween(Line, 'filmPreview__year">', '</');
Year := TextBetween(Line, 'preview__year" content="', '</');
if (Year = '') then
Year := TextBetween(Line, '"', '"');
// HTMLRemoveTags(Year);
Year := Trim(Year);
CorrectTextError(Year);
Year := Copy(Year, 1, 4);
MovieTitle := MovieTitle + ' (' + Year + ')';
if (FindLine(MovieAddress, SearchAddresses, 0) < 0) then
begin
PickTreeAdd(MovieTitle, MovieAddress);
SearchAddresses.Add(MovieAddress);
end;
LineNr := FindLine('class="preview__link"', Page, LineNr + 1);
end;
Page.Free;
end;
procedure AnalyzeSearchPage(Address: string; MovieType: string);
var
Page: TStringList;
Line, Linetmp, MovieVariety, AdressSubPage: string;
LineNr, Count, MoviesCount, i, NumOfPages: integer;
begin
Page := TStringList.Create;
Page.Text := UTF8ToCP1250(GetPage(Address));
Line := TextBetween(Page.Text, 'Znalezione pozycje: <span>', '</span>');
MovieVariety := Page.Text;
Line := Czysc(Line);
MoviesCount := StrToInt(Trim(Line), 0);
MovieVariety := ' ' + MovieType + ':';
PickTreeAdd('Znaleziono' + 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;
for i := 1 to NumOfPages do
begin
AdressSubPage := Address + '&page=' + IntToStr(i);
GetMovieTitles(Address + '&page=' + IntToStr(i));
end;
// if (SearchAddresses.Count = 0) then
// MovieName := SmartFormatMovieName(MovieName);
Page.Free;
end;
Code: Select all
// Gatunek
Line := TextBetween(Page.Text, '<div class="filmPosterSection__buttons tags-container">', '<button type="button" class="tag more hide">');
if Length(Line) > 0 then
begin
case GetOption('SeparatorGatunku') of
0: Separator := ' / ';
1: Separator := ', ';
2: Separator := '/';
end;
Value := '';
while Pos('linkButton__label', Line) > 0 do
begin
Line2 := TextBetween(Line, 'linkButton__label', '/span>');
Line := RemainingText;
Line2 := TextBetween(Line2, 'itemprop="genre"> ', '<');
Value := Value + Line2 + Separator;
end;
Value := Copy(Value, 1, Length(Value) - Length(Separator) -1);
Value := StringReplace(Value,' , ', Separator);
Value := StringReplace(Value,' ,','');
UniToPol(Value);
if Length(Value) > 0 then
SetField(fieldCategory, Trim(Value));
end;