diff --git a/Find Unique Titles/dist/find.unique.titles.user.js b/Find Unique Titles/dist/find.unique.titles.user.js index 893340c..cd48572 100644 --- a/Find Unique Titles/dist/find.unique.titles.user.js +++ b/Find Unique Titles/dist/find.unique.titles.user.js @@ -94,17 +94,13 @@ (0, _utils_dom__WEBPACK_IMPORTED_MODULE_3__.updateTotalCount)(metadata.total); common_logger__WEBPACK_IMPORTED_MODULE_0__.logger.debug("[{0}] Parsing titles to check", sourceTracker.name()); for await (const item of requestGenerator) { - if (null == item) { - (0, _utils_dom__WEBPACK_IMPORTED_MODULE_3__.updateCount)(i++); - continue; - } + if (null == item) continue; const request = item; common_logger__WEBPACK_IMPORTED_MODULE_0__.logger.debug("[{0}] Search request: {1}", sourceTracker.name(), request); try { if (settings.useCache && request.imdbId && (0, _utils_cache__WEBPACK_IMPORTED_MODULE_4__.existsInCache)(targetTracker.name(), request.imdbId)) { common_logger__WEBPACK_IMPORTED_MODULE_0__.logger.debug("Title exists in target tracker, found using cache"); hideTorrents(request); - (0, _utils_dom__WEBPACK_IMPORTED_MODULE_3__.updateCount)(i++); continue; } const response = await targetTracker.search(request); @@ -948,8 +944,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_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"); + 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"); const isExclusive = element => { const exclusiveLink = element.querySelector('a[href="/browse.php?exclusive=1"]'); return null != exclusiveLink; @@ -1004,7 +1001,7 @@ yield { total: elements.length }; - for (let element of elements) { + for (let element of elements) try { if (isExclusive(element)) { element.style.display = "none"; yield null; @@ -1019,6 +1016,10 @@ year, category: parseCategory(element) }; + } catch (e) { + console.trace(e); + common_logger__WEBPACK_IMPORTED_MODULE_2__.logger.info("{0} Error occurred while parsing torrent: " + e, this.name()); + yield null; } } name() { @@ -1027,12 +1028,12 @@ 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); + const result = await (0, common_http__WEBPACK_IMPORTED_MODULE_3__.fetchAndParseHtml)(queryUrl); 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:
"; - (0, common_dom__WEBPACK_IMPORTED_MODULE_3__.addChild)(document.querySelector("#moresearch3 > td:nth-child(2)"), select); + (0, common_dom__WEBPACK_IMPORTED_MODULE_4__.addChild)(document.querySelector("#moresearch3 > td:nth-child(2)"), select); } } }, diff --git a/Find Unique Titles/src/index.ts b/Find Unique Titles/src/index.ts index 99c5297..371fac7 100644 --- a/Find Unique Titles/src/index.ts +++ b/Find Unique Titles/src/index.ts @@ -70,7 +70,6 @@ const main = async function () { logger.debug(`[{0}] Parsing titles to check`, sourceTracker!!.name()); for await (const item of requestGenerator) { if (item == null) { - updateCount(i++); continue; } const request = item as Request; @@ -87,7 +86,6 @@ const main = async function () { ) { logger.debug("Title exists in target tracker, found using cache"); hideTorrents(request); - updateCount(i++); continue; } const response = await targetTracker.search(request); diff --git a/Find Unique Titles/src/trackers/HDB.ts b/Find Unique Titles/src/trackers/HDB.ts index 6d7b660..f1918bb 100644 --- a/Find Unique Titles/src/trackers/HDB.ts +++ b/Find Unique Titles/src/trackers/HDB.ts @@ -6,16 +6,16 @@ import { parseYearAndTitle, } from "../utils/utils"; import { - tracker, - Request, - toGenerator, - MetaData, - Torrent, Category, + MetaData, + Request, SearchResult, + Torrent, + tracker, } from "./tracker"; import { addChild } from "common/dom"; import { fetchAndParseHtml } from "common/http"; +import { logger } from "common/logger"; const isExclusive = (element: HTMLElement) => { const exclusiveLink = element.querySelector( @@ -86,28 +86,37 @@ export default class HDB implements tracker { total: elements.length, }; for (let element of elements) { - if (isExclusive(element)) { - element.style.display = "none"; - yield null; - } - const imdbId = parseImdbId( - element - .querySelector("a[data-imdb-link]") - ?.getAttribute("data-imdb-link") - ); + try { + if (isExclusive(element)) { + element.style.display = "none"; + yield null; + } + const imdbId = parseImdbId( + element + .querySelector("a[data-imdb-link]") + ?.getAttribute("data-imdb-link") + ); - const { title, year } = parseYearAndTitle( - element.children[2].querySelector("a")!!.textContent - ); + const { title, year } = parseYearAndTitle( + element.children[2].querySelector("a")!!.textContent + ); - yield { - torrents: [parseTorrent(element)], - dom: [element as HTMLElement], - imdbId, - title, - year, - category: parseCategory(element), - }; + yield { + torrents: [parseTorrent(element)], + dom: [element as HTMLElement], + imdbId, + title, + year, + category: parseCategory(element), + }; + } catch (e) { + console.trace(e); + logger.info( + "{0} Error occurred while parsing torrent: " + e, + this.name() + ); + yield null; + } } }