diff --git a/Find Unique Titles/dist/find.unique.titles.user.js b/Find Unique Titles/dist/find.unique.titles.user.js
index ba229c3..2e2c769 100644
--- a/Find Unique Titles/dist/find.unique.titles.user.js
+++ b/Find Unique Titles/dist/find.unique.titles.user.js
@@ -52,10 +52,11 @@
__webpack_require__.a(module, (async (__webpack_handle_async_dependencies__, __webpack_async_result__) => {
try {
var _trackers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/trackers/index.ts");
+ var _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/trackers/tracker.ts");
var _utils_cache__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/utils/cache.ts");
var _utils_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/dom.ts");
var _settings__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/settings.ts");
- var common_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_dom__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("../common/dist/dom/index.mjs");
var common_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../common/dist/logger/index.mjs");
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([ _trackers__WEBPACK_IMPORTED_MODULE_2__, _utils_cache__WEBPACK_IMPORTED_MODULE_4__ ]);
[_trackers__WEBPACK_IMPORTED_MODULE_2__, _utils_cache__WEBPACK_IMPORTED_MODULE_4__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__;
@@ -98,14 +99,33 @@
(0, _utils_dom__WEBPACK_IMPORTED_MODULE_3__.updateCount)(i++);
continue;
}
- const response = await targetTracker.canUpload(request, settings.onlyNewTitles);
+ const response = await targetTracker.search(request);
(0, _utils_dom__WEBPACK_IMPORTED_MODULE_3__.updateCount)(i++);
- if (!response) {
+ if (response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.EXIST || response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.NOT_ALLOWED) {
if (request.imdbId) await (0, _utils_cache__WEBPACK_IMPORTED_MODULE_4__.addToCache)(targetTracker.name(), request.imdbId);
hideTorrents(request);
+ } else if (response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.NOT_LOGGED_IN) {
+ alert(`You are not logged in ${targetTracker.name()}`);
+ break;
} else {
newContent++;
(0, _utils_dom__WEBPACK_IMPORTED_MODULE_3__.updateNewContent)(newContent);
+ if (response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.MAYBE_NOT_EXIST) {
+ request.dom[0].setAttribute("title", "Title may not exist on target tracker");
+ request.dom[0].style.border = "2px solid #9b59b6";
+ } else if (response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.NOT_EXIST_WITH_REQUEST) {
+ request.dom[0].setAttribute("title", "Title was not found and has matching requests");
+ request.dom[0].style.border = "2px solid #2ecc71";
+ } else if (response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.MAYBE_NOT_EXIST_WITH_REQUEST) {
+ request.dom[0].setAttribute("title", "Title may not exists and there are matching requests");
+ request.dom[0].style.border = "2px solid #e67e22";
+ } else if (response == _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.NOT_CHECKED) {
+ request.dom[0].setAttribute("title", "Title was not checked on target tracker");
+ request.dom[0].style.border = "2px solid #e74c3c";
+ } else if (response != _trackers_tracker__WEBPACK_IMPORTED_MODULE_5__.SearchResult.NOT_EXIST) {
+ request.dom[0].setAttribute("title", "Title was not found on target tracker");
+ request.dom[0].style.border = "2px solid #3498db";
+ }
}
}
(0, _utils_cache__WEBPACK_IMPORTED_MODULE_4__.clearMemoryCache)();
@@ -113,9 +133,9 @@
}));
sourceTracker.insertTrackersSelect(select);
};
- (0, common_dom__WEBPACK_IMPORTED_MODULE_5__.appendErrorMessage)();
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_6__.appendErrorMessage)();
main().catch((e => {
- (0, common_dom__WEBPACK_IMPORTED_MODULE_5__.showError)(e.message);
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_6__.showError)(e.message);
}));
let currentUrl = document.location.href;
const observer = new MutationObserver((async () => {
@@ -199,8 +219,8 @@
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/utils.ts");
var _tracker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/trackers/tracker.ts");
- var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
class Aither {
canBeUsedAsSource() {
return true;
@@ -233,11 +253,11 @@
name() {
return "Aither";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = "https://aither.xyz/torrents?perPage=25&imdbId=" + request.imdbId + "&sortField=size";
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return result.textContent.includes("There is no result in database for query");
+ return result.textContent.includes("There is no result in database for query") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
const parent = document.querySelector(".panelV2 .panel__header");
@@ -285,11 +305,11 @@
name() {
return "AvistaZ";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = "https://avistaz.to/movies?search=&imdb=" + request.imdbId;
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return result.textContent?.includes("No Movie found!");
+ return result.textContent?.includes("No Movie found!") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector("#content-area > div.well.well-sm"), select);
@@ -392,11 +412,11 @@
name() {
return "BHD";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = "https://beyond-hd.me/library/movies?activity=&q=" + request.imdbId;
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return 0 === result.querySelectorAll(".bhd-meta-box").length;
+ return 0 === result.querySelectorAll(".bhd-meta-box").length ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
select.classList.add("beta-form-main");
@@ -411,8 +431,8 @@
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/utils.ts");
var _tracker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/trackers/tracker.ts");
- var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
class BLU {
canBeUsedAsSource() {
return true;
@@ -445,11 +465,11 @@
name() {
return "BLU";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = "https://blutopia.xyz/torrents?perPage=25&imdbId=" + request.imdbId + "&sortField=size";
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return null !== result.querySelector(".torrent-listings-no-result");
+ return null !== result.querySelector(".torrent-listings-no-result") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
select.classList.add("form__select");
@@ -509,8 +529,8 @@
name() {
return "BTarg";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_3__.insertAfter)(select, document.querySelector('select[name="inclfree"]'));
@@ -575,11 +595,11 @@
name() {
return "CG";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_CHECKED;
const queryUrl = "https://cinemageddon.net/browse.php?search=" + request.imdbId + "&orderby=size&dir=DESC";
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return result.textContent.includes("Nothing found!");
+ return result.textContent.includes("Nothing found!") ? _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector(".embedded > p"), select);
@@ -591,8 +611,9 @@
default: () => CHD
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/utils.ts");
+ var _tracker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/trackers/tracker.ts");
+ var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
var common_http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../common/dist/http/index.mjs");
- var common_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/dom/index.mjs");
class CHD {
canBeUsedAsSource() {
return true;
@@ -614,7 +635,7 @@
if (!link) continue;
let response = await (0, common_http__WEBPACK_IMPORTED_MODULE_0__.fetchAndParseHtml)(link.href);
const imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_1__.parseImdbIdFromLink)(response);
- const size = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_1__.parseSize)(element.querySelector(".rowfollow:nth-child(5)").innerText);
+ const size = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_1__.parseSize)(element.querySelector(".rowfollow:nth-child(5)").textContent);
console.log("size:", size);
const request = {
torrents: [ {
@@ -632,12 +653,12 @@
name() {
return "CHD";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_2__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const element = document.querySelector(".searchbox").children[2].querySelector("td td.rowfollow tr");
- (0, common_dom__WEBPACK_IMPORTED_MODULE_2__.addChild)(element, select);
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(element, select);
}
}
},
@@ -646,8 +667,9 @@
default: () => CLANSUD
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/utils.ts");
+ var _tracker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/trackers/tracker.ts");
+ var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
var common_http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../common/dist/http/index.mjs");
- var common_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/dom/index.mjs");
class CLANSUD {
canBeUsedAsSource() {
return true;
@@ -686,11 +708,11 @@
name() {
return "CLAN-SUD";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_2__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
- (0, common_dom__WEBPACK_IMPORTED_MODULE_2__.insertBefore)(select, document.querySelector('div[data-tableid="topics"]'));
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_3__.insertBefore)(select, document.querySelector('div[data-tableid="topics"]'));
}
}
},
@@ -700,8 +722,8 @@
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/utils.ts");
var _tracker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/trackers/tracker.ts");
- var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
class CinemaZ {
canBeUsedAsSource() {
return true;
@@ -729,11 +751,11 @@
name() {
return "CinemaZ";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = "https://cinemaz.to/movies?search=&imdb=" + request.imdbId;
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return result.textContent.includes("No Movie found!");
+ return result.textContent.includes("No Movie found!") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector("#content-area > div.well.well-sm"), select);
@@ -745,8 +767,9 @@
default: () => FL
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/utils.ts");
+ var _tracker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/trackers/tracker.ts");
+ var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
var common_http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../common/dist/http/index.mjs");
- var common_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/dom/index.mjs");
class FL {
canBeUsedAsSource() {
return true;
@@ -784,14 +807,14 @@
name() {
return "FL";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_2__.SearchResult.NOT_CHECKED;
const queryUrl = "https://filelist.io/browse.php?search=" + request.imdbId + "&cat=0&searchin=1&sort=3";
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_0__.fetchAndParseHtml)(queryUrl);
- return 0 === result.querySelectorAll(".torrentrow").length;
+ return 0 === result.querySelectorAll(".torrentrow").length ? _tracker__WEBPACK_IMPORTED_MODULE_2__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_2__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
- (0, common_dom__WEBPACK_IMPORTED_MODULE_2__.addChild)(document.querySelector("form p"), select);
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector("form p"), select);
}
}
},
@@ -852,11 +875,11 @@
name() {
return "GPW";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = `https://greatposterwall.com/torrents.php?groupname=${request.imdbId}`;
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return null !== result.querySelector(".torrent-listings-no-result");
+ return null !== result.querySelector(".torrent-listings-no-result") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
select.classList.add("Input");
@@ -944,11 +967,11 @@
name() {
return "HDB";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = "https://hdbits.org/browse.php?c3=1&c1=1&c2=1&tagsearchtype=or&imdb=" + request.imdbId + "&sort=size&h=8&d=DESC";
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return result.querySelector("#resultsarea").textContent.includes("Nothing here!");
+ return result.querySelector("#resultsarea").textContent.includes("Nothing here!") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
document.querySelector("#moresearch3 > td:nth-child(2)").innerHTML += "
Find unique for:
";
@@ -996,8 +1019,8 @@
name() {
return "HDSky";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const element = document.querySelector(".searchbox").children[2].querySelector("td td.rowfollow tr");
@@ -1045,8 +1068,8 @@
name() {
return "HDT";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const element = document.querySelectorAll(".mainblockcontentsearch tr")[2];
@@ -1088,8 +1111,8 @@
name() {
return "IPT";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const element = document.createElement("p");
@@ -1104,8 +1127,8 @@
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/utils.ts");
var _tracker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/trackers/tracker.ts");
- var common_http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../common/dist/http/index.mjs");
var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../common/dist/http/index.mjs");
class JPTV {
canBeUsedAsSource() {
return true;
@@ -1140,8 +1163,8 @@
name() {
return "JPTV";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_2__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector(".form-torrent-search"), select);
@@ -1226,13 +1249,14 @@
name() {
return "KG";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_CHECKED;
const result = await (0, common_searcher__WEBPACK_IMPORTED_MODULE_3__.search)(common_trackers__WEBPACK_IMPORTED_MODULE_4__.KG, {
movie_title: "",
movie_imdb_id: request.imdbId
});
- return result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND;
+ if (result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.LOGGED_OUT) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_LOGGED_IN;
+ return result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND ? _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_5__.insertBefore)(select, document.getElementById("showdead"));
@@ -1319,15 +1343,15 @@
name() {
return "MTV";
}
- async canUpload(request) {
- let result = common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND;
+ async search(request) {
+ let result;
if (request.category == _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.MOVIE) result = await (0,
common_searcher__WEBPACK_IMPORTED_MODULE_3__.search)(common_trackers__WEBPACK_IMPORTED_MODULE_4__.MTV, {
movie_title: request.title
}); else result = await (0, common_searcher__WEBPACK_IMPORTED_MODULE_3__.search)(common_trackers__WEBPACK_IMPORTED_MODULE_4__.MTV_TV, {
movie_title: request.title
});
- return result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND;
+ return result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND ? _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
const wrapper = document.createElement("tr");
@@ -1382,8 +1406,8 @@
name() {
return "M-Team";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const element = document.querySelector(".searchbox").children[2].querySelector("td td.rowfollow tr");
@@ -1425,8 +1449,8 @@
name() {
return "NewInsane";
}
- async canUpload(request) {
- return !request.imdbId;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
(0, common_dom__WEBPACK_IMPORTED_MODULE_2__.addChild)(document.querySelector(".searchbuttons.actiontitle"), select);
@@ -1475,6 +1499,7 @@
if (!categoryTitle) return null;
if (categoryTitle.includes("Stand-up Comedy ")) return _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.STAND_UP; else if (categoryTitle.includes("Live Performance ")) return _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.LIVE_PERFORMANCE; else return _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.MOVIE;
};
+ const hasRequests = element => element.querySelector("#no_results_message").textContent.trim().includes("Your search did not match any torrents, however it did match these requests.");
class PTP {
canBeUsedAsSource() {
return true;
@@ -1505,37 +1530,35 @@
name() {
return "PTP";
}
- async canUpload(request, onlyNew) {
- if (!isSupportedCategory(request.category)) return false;
+ async search(request) {
+ if (!isSupportedCategory(request.category)) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_ALLOWED;
let torrents = [];
+ let result;
if (!request.imdbId) {
common_logger__WEBPACK_IMPORTED_MODULE_3__.logger.debug("NO IMDB ID was provided");
if (request.title && request.year) {
common_logger__WEBPACK_IMPORTED_MODULE_3__.logger.debug("Searching by title and year: {0} - {1}", request.title, request.year);
const query_url = `https://passthepopcorn.me/torrents.php?action=advanced&searchstr=${encodeURIComponent(request.title)}&year=${request.year}`;
- const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_4__.fetchAndParseHtml)(query_url);
+ result = await (0, common_http__WEBPACK_IMPORTED_MODULE_4__.fetchAndParseHtml)(query_url);
torrents = parseAvailableTorrents(result);
}
} else {
torrents = (0, _utils_cache__WEBPACK_IMPORTED_MODULE_5__.getFromMemoryCache)(request.imdbId);
if (!torrents) {
const query_url = "https://passthepopcorn.me/torrents.php?imdb=" + request.imdbId;
- const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_4__.fetchAndParseHtml)(query_url);
+ result = await (0, common_http__WEBPACK_IMPORTED_MODULE_4__.fetchAndParseHtml)(query_url);
torrents = parseAvailableTorrents(result);
(0, _utils_cache__WEBPACK_IMPORTED_MODULE_5__.addToMemoryCache)(request.imdbId, torrents);
}
}
let notFound = !torrents.length;
- if (notFound) return true;
- if (onlyNew) {
- common_logger__WEBPACK_IMPORTED_MODULE_3__.logger.debug("Title already exists and only new titles is enabled");
- return false;
+ if (notFound) {
+ if (hasRequests(result)) if (request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_EXIST_WITH_REQUEST; else return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.MAYBE_NOT_EXIST_WITH_REQUEST;
+ if (request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_EXIST; else return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.MAYBE_NOT_EXIST;
}
- for (let torrent of request.torrents) if (canUploadTorrent(torrent, torrents)) {
- torrent.dom.style.border = "2px solid red";
- notFound = true;
- } else torrent.dom.style.display = "none";
- return notFound;
+ let searchResult = _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.EXIST;
+ for (let torrent of request.torrents) if (searchTorrent(torrent, torrents)) searchResult = _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.EXIST_BUT_MISSING_SLOT; else torrent.dom.style.display = "none";
+ return searchResult;
}
insertTrackersSelect(select) {
let element = document.querySelector(".search-form__footer__buttons");
@@ -1578,7 +1601,7 @@
if ("SD" === first.resolution) return isSD(second.resolution);
if ("SD" === second.resolution) return isSD(first.resolution);
}
- const canUploadTorrent = (torrent, availableTorrents) => {
+ const searchTorrent = (torrent, availableTorrents) => {
const similarTorrents = availableTorrents.filter((e => sameResolution(torrent, e) && (void 0 === torrent.container || sameContainer(e.container, torrent.container)) && (!torrent.tags.includes("Remux") || e.tags.includes("Remux"))));
if (0 == similarTorrents.length && torrent.resolution && torrent.container) return true;
if (1 == similarTorrents.length) if (torrent.size > 1.5 * similarTorrents[0].size || similarTorrents[0].size > 1.5 * torrent.size) return true;
@@ -1698,11 +1721,11 @@
name() {
return "Pter";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = `https://pterclub.com/torrents.php?search=${request.imdbId}`;
const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return null === result.querySelector("#torrenttable");
+ return null === result.querySelector("#torrenttable") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
const targetLine = document.querySelector(".searchbox > tbody:last-child table tr");
@@ -1719,8 +1742,9 @@
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/utils.ts");
var _tracker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/trackers/tracker.ts");
- var common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/http/index.mjs");
- var common_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var common_http__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/http/index.mjs");
+ var common_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/logger/index.mjs");
function parseTorrent(element) {
let infos = element.querySelector(".torrent_info .activity_info").querySelectorAll("div");
let size = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseSize)(infos[1].textContent);
@@ -1734,7 +1758,7 @@
return {
size,
tags: [],
- dom: [ element ],
+ dom: element,
resolution,
format
};
@@ -1743,10 +1767,17 @@
let category = _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.MOVIE;
let infos = element.querySelector(".torrent_info .activity_info").querySelectorAll("div");
let info = infos[0].textContent;
- if ("CD" == info || "WEB" === info) category = _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.MUSIC; else if ((0,
- _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseSize)(infos[0].textContent)) category = _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.BOOK;
+ if ("CD" == info || "WEB" === info) category = _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.MUSIC; else if (element.querySelector(".torrent_tags").textContent.includes("ebook")) category = _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.BOOK;
return category;
}
+ const parseYearTitle = element => {
+ const title = element.querySelector(".torrent_title b").textContent;
+ const year = parseInt(element.querySelector(".torrent_year").textContent.split("|")[0].trim(), 10);
+ return {
+ title,
+ year
+ };
+ };
class SC {
canBeUsedAsSource() {
return true;
@@ -1758,34 +1789,38 @@
return url.includes("secret-cinema.pw") && !url.includes("torrents.php?id");
}
async* getSearchRequest() {
- const requests = [];
- document.querySelectorAll(".torrent_card").forEach((element => {
- let dom = element;
+ common_logger__WEBPACK_IMPORTED_MODULE_2__.logger.debug("[{0}] Parsing titles to check", this.name());
+ const elements = Array.from(document.querySelectorAll(".torrent_card")).filter((element => null != element.querySelector(".torrent_tags")));
+ yield {
+ total: elements.length
+ };
+ for (let element of elements) {
let links_container = element.querySelector(".torrent_tags");
- if (null === links_container) return;
- let imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseImdbIdFromLink)(links_container);
+ const imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseImdbIdFromLink)(links_container);
+ const {title, year} = parseYearTitle(element);
const request = {
torrents: [ parseTorrent(element) ],
- dom: [ dom ],
+ dom: [ element ],
imdbId,
- title: "",
+ title,
+ year,
category: parseCategory(element)
};
- requests.push(request);
- }));
- yield* (0, _tracker__WEBPACK_IMPORTED_MODULE_1__.toGenerator)(requests);
+ common_logger__WEBPACK_IMPORTED_MODULE_2__.logger.debug("[{0}] Search request: {1}", this.name(), request);
+ yield request;
+ }
}
name() {
return "SC";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const queryUrl = `https://secret-cinema.pw/torrents.php?action=advanced&searchsubmit=1&cataloguenumber=${request.imdbId}&order_by=time&order_way=desc&tags_type=0`;
- const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_2__.fetchAndParseHtml)(queryUrl);
- return null === result.querySelector(".torrent_card_container");
+ const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_3__.fetchAndParseHtml)(queryUrl);
+ return null === result.querySelector(".torrent_card_container") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
- (0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector("#ft_container p"), select);
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_4__.addChild)(document.querySelector("#ft_container p"), select);
}
}
},
@@ -1828,8 +1863,8 @@
name() {
return "TL";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
select.style.margin = "20px 0";
@@ -1905,13 +1940,14 @@
name() {
return "TSeeds";
}
- async canUpload(request) {
- if (!request.imdbId) return true;
+ async search(request) {
+ if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_CHECKED;
const result = await (0, common_searcher__WEBPACK_IMPORTED_MODULE_3__.search)(common_trackers__WEBPACK_IMPORTED_MODULE_4__.TSeeds, {
movie_title: "",
movie_imdb_id: request.imdbId
});
- return result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND;
+ if (result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.LOGGED_OUT) return _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_LOGGED_IN;
+ return result == common_searcher__WEBPACK_IMPORTED_MODULE_3__.SearchResult.NOT_FOUND ? _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_0__.SearchResult.EXIST;
}
insertTrackersSelect(select) {
if (isCategoryPage()) (0, common_dom__WEBPACK_IMPORTED_MODULE_5__.addChild)(document.querySelector(".table-responsive.cat-torrents .text-center"), select); else {
@@ -1929,7 +1965,8 @@
default: () => TiK
});
var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/utils.ts");
- var common_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../common/dist/dom/index.mjs");
+ var _tracker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/trackers/tracker.ts");
+ var common_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/dom/index.mjs");
const findTorrentsTable = () => {
let tables = document.querySelectorAll("table");
for (let table of tables) {
@@ -1985,14 +2022,14 @@
name() {
return "TiK";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const stateSelect = document.getElementById("incldead");
const td = document.createElement("td");
td.appendChild(select);
- (0, common_dom__WEBPACK_IMPORTED_MODULE_1__.insertBefore)(td, stateSelect.parentElement);
+ (0, common_dom__WEBPACK_IMPORTED_MODULE_2__.insertBefore)(td, stateSelect.parentElement);
}
}
},
@@ -2103,8 +2140,8 @@
name() {
return "nCore";
}
- async canUpload(request) {
- return false;
+ async search(request) {
+ return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select) {
const element = document.querySelector("#keresoresz tr");
@@ -2115,6 +2152,7 @@
"./src/trackers/tracker.ts": (__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.d(__webpack_exports__, {
Category: () => Category,
+ SearchResult: () => SearchResult,
toGenerator: () => toGenerator
});
let Category = function(Category) {
@@ -2134,6 +2172,18 @@
Category[Category.OTHER = 13] = "OTHER";
return Category;
}({});
+ let SearchResult = function(SearchResult) {
+ SearchResult[SearchResult.EXIST = 0] = "EXIST";
+ SearchResult[SearchResult.EXIST_BUT_MISSING_SLOT = 1] = "EXIST_BUT_MISSING_SLOT";
+ SearchResult[SearchResult.NOT_EXIST = 2] = "NOT_EXIST";
+ SearchResult[SearchResult.MAYBE_NOT_EXIST = 3] = "MAYBE_NOT_EXIST";
+ SearchResult[SearchResult.NOT_EXIST_WITH_REQUEST = 4] = "NOT_EXIST_WITH_REQUEST";
+ SearchResult[SearchResult.MAYBE_NOT_EXIST_WITH_REQUEST = 5] = "MAYBE_NOT_EXIST_WITH_REQUEST";
+ SearchResult[SearchResult.NOT_CHECKED = 6] = "NOT_CHECKED";
+ SearchResult[SearchResult.NOT_LOGGED_IN = 7] = "NOT_LOGGED_IN";
+ SearchResult[SearchResult.NOT_ALLOWED = 8] = "NOT_ALLOWED";
+ return SearchResult;
+ }({});
const toGenerator = async function*(requests) {
yield {
total: requests.length
@@ -2360,10 +2410,10 @@
logger.prefix = prefix;
},
info: (message, ...args) => {
- if (logger.level <= LEVEL.INFO) console.log(formatMessage(logger.level, message, args));
+ if (logger.level <= LEVEL.INFO) console.log(formatMessage(LEVEL.INFO, message, args));
},
debug: (message, ...args) => {
- if (logger.level <= LEVEL.DEBUG) console.log(formatMessage(logger.level, message, args));
+ if (logger.level <= LEVEL.DEBUG) console.log(formatMessage(LEVEL.DEBUG, message, args));
}
};
const formatMessage = (level, message, args) => {
diff --git a/Find Unique Titles/package.json b/Find Unique Titles/package.json
index 7f005d1..fa54055 100644
--- a/Find Unique Titles/package.json
+++ b/Find Unique Titles/package.json
@@ -1,7 +1,7 @@
{
"name": "find.unique.titles",
"description": "Find unique titles to cross seed",
- "version": "0.0.6",
+ "version": "0.0.7",
"author": {
"name": "Mea01"
},
diff --git a/Find Unique Titles/readme.md b/Find Unique Titles/readme.md
index a72d0e7..5c0e3b9 100644
--- a/Find Unique Titles/readme.md
+++ b/Find Unique Titles/readme.md
@@ -7,7 +7,8 @@ You can generate it by running run `npm run dev`.
# Changelog
## 2023-12
- Add support for MTV
-- Add support for using title and year when IMDB ID is not available. It only works with MTV and PTP right now
+- Add support for using title and year when IMDB ID is not available when checking titles on PTP.
+- The script now highlight the reason why a title can be uploaded
## 2023-11
- Some work is done to use IMDB Scout code for searching
- Add support for TSeeds
diff --git a/Find Unique Titles/src/index.ts b/Find Unique Titles/src/index.ts
index 299366f..1394755 100644
--- a/Find Unique Titles/src/index.ts
+++ b/Find Unique Titles/src/index.ts
@@ -1,6 +1,6 @@
import * as trackers from "./trackers";
-import { tracker, Request, MetaData } from "./trackers/tracker";
-import { existsInCache, addToCache, clearMemoryCache } from "./utils/cache";
+import { MetaData, Request, SearchResult, tracker } from "./trackers/tracker";
+import { addToCache, clearMemoryCache, existsInCache } from "./utils/cache";
import {
addCounter,
createTrackersSelect,
@@ -11,7 +11,7 @@ import {
import "./settings";
import { getSettings } from "./settings";
import { appendErrorMessage, showError } from "common/dom";
-import { logger, LEVEL } from "common/logger"
+import { LEVEL, logger } from "common/logger";
function hideTorrents(request: Request) {
for (let element of request.dom) {
@@ -23,18 +23,18 @@ function hideTorrents(request: Request) {
}
const setUpLogger = (debugMode: boolean) => {
- logger.setPrefix("[Find Unique Titles]")
- if (debugMode){
- logger.setLevel(LEVEL.DEBUG)
+ logger.setPrefix("[Find Unique Titles]");
+ if (debugMode) {
+ logger.setLevel(LEVEL.DEBUG);
}
-}
+};
const main = async function () {
"use strict";
const settings = getSettings();
- setUpLogger(settings.debug)
+ setUpLogger(settings.debug);
logger.info("Init User script");
@@ -78,19 +78,53 @@ const main = async function () {
updateCount(i++);
continue;
}
- const response = await targetTracker.canUpload(
- request,
- settings.onlyNewTitles
- );
+ const response = await targetTracker.search(request);
updateCount(i++);
- if (!response) {
+ if (
+ response == SearchResult.EXIST ||
+ response == SearchResult.NOT_ALLOWED
+ ) {
if (request.imdbId) {
await addToCache(targetTracker.name(), request.imdbId);
}
hideTorrents(request);
+ } else if (response == SearchResult.NOT_LOGGED_IN) {
+ alert(`You are not logged in ${targetTracker.name()}`);
+ break;
} else {
newContent++;
updateNewContent(newContent);
+ if (response == SearchResult.MAYBE_NOT_EXIST) {
+ request.dom[0].setAttribute(
+ "title",
+ "Title may not exist on target tracker"
+ );
+ request.dom[0].style.border = "2px solid #9b59b6";
+ } else if (response == SearchResult.NOT_EXIST_WITH_REQUEST) {
+ request.dom[0].setAttribute(
+ "title",
+ "Title was not found and has matching requests"
+ );
+ request.dom[0].style.border = "2px solid #2ecc71";
+ } else if (response == SearchResult.MAYBE_NOT_EXIST_WITH_REQUEST) {
+ request.dom[0].setAttribute(
+ "title",
+ "Title may not exists and there are matching requests"
+ );
+ request.dom[0].style.border = "2px solid #e67e22";
+ } else if (response == SearchResult.NOT_CHECKED) {
+ request.dom[0].setAttribute(
+ "title",
+ "Title was not checked on target tracker"
+ );
+ request.dom[0].style.border = "2px solid #e74c3c";
+ } else if (response != SearchResult.NOT_EXIST) {
+ request.dom[0].setAttribute(
+ "title",
+ "Title was not found on target tracker"
+ );
+ request.dom[0].style.border = "2px solid #3498db";
+ }
}
}
clearMemoryCache();
@@ -99,7 +133,6 @@ const main = async function () {
(sourceTracker as tracker).insertTrackersSelect(select);
};
-
appendErrorMessage();
main().catch((e) => {
showError(e.message);
diff --git a/Find Unique Titles/src/trackers/Aither.ts b/Find Unique Titles/src/trackers/Aither.ts
index 321813e..8c7bfb4 100644
--- a/Find Unique Titles/src/trackers/Aither.ts
+++ b/Find Unique Titles/src/trackers/Aither.ts
@@ -1,7 +1,8 @@
import { parseSize } from "../utils/utils";
-import { MetaData, Request, toGenerator, tracker } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import { MetaData, Request, SearchResult, toGenerator, tracker } from "./tracker";
import { addChild, insertAfter } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
+
export default class Aither implements tracker {
canBeUsedAsSource(): boolean {
@@ -46,8 +47,8 @@ export default class Aither implements tracker {
return "Aither";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl =
"https://aither.xyz/torrents?perPage=25&imdbId=" +
request.imdbId +
@@ -57,7 +58,9 @@ export default class Aither implements tracker {
return result.textContent.includes(
"There is no result in database for query"
- );
+ )
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -69,4 +72,4 @@ export default class Aither implements tracker {
addChild(div, select);
insertAfter(div, parent.querySelector("h2"));
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/AvistaZ.ts b/Find Unique Titles/src/trackers/AvistaZ.ts
index 78ee0cc..b1c6d1a 100644
--- a/Find Unique Titles/src/trackers/AvistaZ.ts
+++ b/Find Unique Titles/src/trackers/AvistaZ.ts
@@ -1,5 +1,5 @@
import { parseImdbIdFromLink } from "../utils/utils";
-import { tracker, Request, MetaData, toGenerator } from "./tracker";
+import { tracker, Request, MetaData, toGenerator, SearchResult } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
@@ -39,13 +39,15 @@ export default class AvistaZ implements tracker {
return "AvistaZ";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request) : Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl = "https://avistaz.to/movies?search=&imdb=" + request.imdbId;
const result = await fetchAndParseHtml(queryUrl);
- return result.textContent?.includes("No Movie found!");
+ return result.textContent?.includes("No Movie found!")
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/BHD.ts b/Find Unique Titles/src/trackers/BHD.ts
index 849c726..2706ceb 100644
--- a/Find Unique Titles/src/trackers/BHD.ts
+++ b/Find Unique Titles/src/trackers/BHD.ts
@@ -1,71 +1,87 @@
-import { parseImdbIdFromLink, parseResolution, parseSize } from "../utils/utils";
-import { Category, MetaData, Request, toGenerator, Torrent, tracker } from "./tracker";
+import {
+ parseImdbIdFromLink,
+ parseResolution,
+ parseSize,
+} from "../utils/utils";
+import {
+ Category,
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ Torrent,
+ tracker,
+} from "./tracker";
import { insertBefore } from "common/dom";
import { fetchAndParseHtml } from "common/http";
const parseTorrents = (element: HTMLElement): Array => {
const torrents: Torrent[] = [];
- element.querySelectorAll('tr[id^="resulttorrent"]').forEach((torrentElement) => {
- const data = torrentElement.children[0].textContent.trim().split("/");
- const size = parseSize(torrentElement.children[4].textContent.trim());
- const tags = [];
- if (torrentElement.textContent.includes("Remux")) {
- tags.push("Remux");
- }
- const torrent: Torrent = {
- container: data[0].trim(),
- format: data[1].trim(),
- resolution: data[3].trim(),
- tags: tags,
- size,
- dom: torrentElement as HTMLElement,
- };
- torrents.push(torrent);
- });
+ element
+ .querySelectorAll('tr[id^="resulttorrent"]')
+ .forEach((torrentElement) => {
+ const data = torrentElement.children[0].textContent.trim().split("/");
+ const size = parseSize(torrentElement.children[4].textContent.trim());
+ const tags = [];
+ if (torrentElement.textContent.includes("Remux")) {
+ tags.push("Remux");
+ }
+ const torrent: Torrent = {
+ container: data[0].trim(),
+ format: data[1].trim(),
+ resolution: data[3].trim(),
+ tags: tags,
+ size,
+ dom: torrentElement as HTMLElement,
+ };
+ torrents.push(torrent);
+ });
return torrents;
};
const parseCategory = (element: Element) => {
- const html = element.children[0].innerHTML
- if (html.includes("categories/tv")) return Category.TV
- else if (html.includes("categories/movies")) return Category.MOVIE
+ const html = element.children[0].innerHTML;
+ if (html.includes("categories/tv")) return Category.TV;
+ else if (html.includes("categories/movies")) return Category.MOVIE;
return undefined;
-}
+};
const parseTorrentsFromTorrentsPage = (): Array => {
const requests = [];
- document.querySelectorAll('tr[id^="torrentposter"]').forEach((element: HTMLElement) => {
- let imdbId = null;
- let libraryId = element.getAttribute("library");
- if (libraryId) {
- let imdbElement = document.querySelector(`#librarydiv${libraryId}`);
- if (imdbElement) {
- imdbId = parseImdbIdFromLink(imdbElement as HTMLElement)
+ document
+ .querySelectorAll('tr[id^="torrentposter"]')
+ .forEach((element: HTMLElement) => {
+ let imdbId = null;
+ let libraryId = element.getAttribute("library");
+ if (libraryId) {
+ let imdbElement = document.querySelector(`#librarydiv${libraryId}`);
+ if (imdbElement) {
+ imdbId = parseImdbIdFromLink(imdbElement as HTMLElement);
+ }
}
- }
- const tags = [];
- const torrentName = element.children[1].querySelector('a[id^="torrent"]').textContent
- if (torrentName.toUpperCase().includes("REMUX")) {
- tags.push("Remux");
- }
- const torrent: Torrent = {
- dom: element,
- size: parseSize(element.children[5].textContent),
- tags: tags,
- resolution: parseResolution(torrentName)
-
- }
- const torrents = [torrent]
-
- const request: Request = {
- torrents: torrents,
- dom: [element],
- imdbId,
- title: "",
- category: parseCategory(element)
- };
- requests.push(request);
- });
+ const tags = [];
+ const torrentName =
+ element.children[1].querySelector('a[id^="torrent"]').textContent;
+ if (torrentName.toUpperCase().includes("REMUX")) {
+ tags.push("Remux");
+ }
+ const torrent: Torrent = {
+ dom: element,
+ size: parseSize(element.children[5].textContent),
+ tags: tags,
+ resolution: parseResolution(torrentName),
+ };
+ const torrents = [torrent];
+
+ const request: Request = {
+ torrents: torrents,
+ dom: [element],
+ imdbId,
+ title: "",
+ category: parseCategory(element),
+ };
+ requests.push(request);
+ });
return requests;
};
@@ -119,14 +135,16 @@ export default class BHD implements tracker {
return "BHD";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl =
"https://beyond-hd.me/library/movies?activity=&q=" + request.imdbId;
const result = await fetchAndParseHtml(queryUrl);
- return result.querySelectorAll(".bhd-meta-box").length === 0;
+ return result.querySelectorAll(".bhd-meta-box").length === 0
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/BLU.ts b/Find Unique Titles/src/trackers/BLU.ts
index d644fb1..d9f8706 100644
--- a/Find Unique Titles/src/trackers/BLU.ts
+++ b/Find Unique Titles/src/trackers/BLU.ts
@@ -1,7 +1,13 @@
import { parseSize } from "../utils/utils";
-import { MetaData, Request, toGenerator, tracker } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
export default class BLU implements tracker {
canBeUsedAsSource(): boolean {
@@ -48,8 +54,8 @@ export default class BLU implements tracker {
return "BLU";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl =
"https://blutopia.xyz/torrents?perPage=25&imdbId=" +
request.imdbId +
@@ -57,7 +63,9 @@ export default class BLU implements tracker {
const result = await fetchAndParseHtml(queryUrl);
- return result.querySelector(".torrent-listings-no-result") !== null;
+ return result.querySelector(".torrent-listings-no-result") !== null
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/BTarg.ts b/Find Unique Titles/src/trackers/BTarg.ts
index 2d0e86e..711e016 100644
--- a/Find Unique Titles/src/trackers/BTarg.ts
+++ b/Find Unique Titles/src/trackers/BTarg.ts
@@ -1,16 +1,16 @@
import { parseImdbId, parseSize } from "../utils/utils";
-import { Category, MetaData, Request, tracker } from "./tracker";
+import { Category, MetaData, Request, SearchResult, tracker } from "./tracker";
import { insertAfter } from "common/dom";
import { fetchAndParseHtml } from "common/http";
const parseCategory = (element: HTMLElement) => {
- const category = element.children[0]!!.querySelector('a')!!.href
- if (category.includes("cat=02")) return Category.MOVIE
- if (category.includes("cat=03")) return Category.TV
- if (category.includes("cat=05")) return Category.XXX
- if (category.includes("cat=08")) return Category.LIVE_PERFORMANCE
+ const category = element.children[0]!!.querySelector("a")!!.href;
+ if (category.includes("cat=02")) return Category.MOVIE;
+ if (category.includes("cat=03")) return Category.TV;
+ if (category.includes("cat=05")) return Category.XXX;
+ if (category.includes("cat=08")) return Category.LIVE_PERFORMANCE;
return Category.OTHER;
-}
+};
export default class BTarg implements tracker {
canBeUsedAsSource(): boolean {
@@ -64,8 +64,8 @@ export default class BTarg implements tracker {
return "BTarg";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -74,4 +74,4 @@ export default class BTarg implements tracker {
document.querySelector('select[name="inclfree"]') as HTMLElement
);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/CG.ts b/Find Unique Titles/src/trackers/CG.ts
index a6c0b80..ebfd0d3 100644
--- a/Find Unique Titles/src/trackers/CG.ts
+++ b/Find Unique Titles/src/trackers/CG.ts
@@ -1,5 +1,5 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { Category, MetaData, Request, toGenerator, tracker } from "./tracker";
+import { Category, MetaData, Request, SearchResult, toGenerator, tracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
@@ -77,8 +77,8 @@ export default class CG implements tracker {
return "CG";
}
- async canUpload(request: Request): Promise {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl =
"https://cinemageddon.net/browse.php?search=" +
request.imdbId +
@@ -86,7 +86,8 @@ export default class CG implements tracker {
const result = await fetchAndParseHtml(queryUrl);
- return result.textContent!!.includes("Nothing found!");
+ return result.textContent!!.includes("Nothing found!") ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/CHD.ts b/Find Unique Titles/src/trackers/CHD.ts
index 8a80a8f..136987b 100644
--- a/Find Unique Titles/src/trackers/CHD.ts
+++ b/Find Unique Titles/src/trackers/CHD.ts
@@ -1,7 +1,7 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, MetaData } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import { MetaData, Request, SearchResult, tracker } from "./tracker";
import { addChild } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
export default class CHD implements tracker {
canBeUsedAsSource(): boolean {
@@ -11,15 +11,16 @@ export default class CHD implements tracker {
canBeUsedAsTarget(): boolean {
return false;
}
-
+
canRun(url: string): boolean {
return url.includes("ptchdbits.co");
}
-async *getSearchRequest(): AsyncGenerator {
- let nodes =document.querySelectorAll('.torrents')[0].children[0].children;
+
+ async *getSearchRequest(): AsyncGenerator {
+ let nodes = document.querySelectorAll(".torrents")[0].children[0].children;
yield {
- total: nodes.length
- }
+ total: nodes.length,
+ };
let i = 1;
for (const element of nodes) {
if (!element.querySelector(".torrentname")) {
@@ -31,13 +32,13 @@ async *getSearchRequest(): AsyncGenerator {
if (!link) {
continue;
}
- let response = await fetchAndParseHtml(
- (link as HTMLAnchorElement).href
- );
+ let response = await fetchAndParseHtml((link as HTMLAnchorElement).href);
const imdbId = parseImdbIdFromLink(response as HTMLElement);
- const size = parseSize(element.querySelector('.rowfollow:nth-child(5)').innerText);
- console.log("size:",size);
+ const size = parseSize(
+ element.querySelector(".rowfollow:nth-child(5)")!!.textContent!!
+ );
+ console.log("size:", size);
const request: Request = {
torrents: [
{
@@ -50,22 +51,21 @@ async *getSearchRequest(): AsyncGenerator {
imdbId,
title: "",
};
- yield request
+ yield request;
}
}
-
name(): string {
return "CHD";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
const element = document
- .querySelector(".searchbox")
+ .querySelector(".searchbox")!!
.children[2].querySelector("td td.rowfollow tr");
addChild(element as HTMLElement, select);
}
diff --git a/Find Unique Titles/src/trackers/CLAN-SUD.ts b/Find Unique Titles/src/trackers/CLAN-SUD.ts
index 916976f..782175c 100644
--- a/Find Unique Titles/src/trackers/CLAN-SUD.ts
+++ b/Find Unique Titles/src/trackers/CLAN-SUD.ts
@@ -1,7 +1,7 @@
import { parseImdbIdFromLink } from "../utils/utils";
-import { tracker, Request, MetaData } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import { MetaData, Request, SearchResult, tracker } from "./tracker";
import { insertBefore } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
export default class CLANSUD implements tracker {
canBeUsedAsSource(): boolean {
@@ -58,8 +58,8 @@ export default class CLANSUD implements tracker {
return "CLAN-SUD";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -68,4 +68,4 @@ export default class CLANSUD implements tracker {
document.querySelector('div[data-tableid="topics"]') as HTMLElement
);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/CinemaZ.ts b/Find Unique Titles/src/trackers/CinemaZ.ts
index 53088c1..7cf0c1a 100644
--- a/Find Unique Titles/src/trackers/CinemaZ.ts
+++ b/Find Unique Titles/src/trackers/CinemaZ.ts
@@ -1,7 +1,13 @@
import { parseImdbIdFromLink } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import {
+ tracker,
+ Request,
+ toGenerator,
+ MetaData,
+ SearchResult,
+} from "./tracker";
import { addChild } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
export default class CinemaZ implements tracker {
canBeUsedAsSource(): boolean {
@@ -16,7 +22,7 @@ export default class CinemaZ implements tracker {
return url.includes("cinemaz.to");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
document
.querySelectorAll("#content-area > div.block > .row")
@@ -32,20 +38,22 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
});
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "CinemaZ";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl = "https://cinemaz.to/movies?search=&imdb=" + request.imdbId;
const result = await fetchAndParseHtml(queryUrl);
- return result.textContent!!.includes("No Movie found!");
+ return result.textContent!!.includes("No Movie found!")
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/FL.ts b/Find Unique Titles/src/trackers/FL.ts
index e35269c..5ae8b6b 100644
--- a/Find Unique Titles/src/trackers/FL.ts
+++ b/Find Unique Titles/src/trackers/FL.ts
@@ -1,7 +1,8 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, MetaData } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import { tracker, Request, MetaData, SearchResult } from "./tracker";
import { addChild } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
+import url from "url";
export default class FL implements tracker {
canBeUsedAsSource(): boolean {
@@ -16,11 +17,11 @@ export default class FL implements tracker {
return url.includes("filelist.io");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
let nodes = document.querySelectorAll(".torrentrow");
yield {
- total: nodes.length
- }
+ total: nodes.length,
+ };
for (const element of nodes) {
const link: HTMLAnchorElement | null = element.querySelector(
'a[href*="details.php?id"]'
@@ -28,9 +29,7 @@ async *getSearchRequest(): AsyncGenerator {
if (!link) {
continue;
}
- let response = await fetchAndParseHtml(
- (link as HTMLAnchorElement).href
- );
+ let response = await fetchAndParseHtml((link as HTMLAnchorElement).href);
const imdbId = parseImdbIdFromLink(response as HTMLElement);
const size = parseSize(
element.querySelector(".torrenttable:nth-child(7)")
@@ -49,7 +48,7 @@ async *getSearchRequest(): AsyncGenerator {
imdbId,
title: "",
};
- yield request
+ yield request;
}
}
@@ -57,8 +56,8 @@ async *getSearchRequest(): AsyncGenerator {
return "FL";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl =
"https://filelist.io/browse.php?search=" +
request.imdbId +
@@ -66,13 +65,12 @@ async *getSearchRequest(): AsyncGenerator {
const result = await fetchAndParseHtml(queryUrl);
- return result.querySelectorAll(".torrentrow").length === 0;
+ return result.querySelectorAll(".torrentrow").length === 0
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
- addChild(
- document.querySelector("form p") as HTMLElement,
- select
- );
+ addChild(document.querySelector("form p") as HTMLElement, select);
}
}
diff --git a/Find Unique Titles/src/trackers/GPW.ts b/Find Unique Titles/src/trackers/GPW.ts
index 6b2db48..ec84484 100644
--- a/Find Unique Titles/src/trackers/GPW.ts
+++ b/Find Unique Titles/src/trackers/GPW.ts
@@ -1,5 +1,5 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { MetaData, Request, toGenerator, Torrent, tracker } from "./tracker";
+import { MetaData, Request, SearchResult, toGenerator, Torrent, tracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
@@ -74,13 +74,14 @@ async *getSearchRequest(): AsyncGenerator {
return "GPW";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl = `https://greatposterwall.com/torrents.php?groupname=${request.imdbId}`;
const result = await fetchAndParseHtml(queryUrl);
- return result.querySelector(".torrent-listings-no-result") !== null;
+ return result.querySelector(".torrent-listings-no-result") !== null ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/HDB.ts b/Find Unique Titles/src/trackers/HDB.ts
index 1913e19..d3164c0 100644
--- a/Find Unique Titles/src/trackers/HDB.ts
+++ b/Find Unique Titles/src/trackers/HDB.ts
@@ -9,7 +9,7 @@ import {
toGenerator,
MetaData,
Torrent,
- Category,
+ Category, SearchResult
} from "./tracker";
import { fetchAndParseHtml } from "common/http";
import { addChild } from "common/dom";
@@ -110,8 +110,8 @@ export default class HDB implements tracker {
return "HDB";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl =
"https://hdbits.org/browse.php?c3=1&c1=1&c2=1&tagsearchtype=or&imdb=" +
request.imdbId +
@@ -121,7 +121,8 @@ export default class HDB implements tracker {
return result
.querySelector("#resultsarea")
- .textContent.includes("Nothing here!");
+ .textContent.includes("Nothing here!") ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/HDSky.ts b/Find Unique Titles/src/trackers/HDSky.ts
index 14a796f..d9f656b 100644
--- a/Find Unique Titles/src/trackers/HDSky.ts
+++ b/Find Unique Titles/src/trackers/HDSky.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
export default class HDSky implements tracker {
@@ -12,14 +18,13 @@ export default class HDSky implements tracker {
}
canRun(url: string): boolean {
- return (
- url.includes("hdsky.me")
- );
+ return url.includes("hdsky.me");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
- for (const element of document.querySelectorAll('.torrents')[0].children[0].children) {
+ for (const element of document.querySelectorAll(".torrents")[0].children[0]
+ .children) {
if (!element.querySelector(".torrentname")) {
continue;
}
@@ -41,15 +46,15 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
}
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "HDSky";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -58,4 +63,4 @@ async *getSearchRequest(): AsyncGenerator {
.children[2].querySelector("td td.rowfollow tr");
addChild(element as HTMLElement, select);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/HDT.ts b/Find Unique Titles/src/trackers/HDT.ts
index 97898bf..cc271a5 100644
--- a/Find Unique Titles/src/trackers/HDT.ts
+++ b/Find Unique Titles/src/trackers/HDT.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
export default class HDT implements tracker {
@@ -15,7 +21,7 @@ export default class HDT implements tracker {
return url.includes("hd-torrents.org");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
document
.querySelectorAll(
@@ -41,19 +47,19 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
});
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "HDT";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
const element = document.querySelectorAll(".mainblockcontentsearch tr")[2];
addChild(element as HTMLElement, select);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/IPT.ts b/Find Unique Titles/src/trackers/IPT.ts
index c897615..4680f1f 100644
--- a/Find Unique Titles/src/trackers/IPT.ts
+++ b/Find Unique Titles/src/trackers/IPT.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild, insertAfter } from "common/dom";
export default class CG implements tracker {
@@ -15,7 +21,7 @@ export default class CG implements tracker {
return url.includes("iptorrents.com/movies");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
document.querySelectorAll(".mBox table")?.forEach((element) => {
const imdbId = parseImdbIdFromLink(element as HTMLElement);
@@ -28,15 +34,15 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
});
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "IPT";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -44,7 +50,9 @@ async *getSearchRequest(): AsyncGenerator {
addChild(element, select);
insertAfter(
element,
- document.querySelector('.mBox form input[name="q"]')!!.closest("p") as HTMLElement
+ document
+ .querySelector('.mBox form input[name="q"]')!!
+ .closest("p") as HTMLElement
);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/JPTV.ts b/Find Unique Titles/src/trackers/JPTV.ts
index fa7b48f..0f6d9a5 100644
--- a/Find Unique Titles/src/trackers/JPTV.ts
+++ b/Find Unique Titles/src/trackers/JPTV.ts
@@ -1,7 +1,13 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
export default class JPTV implements tracker {
canBeUsedAsSource(): boolean {
@@ -16,7 +22,7 @@ export default class JPTV implements tracker {
return url.includes("jptv.club");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
let nodes = document.querySelectorAll(".view-torrent");
for (const element of nodes) {
@@ -45,15 +51,15 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
}
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "JPTV";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -62,4 +68,4 @@ async *getSearchRequest(): AsyncGenerator {
select
);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/KG.ts b/Find Unique Titles/src/trackers/KG.ts
index 5e0b9e9..3775440 100644
--- a/Find Unique Titles/src/trackers/KG.ts
+++ b/Find Unique Titles/src/trackers/KG.ts
@@ -3,13 +3,13 @@ import {
Category,
MetaData,
Request,
- toGenerator,
+ SearchResult,
Torrent,
tracker,
} from "./tracker";
import { insertBefore } from "common/dom";
import { logger } from "common/logger";
-import { search, SearchResult } from "common/searcher";
+import { search, SearchResult as SR } from "common/searcher";
import { KG as KGTracker } from "common/trackers";
const parseCategory = (element: HTMLElement): Category => {
@@ -104,13 +104,14 @@ export default class KG implements tracker {
return "KG";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const result = await search(KGTracker, {
movie_title: "",
movie_imdb_id: request.imdbId,
});
- return result == SearchResult.NOT_FOUND;
+ if (result == SR.LOGGED_OUT) return SearchResult.NOT_LOGGED_IN;
+ return result == SR.NOT_FOUND ? SearchResult.NOT_EXIST : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/MTV.ts b/Find Unique Titles/src/trackers/MTV.ts
index 0524d0e..a566b53 100644
--- a/Find Unique Titles/src/trackers/MTV.ts
+++ b/Find Unique Titles/src/trackers/MTV.ts
@@ -1,8 +1,8 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { Category, MetaData, Request, tracker } from "./tracker";
+import { Category, MetaData, Request, SearchResult, tracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
-import { search, SearchResult } from "common/searcher";
+import { search, SearchResult as SC } from "common/searcher";
import { MTV as MTVTracker, MTV_TV } from "common/trackers";
const parseCategory = (element: Element): Category | undefined => {
@@ -89,8 +89,8 @@ export default class MTV implements tracker {
return "MTV";
}
- async canUpload(request: Request) {
- let result = SearchResult.NOT_FOUND;
+ async search(request: Request): Promise {
+ let result: SearchResult;
if (request.category == Category.MOVIE) {
result = await search(MTVTracker, {
movie_title: request.title,
@@ -100,7 +100,8 @@ export default class MTV implements tracker {
movie_title: request.title,
});
}
- return result == SearchResult.NOT_FOUND;
+ return result == SC.NOT_FOUND ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/MTeam.ts b/Find Unique Titles/src/trackers/MTeam.ts
index edebbdc..2ce1edb 100644
--- a/Find Unique Titles/src/trackers/MTeam.ts
+++ b/Find Unique Titles/src/trackers/MTeam.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
export default class MTeam implements tracker {
@@ -18,9 +24,10 @@ export default class MTeam implements tracker {
);
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
- for (const element of document.querySelectorAll('.torrents')[0].children[0].children) {
+ for (const element of document.querySelectorAll(".torrents")[0].children[0]
+ .children) {
if (!element.querySelector(".torrentname")) {
continue;
}
@@ -42,15 +49,15 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
}
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "M-Team";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -59,4 +66,4 @@ async *getSearchRequest(): AsyncGenerator {
.children[2].querySelector("td td.rowfollow tr");
addChild(element as HTMLElement, select);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/NewInsane.ts b/Find Unique Titles/src/trackers/NewInsane.ts
index fef07db..be4ab1b 100644
--- a/Find Unique Titles/src/trackers/NewInsane.ts
+++ b/Find Unique Titles/src/trackers/NewInsane.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
export default class NewInsane implements tracker {
@@ -37,8 +43,8 @@ export default class NewInsane implements tracker {
return "NewInsane";
}
- async canUpload(request: Request) {
- return !request.imdbId;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -47,4 +53,4 @@ export default class NewInsane implements tracker {
select
);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/PTP.ts b/Find Unique Titles/src/trackers/PTP.ts
index 5a66eee..bdc183f 100644
--- a/Find Unique Titles/src/trackers/PTP.ts
+++ b/Find Unique Titles/src/trackers/PTP.ts
@@ -8,6 +8,7 @@ import {
Category,
MetaData,
Request,
+ SearchResult,
toGenerator,
Torrent,
tracker,
@@ -70,6 +71,14 @@ const parseCategory = (element: HTMLElement): Category => {
}
};
+const hasRequests = (element: Element) => {
+ return element
+ .querySelector("#no_results_message")!!
+ .textContent!!.trim()
+ .includes(
+ "Your search did not match any torrents, however it did match these requests."
+ );
+};
export default class PTP implements tracker {
canBeUsedAsSource(): boolean {
return true;
@@ -119,9 +128,10 @@ export default class PTP implements tracker {
return "PTP";
}
- async canUpload(request: Request, onlyNew: boolean): Promise {
- if (!isSupportedCategory(request.category)) return false;
+ async search(request: Request): Promise {
+ if (!isSupportedCategory(request.category)) return SearchResult.NOT_ALLOWED;
let torrents = [];
+ let result;
if (!request.imdbId) {
logger.debug("NO IMDB ID was provided");
if (request.title && request.year) {
@@ -133,7 +143,7 @@ export default class PTP implements tracker {
const query_url = `https://passthepopcorn.me/torrents.php?action=advanced&searchstr=${encodeURIComponent(
request.title
)}&year=${request.year}`;
- const result = await fetchAndParseHtml(query_url);
+ result = await fetchAndParseHtml(query_url);
torrents = parseAvailableTorrents(result);
}
} else {
@@ -141,28 +151,35 @@ export default class PTP implements tracker {
if (!torrents) {
const query_url =
"https://passthepopcorn.me/torrents.php?imdb=" + request.imdbId;
- const result = await fetchAndParseHtml(query_url);
+ result = await fetchAndParseHtml(query_url);
torrents = parseAvailableTorrents(result);
addToMemoryCache(request.imdbId, torrents);
}
}
let notFound = !torrents.length;
if (notFound) {
- return true;
- }
- if (onlyNew) {
- logger.debug("Title already exists and only new titles is enabled");
- return false;
+ if (hasRequests(result)) {
+ if (request.imdbId) {
+ return SearchResult.NOT_EXIST_WITH_REQUEST;
+ } else {
+ return SearchResult.MAYBE_NOT_EXIST_WITH_REQUEST;
+ }
+ }
+ if (request.imdbId) {
+ return SearchResult.NOT_EXIST
+ } else {
+ return SearchResult.MAYBE_NOT_EXIST
+ }
}
+ let searchResult: SearchResult = SearchResult.EXIST
for (let torrent of request.torrents) {
- if (canUploadTorrent(torrent, torrents)) {
- torrent.dom.style.border = "2px solid red";
- notFound = true;
+ if (searchTorrent(torrent, torrents)) {
+ searchResult = SearchResult.EXIST_BUT_MISSING_SLOT;
} else {
torrent.dom.style.display = "none";
}
}
- return notFound;
+ return searchResult;
}
insertTrackersSelect(select: HTMLSelectElement): void {
@@ -227,10 +244,7 @@ function sameResolution(first: Torrent, second: Torrent) {
if (second.resolution === "SD") return isSD(first.resolution);
}
-const canUploadTorrent = (
- torrent: Torrent,
- availableTorrents: Array
-) => {
+const searchTorrent = (torrent: Torrent, availableTorrents: Array) => {
const similarTorrents = availableTorrents.filter((e) => {
return (
sameResolution(torrent, e) &&
@@ -251,4 +265,4 @@ const canUploadTorrent = (
}
}
return false;
-};
+};
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/Pter.ts b/Find Unique Titles/src/trackers/Pter.ts
index 94d5245..622fcb1 100644
--- a/Find Unique Titles/src/trackers/Pter.ts
+++ b/Find Unique Titles/src/trackers/Pter.ts
@@ -3,6 +3,7 @@ import {
Category,
MetaData,
Request,
+ SearchResult,
toGenerator,
Torrent,
tracker,
@@ -69,10 +70,12 @@ function parseCategory(element: HTMLElement) {
}
const isExclusive = (element: HTMLElement) => {
- const torrentName = element.querySelector('.torrentname')
- const exclusiveLink = torrentName.querySelector('a[href="torrents.php?tag_exclusive=yes"]')
+ const torrentName = element.querySelector(".torrentname");
+ const exclusiveLink = torrentName.querySelector(
+ 'a[href="torrents.php?tag_exclusive=yes"]'
+ );
return exclusiveLink != null;
-}
+};
export default class Pter implements tracker {
canBeUsedAsSource(): boolean {
@@ -94,8 +97,8 @@ export default class Pter implements tracker {
.slice(1)
.forEach((element: HTMLElement) => {
if (isExclusive(element)) {
- element.style.display = 'none'
- return
+ element.style.display = "none";
+ return;
}
const spanElement = element.querySelector("span[data-imdbid]");
let imdbId = spanElement
@@ -104,7 +107,7 @@ export default class Pter implements tracker {
if (imdbId) {
imdbId = "tt" + imdbId;
} else {
- imdbId = null
+ imdbId = null;
}
const request: Request = {
@@ -124,11 +127,13 @@ export default class Pter implements tracker {
return "Pter";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl = `https://pterclub.com/torrents.php?search=${request.imdbId}`;
const result = await fetchAndParseHtml(queryUrl);
- return result.querySelector("#torrenttable") === null;
+ return result.querySelector("#torrenttable") === null
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/SC.ts b/Find Unique Titles/src/trackers/SC.ts
index f02a66b..27e447d 100644
--- a/Find Unique Titles/src/trackers/SC.ts
+++ b/Find Unique Titles/src/trackers/SC.ts
@@ -1,14 +1,16 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { Category, Request, toGenerator, tracker, MetaData } from "./tracker";
-import { fetchAndParseHtml } from "common/http";
+import { Category, MetaData, Request, SearchResult, Torrent, tracker } from "./tracker";
import { addChild } from "common/dom";
+import { fetchAndParseHtml } from "common/http";
+import { logger } from "common/logger";
-function parseTorrent(element: HTMLElement) {
+
+function parseTorrent(element: HTMLElement): Torrent {
let infos = element
.querySelector(".torrent_info .activity_info")!!
.querySelectorAll("div");
let size = parseSize(infos[1].textContent as string);
- let resolution = infos[0].textContent.trim();
+ let resolution: string | undefined = infos[0].textContent.trim();
if (resolution == "CD" || resolution == "WEB") {
resolution = undefined;
}
@@ -20,7 +22,7 @@ function parseTorrent(element: HTMLElement) {
return {
size,
tags: [],
- dom: [element],
+ dom: element,
resolution,
format,
};
@@ -34,12 +36,22 @@ function parseCategory(element: HTMLElement) {
let info = infos[0].textContent;
if (info == "CD" || info === "WEB") {
category = Category.MUSIC;
- } else if (parseSize(infos[0].textContent as string)) {
+ } else if (
+ element.querySelector(".torrent_tags")!!.textContent!!.includes("ebook")
+ ) {
category = Category.BOOK;
}
return category;
}
+const parseYearTitle = (element: Element) => {
+ const title = element.querySelector(".torrent_title b")!!.textContent!!;
+ const year = parseInt(
+ element.querySelector(".torrent_year")!!.textContent!!.split("|")[0].trim(),
+ 10
+ );
+ return { title, year };
+};
export default class SC implements tracker {
canBeUsedAsSource(): boolean {
return true;
@@ -53,47 +65,48 @@ export default class SC implements tracker {
return url.includes("secret-cinema.pw") && !url.includes("torrents.php?id");
}
-async *getSearchRequest(): AsyncGenerator {
- const requests: Array = [];
- document
- .querySelectorAll(".torrent_card")
- .forEach((element: HTMLElement) => {
- let dom: Element = element;
- let links_container: HTMLElement | null =
- element.querySelector(".torrent_tags");
-
- if (links_container === null) return;
- let imdbId = parseImdbIdFromLink(links_container);
+ async *getSearchRequest(): AsyncGenerator {
+ logger.debug(`[{0}] Parsing titles to check`, this.name());
+ const elements = Array.from(
+ document.querySelectorAll(".torrent_card")
+ ).filter((element) => element.querySelector(".torrent_tags") != null);
+ yield {
+ total: elements.length,
+ };
+ for (let element of elements) {
+ let links_container: HTMLElement =
+ element.querySelector(".torrent_tags")!!;
- const request: Request = {
- torrents: [parseTorrent(element)],
- dom: [dom],
- imdbId,
- title: "",
- category: parseCategory(element),
- };
- requests.push(request);
- });
+ const imdbId = parseImdbIdFromLink(links_container);
+ const { title, year } = parseYearTitle(element);
- yield* toGenerator(requests)
-
-}
+ const request: Request = {
+ torrents: [parseTorrent(element as HTMLElement)],
+ dom: [element as HTMLElement],
+ imdbId,
+ title,
+ year,
+ category: parseCategory(element as HTMLElement),
+ };
+ logger.debug(`[{0}] Search request: {1}`, this.name(), request);
+ yield request;
+ }
+ }
name(): string {
return "SC";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const queryUrl = `https://secret-cinema.pw/torrents.php?action=advanced&searchsubmit=1&cataloguenumber=${request.imdbId}&order_by=time&order_way=desc&tags_type=0`;
const result = await fetchAndParseHtml(queryUrl);
- return result.querySelector(".torrent_card_container") === null;
+ return result.querySelector(".torrent_card_container") === null
+ ? SearchResult.NOT_EXIST
+ : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
- addChild(
- document.querySelector("#ft_container p") as HTMLElement,
- select
- );
+ addChild(document.querySelector("#ft_container p") as HTMLElement, select);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/TL.ts b/Find Unique Titles/src/trackers/TL.ts
index 2bd9ece..e387073 100644
--- a/Find Unique Titles/src/trackers/TL.ts
+++ b/Find Unique Titles/src/trackers/TL.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
export default class TL implements tracker {
@@ -15,7 +21,7 @@ export default class TL implements tracker {
return url.includes("torrentleech.org");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
document.querySelectorAll(".torrent")?.forEach((element: HTMLElement) => {
const imdbId = parseImdbIdFromLink(element);
@@ -38,24 +44,21 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
});
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "TL";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
select.style.margin = "20px 0";
select.style.padding = "2px 2px 3px 2px";
select.style.color = "#111";
- addChild(
- document.querySelector(".sub-navbar") as HTMLElement,
- select
- );
+ addChild(document.querySelector(".sub-navbar") as HTMLElement, select);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/TSeeds.ts b/Find Unique Titles/src/trackers/TSeeds.ts
index b653ca2..28d2b7d 100644
--- a/Find Unique Titles/src/trackers/TSeeds.ts
+++ b/Find Unique Titles/src/trackers/TSeeds.ts
@@ -1,8 +1,8 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { Category, MetaData, Request, tracker } from "./tracker";
+import { Category, MetaData, Request, SearchResult, tracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
-import { search, SearchResult } from "common/searcher";
+import { search, SearchResult as SR } from "common/searcher";
import { TSeeds as TSeedsTracker } from "common/trackers";
const parseCategory = (element: Element): Category | undefined => {
@@ -79,13 +79,14 @@ export default class TSeeds implements tracker {
return "TSeeds";
}
- async canUpload(request: Request) {
- if (!request.imdbId) return true;
+ async search(request: Request): Promise {
+ if (!request.imdbId) return SearchResult.NOT_CHECKED;
const result = await search(TSeedsTracker, {
movie_title: "",
movie_imdb_id: request.imdbId,
});
- return result == SearchResult.NOT_FOUND;
+ if (result == SR.LOGGED_OUT) return SearchResult.NOT_LOGGED_IN;
+ return result == SR.NOT_FOUND ? SearchResult.NOT_EXIST : SearchResult.EXIST;
}
insertTrackersSelect(select: HTMLElement): void {
diff --git a/Find Unique Titles/src/trackers/TiK.ts b/Find Unique Titles/src/trackers/TiK.ts
index a0bfaa7..8575ef2 100644
--- a/Find Unique Titles/src/trackers/TiK.ts
+++ b/Find Unique Titles/src/trackers/TiK.ts
@@ -1,5 +1,5 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, MetaData, toGenerator } from "./tracker";
+import { MetaData, Request, SearchResult, tracker } from "./tracker";
import { insertBefore } from "common/dom";
const findTorrentsTable = () => {
@@ -82,8 +82,8 @@ export default class TiK implements tracker {
return "TiK";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
@@ -92,4 +92,4 @@ export default class TiK implements tracker {
td.appendChild(select);
insertBefore(td, stateSelect.parentElement);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/nCore.ts b/Find Unique Titles/src/trackers/nCore.ts
index 64809e6..f442814 100644
--- a/Find Unique Titles/src/trackers/nCore.ts
+++ b/Find Unique Titles/src/trackers/nCore.ts
@@ -1,5 +1,11 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
-import { tracker, Request, toGenerator, MetaData } from "./tracker";
+import {
+ MetaData,
+ Request,
+ SearchResult,
+ toGenerator,
+ tracker,
+} from "./tracker";
import { addChild } from "common/dom";
export default class MTeam implements tracker {
@@ -15,12 +21,13 @@ export default class MTeam implements tracker {
return url.includes("https://ncore.pro");
}
-async *getSearchRequest(): AsyncGenerator {
+ async *getSearchRequest(): AsyncGenerator {
const requests: Array = [];
for (const element of document.querySelectorAll(".box_torrent")) {
-
const imdbId = parseImdbIdFromLink(element);
- const size = parseSize(element.children[1].children[4].textContent as string);
+ const size = parseSize(
+ element.children[1].children[4].textContent as string
+ );
const request: Request = {
torrents: [
@@ -37,19 +44,19 @@ async *getSearchRequest(): AsyncGenerator {
requests.push(request);
}
- yield* toGenerator(requests)
-}
+ yield* toGenerator(requests);
+ }
name(): string {
return "nCore";
}
- async canUpload(request: Request) {
- return false;
+ async search(request: Request): Promise {
+ return SearchResult.NOT_CHECKED;
}
insertTrackersSelect(select: HTMLElement): void {
const element = document.querySelector("#keresoresz tr");
addChild(element as HTMLElement, select);
}
-}
+}
\ No newline at end of file
diff --git a/Find Unique Titles/src/trackers/tracker.ts b/Find Unique Titles/src/trackers/tracker.ts
index 8b09024..4056131 100644
--- a/Find Unique Titles/src/trackers/tracker.ts
+++ b/Find Unique Titles/src/trackers/tracker.ts
@@ -37,10 +37,22 @@ export interface MetaData {
total: number;
}
+export enum SearchResult {
+ EXIST,
+ EXIST_BUT_MISSING_SLOT,
+ NOT_EXIST,
+ MAYBE_NOT_EXIST,
+ NOT_EXIST_WITH_REQUEST,
+ MAYBE_NOT_EXIST_WITH_REQUEST,
+ NOT_CHECKED,
+ NOT_LOGGED_IN,
+ NOT_ALLOWED
+}
+
export interface tracker {
canRun(url: string): boolean;
- canUpload(request: Request, onlyNewTitle: boolean): Promise;
+ search(request: Request): Promise;
canBeUsedAsSource(): boolean;
diff --git a/common/src/logger/index.ts b/common/src/logger/index.ts
index 7fedc0f..6c50e27 100644
--- a/common/src/logger/index.ts
+++ b/common/src/logger/index.ts
@@ -17,14 +17,13 @@ export const logger = {
info: (message: string, ...args: Array) => {
if (logger.level <= LEVEL.INFO) {
- console.log(formatMessage(logger.level, message, args));
+ console.log(formatMessage(LEVEL.INFO, message, args));
}
},
debug: (message: string, ...args: Array) => {
- // Log debug messages if level is 'debug'
if (logger.level <= LEVEL.DEBUG) {
- console.log(formatMessage(logger.level, message, args));
+ console.log(formatMessage(LEVEL.DEBUG, message, args));
}
},
};
@@ -43,9 +42,9 @@ const formatMessage = (level: LEVEL, message: string, args: any[]): string => {
const argIndex = parseInt(index, 10);
const argValue = args[argIndex];
- // Stringify objects and arrays
- return typeof argValue === 'object' ? JSON.stringify(argValue) : argValue;
-
+ return typeof argValue === "object"
+ ? JSON.stringify(argValue)
+ : argValue;
})
.trim()
);