Skip to content

Commit a36efa3

Browse files
committed
feat(graphql-api): Update every 0,5 seconds
1 parent 5266623 commit a36efa3

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export class OneThreeThreeSevenXSearchAdapater extends SearchAdapter {
2323
'SeekNDstroy',
2424
'Cristie',
2525
'mazemaze16',
26-
'TeamRocker'
26+
'TeamRocker',
27+
'YIFY',
28+
'PMEDIA',
29+
'bone111',
30+
'Silmarillion'
2731
]
2832
/**
2933
* Search for a episode
@@ -39,13 +43,13 @@ export class OneThreeThreeSevenXSearchAdapater extends SearchAdapter {
3943
category: 'TV'
4044
})
4145

46+
// Get all the torrents from trusted uploaders and validate if the
47+
// season and episode format is in the torrent
4248
const foundTorrents = torrents.filter((torrent) =>
4349
this.trustedUploaders.includes(torrent.uploader) &&
4450
torrent.title.toUpperCase().includes(this.buildSeasonEpisodeString(episode).toUpperCase())
4551
)
4652

47-
console.log(torrents)
48-
4953
const results = await Promise.all(
5054
foundTorrents.map((torrent) => this.formatTorrent(torrent, domain))
5155
)

apps/graphql-api/src/shared/torrent/torrent.service.ts

+5-13
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,7 @@ export class TorrentService {
365365
this.removeFromTorrents(download, true)
366366

367367
let searchedSubs = false
368-
let lastUpdate = {
369-
progress: null,
370-
numPeers: null
371-
}
368+
let lastUpdate = null
372369

373370
// Keep track if we updated the episode of movie with the new status
374371
let updatedItem = false
@@ -429,17 +426,12 @@ export class TorrentService {
429426
this.subtitlesService.searchForSubtitles(download, file)
430427
}
431428

432-
// Only update every 0.5 %
433-
if (lastUpdate.progress === null
434-
|| (lastUpdate.progress + 0.5) < newProgress
435-
|| lastUpdate.numPeers !== torrent.numPeers
436-
) {
429+
const now = Date.now()
430+
// Only update 0,5 seconds
431+
if (lastUpdate === null || (lastUpdate + 5000) < now) {
437432
this.logger.debug(`[${download._id}]: Progress ${newProgress.toFixed(1)}% at ${formatKbToString(torrent.downloadSpeed)}`)
438433

439-
lastUpdate = {
440-
progress: newProgress,
441-
numPeers: torrent.numPeers
442-
}
434+
lastUpdate = now
443435

444436
// Don't update if we are already updating
445437
if (!updatingModel) {

0 commit comments

Comments
 (0)