From 883ba3d59cec5e37347b0fdca6585d8a9cb333b2 Mon Sep 17 00:00:00 2001 From: Morea Date: Sun, 21 Apr 2024 15:39:23 +0200 Subject: [PATCH] Fix CZ --- .../dist/find.unique.titles.user.js | 48 +++++++++++---- Find Unique Titles/package.json | 2 +- Find Unique Titles/src/trackers/AvistaZ.ts | 1 - Find Unique Titles/src/trackers/CinemaZ.ts | 61 +++++++++++-------- 4 files changed, 73 insertions(+), 39 deletions(-) diff --git a/Find Unique Titles/dist/find.unique.titles.user.js b/Find Unique Titles/dist/find.unique.titles.user.js index 57559f4..5bbbca5 100644 --- a/Find Unique Titles/dist/find.unique.titles.user.js +++ b/Find Unique Titles/dist/find.unique.titles.user.js @@ -796,8 +796,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_searcher__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/searcher/index.mjs"); + var common_trackers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../common/dist/trackers/index.mjs"); class CinemaZ { canBeUsedAsSource() { return true; @@ -809,30 +810,42 @@ return url.includes("cinemaz.to"); } async* getSearchRequest() { - const requests = []; - document.querySelectorAll("#content-area > div.block > .row")?.forEach((element => { + const rows = document.querySelectorAll("#content-area > div.block > .row"); + let elements = Array.from(rows); + if (1 === rows.length) elements = Array.from(rows.item(0).children); + yield { + total: elements.length + }; + for (let element of elements) { const imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseImdbIdFromLink)(element); + const {title, year} = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseYearAndTitle)(element.querySelector("a")?.getAttribute("title")); const request = { - torrents: [], + torrents: [ { + dom: element + } ], dom: [ element ], imdbId, - title: "" + title, + year, + category: _tracker__WEBPACK_IMPORTED_MODULE_1__.Category.MOVIE }; - requests.push(request); - })); - yield* (0, _tracker__WEBPACK_IMPORTED_MODULE_1__.toGenerator)(requests); + yield request; + } } name() { return "CinemaZ"; } 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!") ? _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_EXIST : _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.EXIST; + const result = await (0, common_searcher__WEBPACK_IMPORTED_MODULE_2__.search)(common_trackers__WEBPACK_IMPORTED_MODULE_3__.CZ, { + movie_title: "", + movie_imdb_id: request.imdbId + }); + if (result == common_searcher__WEBPACK_IMPORTED_MODULE_2__.SearchResult.LOGGED_OUT) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_LOGGED_IN; + return result == common_searcher__WEBPACK_IMPORTED_MODULE_2__.SearchResult.NOT_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); + (0, common_dom__WEBPACK_IMPORTED_MODULE_4__.addChild)(document.querySelector("#content-area > div.well.well-sm"), select); } } }, @@ -3207,6 +3220,7 @@ __webpack_require__.d(__webpack_exports__, { AT: () => AT, Aither: () => Aither, + CZ: () => CZ, HDb: () => HDb, KG: () => KG, MTV: () => MTV, @@ -3229,6 +3243,14 @@ matchRegex: /class="overlay-container"|class="movie-poster/, positiveMatch: true }; + const CZ = { + name: "CZ", + searchUrl: "https://cinemaz.to/movies?search=&imdb=%tt%", + configName: "ET", + loggedOutRegex: /Forgot Your Password/, + matchRegex: /class="overlay-container"|class="movie-poster/, + positiveMatch: true + }; const HDb = { name: "HDb", searchUrl: "https://hdbits.org/browse.php?c1=1&c2=1&c3=1&c4=1&c5=1&c7=1&c8=1&imdb=%tt%", diff --git a/Find Unique Titles/package.json b/Find Unique Titles/package.json index 287d127..a865d33 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.10", + "version": "0.0.11", "author": { "name": "Mea01" }, diff --git a/Find Unique Titles/src/trackers/AvistaZ.ts b/Find Unique Titles/src/trackers/AvistaZ.ts index 181c175..d48541b 100644 --- a/Find Unique Titles/src/trackers/AvistaZ.ts +++ b/Find Unique Titles/src/trackers/AvistaZ.ts @@ -1,7 +1,6 @@ import { parseImdbIdFromLink, parseYearAndTitle } from "../utils/utils"; import { tracker, Request, MetaData, SearchResult, Category } from "./tracker"; import { addChild } from "common/dom"; -import { fetchAndParseHtml } from "common/http"; import { search, SearchResult as SR } from "common/searcher"; import { AT as ATTracker } from "common/trackers"; diff --git a/Find Unique Titles/src/trackers/CinemaZ.ts b/Find Unique Titles/src/trackers/CinemaZ.ts index 7cf0c1a..086e56e 100644 --- a/Find Unique Titles/src/trackers/CinemaZ.ts +++ b/Find Unique Titles/src/trackers/CinemaZ.ts @@ -1,13 +1,14 @@ -import { parseImdbIdFromLink } from "../utils/utils"; +import { parseImdbIdFromLink, parseYearAndTitle } from "../utils/utils"; import { tracker, Request, - toGenerator, MetaData, SearchResult, + Category, } from "./tracker"; import { addChild } from "common/dom"; -import { fetchAndParseHtml } from "common/http"; +import { search, SearchResult as SR } from "common/searcher"; +import { CZ as CZTracker } from "common/trackers"; export default class CinemaZ implements tracker { canBeUsedAsSource(): boolean { @@ -23,22 +24,34 @@ export default class CinemaZ implements tracker { } async *getSearchRequest(): AsyncGenerator { - const requests: Array = []; - document - .querySelectorAll("#content-area > div.block > .row") - ?.forEach((element: HTMLElement) => { - const imdbId = parseImdbIdFromLink(element); + const rows = document.querySelectorAll("#content-area > div.block > .row"); + let elements = Array.from(rows); + if (rows.length === 1) { + elements = Array.from(rows.item(0)!!.children); + } + yield { + total: elements.length, + }; + for (let element of elements) { + const imdbId = parseImdbIdFromLink(element); + const { title, year } = parseYearAndTitle( + element.querySelector("a")?.getAttribute("title") + ); - const request: Request = { - torrents: [], - dom: [element], - imdbId, - title: "", - }; - requests.push(request); - }); - - yield* toGenerator(requests); + const request: Request = { + torrents: [ + { + dom: element, + }, + ], + dom: [element], + imdbId, + title, + year, + category: Category.MOVIE, + }; + yield request; + } } name(): string { @@ -47,13 +60,13 @@ export default class CinemaZ implements tracker { 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); + const result = await search(CZTracker, { + movie_title: "", + movie_imdb_id: request.imdbId, + }); + if (result == SR.LOGGED_OUT) return SearchResult.NOT_LOGGED_IN; + return result == SR.NOT_FOUND ? SearchResult.NOT_EXIST : SearchResult.EXIST; - return result.textContent!!.includes("No Movie found!") - ? SearchResult.NOT_EXIST - : SearchResult.EXIST; } insertTrackersSelect(select: HTMLElement): void {