Skip to content

Commit 58e128b

Browse files
committed
feat(graphql-api): Implement movies search in 1337x search adapter
1 parent ec147dd commit 58e128b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

apps/graphql-api/src/shared/search/adapters/1337x.search-adapter.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class OneThreeThreeSevenXSearchAdapater extends SearchAdapter {
3333
* Search for a episode
3434
*
3535
* @param episode
36-
* @param isRetry
3736
* @returns {Promise<*>}
3837
*/
3938
searchEpisode = async (episode: Episode) => {
@@ -67,12 +66,26 @@ export class OneThreeThreeSevenXSearchAdapater extends SearchAdapter {
6766
* Search for movies
6867
*
6968
* @param movie
70-
* @param isRetry
7169
* @returns {Promise<*>}
7270
*/
7371
searchMovie = async (movie: Movie) => {
7472
try {
75-
// TODO
73+
const { torrents, domain } = await search({
74+
query: movie.title,
75+
category: 'Movies'
76+
})
77+
78+
// Get all the torrents from trusted uploaders
79+
const foundTorrents = torrents.filter((torrent) =>
80+
this.trustedUploaders.includes(torrent.uploader)
81+
)
82+
83+
const results = await Promise.all(
84+
foundTorrents.map((torrent) => this.formatTorrent(torrent, domain))
85+
)
86+
87+
return results.filter(Boolean)
88+
7689
} catch (e) {
7790
this.logger.error('Error searching for movie!', e)
7891
}

0 commit comments

Comments
 (0)