Skip to content

Commit

Permalink
Make upload only titles works with PTP
Browse files Browse the repository at this point in the history
  • Loading branch information
Morea committed Sep 24, 2023
1 parent 5aa73b4 commit 6755301
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Find Unique Titles/dist/find.unique.titles.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Find Unique Titles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion Find Unique Titles/src/trackers/PTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class PTP implements tracker {
return "PTP";
}

async canUpload(request: Request): Promise<boolean> {
async canUpload(request: Request, onlyNew: boolean): Promise<boolean> {
if (request.category && request.category !== Category.MOVIE) return false;
if (!request.imdbId) return true;
const query_url =
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Find Unique Titles/src/trackers/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface Response {
export interface tracker {
canRun(url: string): boolean;

canUpload(request: Request): Promise<boolean>;
canUpload(request: Request, onlyNewTitle: boolean): Promise<boolean>;

canBeUsedAsSource(): boolean;

Expand Down

0 comments on commit 6755301

Please sign in to comment.