From 6755301cc0c65a5c2f615d8a970da4c293dbf390 Mon Sep 17 00:00:00 2001 From: Morea Date: Sun, 24 Sep 2023 20:03:34 +0200 Subject: [PATCH] Make upload only titles works with PTP --- Find Unique Titles/dist/find.unique.titles.user.js | 7 +++++-- Find Unique Titles/src/index.ts | 2 +- Find Unique Titles/src/trackers/PTP.ts | 5 ++++- Find Unique Titles/src/trackers/tracker.ts | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Find Unique Titles/dist/find.unique.titles.user.js b/Find Unique Titles/dist/find.unique.titles.user.js index d8987e7..ffeed6a 100644 --- a/Find Unique Titles/dist/find.unique.titles.user.js +++ b/Find Unique Titles/dist/find.unique.titles.user.js @@ -128,7 +128,7 @@ var main = /*#__PURE__*/function () { request.dom.style.display = "none"; continue; } - var response = yield targetTracker.canUpload(request); + var response = yield targetTracker.canUpload(request, only_show_unique_titles); if (!response) { if (request.imdbId) { yield (0,_utils_cache__WEBPACK_IMPORTED_MODULE_1__.addToCache)(targetTracker.name(), request.imdbId); @@ -1365,7 +1365,7 @@ class PTP { name() { return "PTP"; } - canUpload(request) { + canUpload(request, onlyNew) { return _asyncToGenerator(function* () { if (request.category && request.category !== _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.MOVIE) return false; if (!request.imdbId) return true; @@ -1376,6 +1376,9 @@ class PTP { return true; } var torrents = parseAvailableTorrents(result); + if (onlyNew) { + return torrents.length === 0; + } for (var torrent of request.torrents) { if (canUploadTorrent(torrent, torrents)) { torrent.dom.style.border = "2px solid red"; diff --git a/Find Unique Titles/src/index.ts b/Find Unique Titles/src/index.ts index 2d29080..62aa916 100644 --- a/Find Unique Titles/src/index.ts +++ b/Find Unique Titles/src/index.ts @@ -84,7 +84,7 @@ const main = async function () { request.dom.style.display = "none"; continue; } - const response = await targetTracker.canUpload(request); + const response = await targetTracker.canUpload(request, only_show_unique_titles); if (!response) { if (request.imdbId) { await addToCache(targetTracker.name(), request.imdbId); diff --git a/Find Unique Titles/src/trackers/PTP.ts b/Find Unique Titles/src/trackers/PTP.ts index 472bd78..f814eec 100644 --- a/Find Unique Titles/src/trackers/PTP.ts +++ b/Find Unique Titles/src/trackers/PTP.ts @@ -23,7 +23,7 @@ export default class PTP implements tracker { return "PTP"; } - async canUpload(request: Request): Promise { + async canUpload(request: Request, onlyNew: boolean): Promise { if (request.category && request.category !== Category.MOVIE) return false; if (!request.imdbId) return true; const query_url = @@ -34,6 +34,9 @@ export default class PTP implements tracker { return true; } const torrents = parseAvailableTorrents(result); + if (onlyNew) { + return torrents.length === 0; + } for (let torrent of request.torrents) { if (canUploadTorrent(torrent, torrents)) { torrent.dom.style.border = "2px solid red"; diff --git a/Find Unique Titles/src/trackers/tracker.ts b/Find Unique Titles/src/trackers/tracker.ts index d7ecd38..1f60e02 100644 --- a/Find Unique Titles/src/trackers/tracker.ts +++ b/Find Unique Titles/src/trackers/tracker.ts @@ -34,7 +34,7 @@ export interface Response { export interface tracker { canRun(url: string): boolean; - canUpload(request: Request): Promise; + canUpload(request: Request, onlyNewTitle: boolean): Promise; canBeUsedAsSource(): boolean;