Skip to content

Commit

Permalink
Fix AZ
Browse files Browse the repository at this point in the history
  • Loading branch information
Morea committed Apr 21, 2024
1 parent f22cc28 commit fd5966f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 47 deletions.
51 changes: 35 additions & 16 deletions Find Unique Titles/dist/find.unique.titles.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,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 AvistaZ {
canBeUsedAsSource() {
return true;
Expand All @@ -332,30 +333,40 @@
return url.includes("avistaz.to");
}
async* getSearchRequest() {
const requests = [];
document.querySelectorAll("#content-area > div.block > .row")?.forEach((element => {
const elements = Array.from(document.querySelector("#content-area > div.block > .row").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 "AvistaZ";
}
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!") ? _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__.AT, {
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);
}
}
},
Expand Down Expand Up @@ -1758,7 +1769,7 @@
};
const hasRequests = element => true === element.querySelector("#no_results_message")?.textContent?.trim().includes("Your search did not match any torrents, however it did match these requests.");
const isAllowedTorrent = torrent => {
if ("x265" == torrent.container && torrent.resolution != _tracker__WEBPACK_IMPORTED_MODULE_0__.Resolution.UHD && !isHDR(torrent)) {
if ("x265" === torrent.container && torrent.resolution !== _tracker__WEBPACK_IMPORTED_MODULE_0__.Resolution.UHD && !isHDR(torrent)) {
common_logger__WEBPACK_IMPORTED_MODULE_2__.logger.debug("[PTP] Torrent not allowed: non HDR X265 and not 2160p");
return false;
}
Expand Down Expand Up @@ -1887,7 +1898,7 @@
}
const isHDR = torrent => torrent.tags?.includes("HDR") || torrent.tags?.includes("DV");
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"))));
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;
return false;
Expand Down Expand Up @@ -2921,7 +2932,7 @@
title: void 0,
year: void 0
};
const regexes = [ /^(.*?)\s+\(?(\d{4})\)?\s+(.*)/, /(.+?)\.(\d\d\d\d)/ ];
const regexes = [ /^(.*?)\s+\(?(\d{4})\)?\s+(.*)/, /(.+?)\.(\d\d\d\d)/, /(.+?) \((\d\d\d\d)\)/ ];
for (let regex of regexes) {
const match = title.match(regex);
if (match) {
Expand Down Expand Up @@ -3192,6 +3203,7 @@
},
"../common/dist/trackers/index.mjs": (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.d(__webpack_exports__, {
AT: () => AT,
Aither: () => Aither,
HDb: () => HDb,
KG: () => KG,
Expand All @@ -3208,6 +3220,13 @@
positiveMatch: true,
both: true
};
const AT = {
name: "AT",
searchUrl: "https://avistaz.to/movies?search=&imdb=%tt%",
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%",
Expand Down
2 changes: 1 addition & 1 deletion Find Unique Titles/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "find.unique.titles",
"description": "Find unique titles to cross seed",
"version": "0.0.9",
"version": "0.0.10",
"author": {
"name": "Mea01"
},
Expand Down
63 changes: 37 additions & 26 deletions Find Unique Titles/src/trackers/AvistaZ.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { parseImdbIdFromLink } from "../utils/utils";
import { tracker, Request, MetaData, toGenerator, SearchResult } from "./tracker";
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";

export default class AvistaZ implements tracker {
canBeUsedAsSource(): boolean {
Expand All @@ -17,37 +19,46 @@ export default class AvistaZ implements tracker {
}

async *getSearchRequest(): AsyncGenerator<MetaData | Request, void, void> {
const requests: Array<Request> = [];
document
.querySelectorAll("#content-area > div.block > .row")
?.forEach((element: HTMLElement) => {
const imdbId = parseImdbIdFromLink(element);

const request: Request = {
torrents: [],
dom: [element],
imdbId,
title: "",
};
requests.push(request);
});

yield* toGenerator(requests);
const elements = Array.from(
document.querySelector("#content-area > div.block > .row")!!.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,
},
],
dom: [element],
imdbId,
title,
year,
category: Category.MOVIE,
};
yield request;
}
}

name(): string {
return "AvistaZ";
}

async search(request: Request) : Promise<SearchResult> {
async search(request: Request): Promise<SearchResult> {
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!")
? SearchResult.NOT_EXIST
: SearchResult.EXIST;
const result = await search(ATTracker, {
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;
}

insertTrackersSelect(select: HTMLElement): void {
Expand Down
6 changes: 3 additions & 3 deletions Find Unique Titles/src/trackers/PTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const hasRequests = (element: Element): boolean => {

const isAllowedTorrent = (torrent: Torrent) => {
if (
torrent.container == "x265" &&
torrent.resolution != Resolution.UHD &&
torrent.container === "x265" &&
torrent.resolution !== Resolution.UHD &&
!isHDR(torrent)
) {
logger.debug("[PTP] Torrent not allowed: non HDR X265 and not 2160p");
Expand Down Expand Up @@ -320,7 +320,7 @@ const searchTorrent = (torrent: Torrent, availableTorrents: Array<Torrent>) => {
sameResolution(torrent, e) &&
(torrent.container === undefined ||
sameContainer(e.container, torrent.container)) &&
(!torrent.tags.includes("Remux") || e.tags.includes("Remux"))
(!torrent.tags?.includes("Remux") || e.tags?.includes("Remux"))
);
});
if (similarTorrents.length == 0 && torrent.resolution && torrent.container) {
Expand Down
6 changes: 5 additions & 1 deletion Find Unique Titles/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ export const parseTags = (title: string) => {

export const parseYearAndTitle = (title: string | undefined) => {
if (!title) return { title: undefined, year: undefined };
const regexes = [/^(.*?)\s+\(?(\d{4})\)?\s+(.*)/, /(.+?)\.(\d\d\d\d)/];
const regexes = [
/^(.*?)\s+\(?(\d{4})\)?\s+(.*)/,
/(.+?)\.(\d\d\d\d)/,
/(.+?) \((\d\d\d\d)\)/,
];
for (let regex of regexes) {
const match = title.match(regex);

Expand Down

0 comments on commit fd5966f

Please sign in to comment.