Skip to content

Commit

Permalink
Add support for extracting release group and use it to filter banned …
Browse files Browse the repository at this point in the history
…groups in PTP
  • Loading branch information
Morea committed Dec 21, 2024
1 parent 67320fd commit 9088b20
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 3 deletions.
16 changes: 15 additions & 1 deletion Find Unique Titles/dist/find.unique.titles.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,7 @@
var common_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../common/dist/logger/index.mjs");
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([ _utils_cache__WEBPACK_IMPORTED_MODULE_5__ ]);
_utils_cache__WEBPACK_IMPORTED_MODULE_5__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
const BANNED_RELEASE_GROUPS = [ "aXXo", "BMDRu", "BRrip", "CM8", "CrEwSaDe", "CTFOH", "d3g", "DNL", "FaNGDiNG0", "HD2DVD", "HDTime", "ION10", "iPlanet", "KiNGDOM", "mHD", "mSD", "nHD", "nikt0", "nSD", "NhaNc3", "OFT", "PRODJi", "SANTi", "SPiRiT", "STUTTERSHIT", "ViSION", "VXT", "WAF", "x0r", "YIFY", "OFT", "BHDStudio", "nikt0", "HDT", "LAMA", "WORLD", "SasukeducK", "SPiRiT" ];
function isSupportedCategory(category) {
return void 0 === category || category === _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.MOVIE || category === _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.DOCUMENTARY || category === _tracker__WEBPACK_IMPORTED_MODULE_0__.Category.LIVE_PERFORMANCE;
}
Expand Down Expand Up @@ -1862,6 +1863,10 @@
common_logger__WEBPACK_IMPORTED_MODULE_2__.logger.debug("[PTP] Torrent not allowed: non HDR X265 and not 2160p");
return false;
}
if (BANNED_RELEASE_GROUPS.includes(torrent.releaseGroup)) {
common_logger__WEBPACK_IMPORTED_MODULE_2__.logger.debug(`[PTP] Torrent not allowed: banned release group: ${torrent.releaseGroup}`);
return false;
}
return true;
};
class PTP extends _tracker__WEBPACK_IMPORTED_MODULE_0__.AbstractTracker {
Expand Down Expand Up @@ -2345,7 +2350,8 @@
tags: (0, _utils_utils__WEBPACK_IMPORTED_MODULE_2__.parseTags)(torrentTitle),
dom: element,
resolution: (0, _utils_utils__WEBPACK_IMPORTED_MODULE_2__.parseResolution)(torrentTitle),
container: (0, _utils_utils__WEBPACK_IMPORTED_MODULE_2__.parseCodec)(torrentTitle)
container: (0, _utils_utils__WEBPACK_IMPORTED_MODULE_2__.parseCodec)(torrentTitle),
releaseGroup: (0, _utils_utils__WEBPACK_IMPORTED_MODULE_2__.parseReleaseGroup)(torrentTitle)
} ],
dom: [ element ],
imdbId,
Expand Down Expand Up @@ -2940,6 +2946,7 @@
parseContainerAndFormat: () => parseContainerAndFormat,
parseImdbId: () => parseImdbId,
parseImdbIdFromLink: () => parseImdbIdFromLink,
parseReleaseGroup: () => parseReleaseGroup,
parseResolution: () => parseResolution,
parseSize: () => parseSize,
parseTags: () => parseTags,
Expand Down Expand Up @@ -3064,6 +3071,13 @@
const match = title.match(regex);
if (match) return parseInt(match[1], 10);
};
const parseReleaseGroup = title => {
const lastDashIndex = title.lastIndexOf("-");
if (-1 === lastDashIndex || lastDashIndex === title.length - 1) return null;
const maybeGroup = title.substring(lastDashIndex + 1).trim();
if (maybeGroup.includes(" ")) return null;
return maybeGroup;
};
},
"../common/dist/dom/index.mjs": (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.d(__webpack_exports__, {
Expand Down
47 changes: 47 additions & 0 deletions Find Unique Titles/src/trackers/PTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,47 @@ import { findFirst, insertBefore } from "common/dom";
import { fetchAndParseHtml } from "common/http";
import { logger } from "common/logger";

const BANNED_RELEASE_GROUPS = [
"aXXo",
"BMDRu",
"BRrip",
"CM8",
"CrEwSaDe",
"CTFOH",
"d3g",
"DNL",
"FaNGDiNG0",
"HD2DVD",
"HDTime",
"ION10",
"iPlanet",
"KiNGDOM",
"mHD",
"mSD",
"nHD",
"nikt0",
"nSD",
"NhaNc3",
"OFT",
"PRODJi",
"SANTi",
"SPiRiT",
"STUTTERSHIT",
"ViSION",
"VXT",
"WAF",
"x0r",
"YIFY",
"OFT",
"BHDStudio",
"nikt0",
"HDT",
"LAMA",
"WORLD",
"SasukeducK",
"SPiRiT",
];

function isSupportedCategory(category: Category | undefined) {
return (
category === undefined ||
Expand Down Expand Up @@ -94,6 +135,12 @@ const isAllowedTorrent = (torrent: Torrent) => {
logger.debug("[PTP] Torrent not allowed: non HDR X265 and not 2160p");
return false;
}
if (BANNED_RELEASE_GROUPS.includes(torrent.releaseGroup)) {
logger.debug(
`[PTP] Torrent not allowed: banned release group: ${torrent.releaseGroup}`
);
return false;
}
return true;
};

Expand Down
3 changes: 2 additions & 1 deletion Find Unique Titles/src/trackers/TL.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
parseCodec,
parseImdbIdFromLink,
parseImdbIdFromLink, parseReleaseGroup,
parseResolution,
parseSize,
parseTags, parseYearAndTitle
Expand Down Expand Up @@ -63,6 +63,7 @@ export default class TL extends AbstractTracker {
dom: element as HTMLElement,
resolution: parseResolution(torrentTitle),
container: parseCodec(torrentTitle),
releaseGroup: parseReleaseGroup(torrentTitle)
},
],
dom: [element as HTMLElement],
Expand Down
1 change: 1 addition & 0 deletions Find Unique Titles/src/trackers/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface Torrent {
format?: string | null;
resolution?: Resolution;
dom: HTMLElement;
releaseGroup?: string;
}

export enum Resolution {
Expand Down
14 changes: 13 additions & 1 deletion Find Unique Titles/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export const parseImdbId = (text: string) => {
return results[0];
};

export const parseResolution = (text: string|undefined): Resolution | undefined => {
export const parseResolution = (
text: string | undefined
): Resolution | undefined => {
if (!text) return undefined;
const resolutionsAndAliases: Record<Resolution, string[]> = {
SD: ["sd", "pal", "ntsc"],
Expand Down Expand Up @@ -156,3 +158,13 @@ export const parseYear = (title: string) => {
const match = title.match(regex);
if (match) return parseInt(match[1], 10);
};

export const parseReleaseGroup = (title: string): string | null => {
const lastDashIndex = title.lastIndexOf("-");
if (lastDashIndex === -1 || lastDashIndex === title.length - 1) {
return null;
}
const maybeGroup = title.substring(lastDashIndex + 1).trim();
if (maybeGroup.includes(" ")) return null;
return maybeGroup;
};

0 comments on commit 9088b20

Please sign in to comment.