diff --git a/src/source/Soaper.test.ts b/src/source/Soaper.test.ts
index bd3ce4d..97896c7 100644
--- a/src/source/Soaper.test.ts
+++ b/src/source/Soaper.test.ts
@@ -40,4 +40,9 @@ describe('Soaper', () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt0093058', undefined, undefined));
expect(streams).toMatchSnapshot();
});
+
+ test('handle lego heroes flash', async () => {
+ const streams = await handler.handle(ctx, 'movie', new TmdbId(504997, undefined, undefined));
+ expect(streams).toMatchSnapshot();
+ });
});
diff --git a/src/source/Soaper.ts b/src/source/Soaper.ts
index 5541544..e3f264b 100644
--- a/src/source/Soaper.ts
+++ b/src/source/Soaper.ts
@@ -58,9 +58,16 @@ export class Soaper implements Source {
const $ = cheerio.load(html);
- return $(`.thumbnail .img-group:has(.img-tip:contains("${year}")) a[href^="${hrefPrefix}"]`)
+ const exactKeyWordMatchUrl = $(`a[href^="${hrefPrefix}"]`)
+ .filter((_i, el) => $(el).text().toLowerCase() === keyword.toLowerCase())
.map((_i, el) => new URL($(el).attr('href') as string, this.baseUrl))
.get(0);
+
+ const yearMatchUrl = $(`.thumbnail .img-group:has(.img-tip:contains("${year}")) a[href^="${hrefPrefix}"]`)
+ .map((_i, el) => new URL($(el).attr('href') as string, this.baseUrl))
+ .get(0);
+
+ return exactKeyWordMatchUrl ?? yearMatchUrl;
};
private readonly getKeywordYearAndHrefPrefix = async (ctx: Context, tmdbId: TmdbId): Promise<[string, number, string]> => {
diff --git a/src/source/__fixtures__/Soaper/https:api.themoviedb.org3movie504997 b/src/source/__fixtures__/Soaper/https:api.themoviedb.org3movie504997
new file mode 100644
index 0000000..4f424fc
--- /dev/null
+++ b/src/source/__fixtures__/Soaper/https:api.themoviedb.org3movie504997
@@ -0,0 +1 @@
+{"adult":false,"backdrop_path":"/uSVXTWbdPPpiecRlGvIZrz9gc8Q.jpg","belongs_to_collection":{"id":386162,"name":"LEGO DC Comics Super Heroes Collection","poster_path":"/noBsTnvxo1G4DVd36kaKSbTtM1M.jpg","backdrop_path":"/xMSbYXiCstnssIdxAajbGST8lpI.jpg"},"budget":10000000,"genres":[{"id":12,"name":"Adventure"},{"id":16,"name":"Animation"},{"id":35,"name":"Comedy"},{"id":10751,"name":"Family"},{"id":878,"name":"Science Fiction"}],"homepage":"https://www.warnerbros.com/lego-dc-super-heroes-flash","id":504997,"imdb_id":"tt7877382","origin_country":["US"],"original_language":"en","original_title":"LEGO DC Comics Super Heroes: The Flash","overview":"Reverse-Flash manipulates the Speed Force to put the Flash into a time loop that forces him to relive the same day over and over again—with progressively disastrous results, including losing his powers and being fired by the Justice League. The Flash must find a way to restore time to its original path and finally apprehend his worst enemy before all is lost for the Flash…and the world!","popularity":1.3876,"poster_path":"/zxz7Qo3GhiHkkFl26tWJ3uIwXiJ.jpg","production_companies":[{"id":2785,"logo_path":"/l5zW8jjmQOCx2dFmvnmbYmqoBmL.png","name":"Warner Bros. Animation","origin_country":"US"},{"id":9993,"logo_path":"/2Tc1P3Ac8M479naPp1kYT3izLS5.png","name":"DC Entertainment","origin_country":"US"},{"id":4081,"logo_path":"/9Q0SyrhQD61wWbz5KJOkL6tu2mg.png","name":"LEGO","origin_country":"DK"}],"production_countries":[{"iso_3166_1":"US","name":"United States of America"}],"release_date":"2018-02-13","revenue":0,"runtime":78,"spoken_languages":[{"english_name":"English","iso_639_1":"en","name":"English"}],"status":"Released","tagline":"Fastest Minifigure Alive","title":"LEGO DC Comics Super Heroes: The Flash","video":false,"vote_average":6.796,"vote_count":218}
\ No newline at end of file
diff --git a/src/source/__fixtures__/Soaper/https:soaper.livesearch.htmlkeywordLEGOpercent20DCpercent20Comicspercent20Superpercent20Heroespercent3Apercent20Thepercent20Flash b/src/source/__fixtures__/Soaper/https:soaper.livesearch.htmlkeywordLEGOpercent20DCpercent20Comicspercent20Superpercent20Heroespercent3Apercent20Thepercent20Flash
new file mode 100644
index 0000000..0df1ad9
--- /dev/null
+++ b/src/source/__fixtures__/Soaper/https:soaper.livesearch.htmlkeywordLEGOpercent20DCpercent20Comicspercent20Superpercent20Heroespercent3Apercent20Thepercent20Flash
@@ -0,0 +1,789 @@
+
+