Skip to content

Commit

Permalink
feat: add fetch by country at flixhq.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Adailton Nascimento committed Feb 22, 2024
1 parent beb68e6 commit aa86c4c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/providers/movies/flixhq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,35 @@ class FlixHQ extends MovieParser {
throw new Error((err as Error).message);
}
};

fetchByCountry = async (country: string): Promise<IMovieResult[]> => {
try {
const { data } = await this.client.get(`${this.baseUrl}/country/${country}`);
const $ = load(data);

const movies = $('div.container > section.block_area > div.block_area-content > div.film_list-wrap > div.flw-item')
.map((i, el) => {
const movie = {
id: $(el).find('div.film-poster > a').attr('href')?.slice(1)!,

Check warning on line 395 in src/providers/movies/flixhq.ts

View check run for this annotation

codefactor.io / CodeFactor

src/providers/movies/flixhq.ts#L395

Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong. (@typescript-eslint/no-non-null-asserted-optional-chain)
title: $(el).find('div.film-detail > h2.film-name > a').attr('title')!,
url: `${this.baseUrl}${$(el).find('div.film-poster > a').attr('href')}`,
image: $(el).find('div.film-poster > img').attr('data-src'),
season: $(el).find('div.film-detail > div.fd-infor > span:nth-child(1)').text(),
latestEpisode: $(el).find('div.film-detail > div.fd-infor > span:nth-child(3)').text() || null,
type:
$(el).find('div.film-detail > div.fd-infor > span.float-right').text() === 'Movie'
? TvType.MOVIE
: TvType.TVSERIES,

}
return movie
})
.get();
return movies;
} catch (err) {
throw new Error((err as Error).message);
}
};
}

// (async () => {
Expand Down

0 comments on commit aa86c4c

Please sign in to comment.