Skip to content

Commit

Permalink
Support BHD library pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Morea committed Feb 4, 2024
1 parent 747ec22 commit 560eb53
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Find Unique Titles/config/userscript.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const UserScriptConfig: IWebpackUserScript = {
"https://hdbits.org/browse.php*",
"https://passthepopcorn.me/torrents.php*",
"https://passthepopcorn.me/torrents.php?type=seeding",
"https://beyond-hd.me/library/movies*",
"https://beyond-hd.me/library/*",
"https://beyond-hd.me/torrents*",
"https://cinemaz.to/movies*",
"https://avistaz.to/movies*",
Expand Down
14 changes: 7 additions & 7 deletions Find Unique Titles/dist/find.unique.titles.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// @match https://hdbits.org/browse.php*
// @match https://passthepopcorn.me/torrents.php*
// @match https://passthepopcorn.me/torrents.php?type=seeding
// @match https://beyond-hd.me/library/movies*
// @match https://beyond-hd.me/library/*
// @match https://beyond-hd.me/torrents*
// @match https://cinemaz.to/movies*
// @match https://avistaz.to/movies*
Expand All @@ -22,7 +22,7 @@
// @match https://filelist.io/browse.php*
// @match https://jptv.club/torrents*
// @match https://hd-torrents.org/torrents.php*
// @match https://iptorrents.com/t?*
// @match https://iptorrents.com/t*
// @match https://kp.m-team.cc/*
// @match https://ncore.pro/torrents.php*
// @match https://greatposterwall.com/torrents.php*
Expand All @@ -35,7 +35,7 @@
// @match https://torrentseeds.org/categories/*
// @match https://www.morethantv.me/torrents/browse*
// @match https://jpopsuki.eu/torrents.php*
// @match https://tntracker.org/*/?perPage=*
// @match https://tntracker.org/*
// @grant GM.xmlHttpRequest
// @grant GM.setValue
// @grant GM.getValue
Expand Down Expand Up @@ -391,7 +391,7 @@
};
const parseTorrentsFromTorrentsPage = () => {
const requests = [];
document.querySelectorAll('tr[id^="torrentposter"]').forEach((element => {
Array.from(document.querySelectorAll('tr[id^="torrentposter"]')).forEach((element => {
let imdbId = null;
let libraryId = element.getAttribute("library");
if (libraryId) {
Expand Down Expand Up @@ -419,7 +419,7 @@
}));
return requests;
};
const parseTorrentsFromMoviesPage = () => {
const parseTorrentsFromLibraryPage = () => {
const requests = [];
document.querySelectorAll(".bhd-meta-box").forEach((element => {
let imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseImdbIdFromLink)(element);
Expand All @@ -433,7 +433,7 @@
}));
return requests;
};
const isMoviesPage = () => window.location.href.includes("/movies");
const isLibraryPage = () => window.location.href.includes("/library");
const isTorrentsPage = () => window.location.href.includes("/torrents");
class BHD {
canBeUsedAsSource() {
Expand All @@ -447,7 +447,7 @@
}
async* getSearchRequest() {
let requests = [];
if (isMoviesPage()) requests = parseTorrentsFromMoviesPage(); else if (isTorrentsPage()) requests = parseTorrentsFromTorrentsPage();
if (isLibraryPage()) requests = parseTorrentsFromLibraryPage(); else if (isTorrentsPage()) requests = parseTorrentsFromTorrentsPage();
yield* (0, _tracker__WEBPACK_IMPORTED_MODULE_1__.toGenerator)(requests);
}
name() {
Expand Down
25 changes: 13 additions & 12 deletions Find Unique Titles/src/trackers/BHD.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
parseImdbIdFromLink,
parseResolution,
parseSize, parseTags
parseSize,
parseTags,
} from "../utils/utils";
import {
Category,
Expand Down Expand Up @@ -44,10 +45,9 @@ const parseCategory = (element: Element) => {
};

const parseTorrentsFromTorrentsPage = (): Array<Request> => {
const requests = [];
document
.querySelectorAll('tr[id^="torrentposter"]')
.forEach((element: HTMLElement) => {
const requests: Array<Request<any>> = [];
Array.from(document.querySelectorAll('tr[id^="torrentposter"]')).forEach(
(element) => {
let imdbId = null;
let libraryId = element.getAttribute("library");
if (libraryId) {
Expand All @@ -58,7 +58,7 @@ const parseTorrentsFromTorrentsPage = (): Array<Request> => {
}
const tags = [];
const torrentName =
element.children[1].querySelector('a[id^="torrent"]').textContent;
element.children[1].querySelector('a[id^="torrent"]')!!.textContent!!;
if (torrentName.toUpperCase().includes("REMUX")) {
tags.push("Remux");
}
Expand All @@ -78,11 +78,12 @@ const parseTorrentsFromTorrentsPage = (): Array<Request> => {
category: parseCategory(element),
};
requests.push(request);
});
}
);
return requests;
};

const parseTorrentsFromMoviesPage = (): Array<Request> => {
const parseTorrentsFromLibraryPage = (): Array<Request> => {
const requests: Array<Request> = [];
document.querySelectorAll(".bhd-meta-box").forEach((element) => {
let imdbId = parseImdbIdFromLink(element as HTMLElement);
Expand All @@ -98,8 +99,8 @@ const parseTorrentsFromMoviesPage = (): Array<Request> => {
return requests;
};

const isMoviesPage = () => {
return window.location.href.includes("/movies");
const isLibraryPage = () => {
return window.location.href.includes("/library");
};
const isTorrentsPage = () => {
return window.location.href.includes("/torrents");
Expand All @@ -120,8 +121,8 @@ export default class BHD implements tracker {

async *getSearchRequest(): AsyncGenerator<MetaData | Request, void, void> {
let requests: Array<Request> = [];
if (isMoviesPage()) {
requests = parseTorrentsFromMoviesPage();
if (isLibraryPage()) {
requests = parseTorrentsFromLibraryPage();
} else if (isTorrentsPage()) {
requests = parseTorrentsFromTorrentsPage();
}
Expand Down

0 comments on commit 560eb53

Please sign in to comment.