Skip to content

Commit

Permalink
feat: adapt TIK-U3D
Browse files Browse the repository at this point in the history
(cherry picked from commit 0afaffd)
  • Loading branch information
Gawain12 authored and Morea committed Feb 4, 2024
1 parent 9cb8b92 commit fe51f09
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 92 deletions.
68 changes: 31 additions & 37 deletions Find Unique Titles/dist/find.unique.titles.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Find Unique Titles
// @description Find unique titles to cross seed
// @version 0.0.8
// @version 0.0.9
// @author Mea01
// @match https://cinemageddon.net/browse.php*
// @match https://karagarga.in/browse.php*
Expand Down Expand Up @@ -2496,55 +2496,36 @@
});
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_2__ = __webpack_require__("../common/dist/dom/index.mjs");
const findTorrentsTable = () => {
let tables = document.querySelectorAll("table");
for (let table of tables) {
let firstRow = table.querySelector("tr");
let cells = firstRow.querySelectorAll("td");
if (cells[0] && "Type" === cells[0].innerText && cells[1] && "Name" === cells[1].innerText && cells[2] && "Director" === cells[3].innerText) return table;
}
console.log("No torrents table found.");
return;
};
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");
var common_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../common/dist/dom/index.mjs");
class TiK {
canBeUsedAsSource() {
return true;
}
canBeUsedAsTarget() {
return false;
return true;
}
canRun(url) {
return url.includes("cinematik.net");
}
async* getSearchRequest() {
const torrentsTable = findTorrentsTable();
if (!torrentsTable) {
yield {
total: 0
};
return;
}
let nodes = torrentsTable.querySelectorAll("tr");
let elements = Array.from(document.querySelectorAll(".torrent-search--list__results tbody tr"));
yield {
total: nodes.length - 1
total: elements.length
};
for (let i = 1; i < nodes.length; i++) {
const element = nodes[i];
const link = element.querySelector('a[href*="details.php?id"]');
if (!link) continue;
let response = await fetchAndParseHtml(link.href);
const imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseImdbIdFromLink)(response);
const size = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseSize)(element.children[6].textContent);
for (let element of elements) {
let imdbId = "tt" + element.getAttribute("data-imdb-id");
let size = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseSize)(element.querySelector(".torrent-search--list__size").textContent);
const request = {
torrents: [ {
size,
tags: [],
dom: element
} ],
dom: [ element ],
dom: element,
imdbId,
title: ""
query: ""
};
yield request;
}
Expand All @@ -2553,13 +2534,17 @@
return "TiK";
}
async search(request) {
return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
if (!request.imdbId) return _tracker__WEBPACK_IMPORTED_MODULE_1__.SearchResult.NOT_CHECKED;
const result = await (0, common_searcher__WEBPACK_IMPORTED_MODULE_2__.search)(common_trackers__WEBPACK_IMPORTED_MODULE_3__.Tik, {
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) {
const stateSelect = document.getElementById("incldead");
const td = document.createElement("td");
td.appendChild(select);
(0, common_dom__WEBPACK_IMPORTED_MODULE_2__.insertBefore)(td, stateSelect.parentElement);
select.classList.add("form__select");
(0, common_dom__WEBPACK_IMPORTED_MODULE_4__.addChild)(document.querySelectorAll(".panel__actions")[1], select);
}
}
},
Expand Down Expand Up @@ -3212,7 +3197,8 @@
KG: () => KG,
MTV: () => MTV,
MTV_TV: () => MTV_TV,
TSeeds: () => TSeeds
TSeeds: () => TSeeds,
Tik: () => Tik
});
const Aither = {
name: "Aither",
Expand Down Expand Up @@ -3254,6 +3240,14 @@
positiveMatch: true,
TV: true
};
const Tik = {
name: "Tik",
searchUrl: "https://www.cinematik.net/browse.php?cat=0&incldead=1&srchdtls=1&search=%tt%",
loggedOutRegex: /Not logged in!|Ray ID/,
matchRegex: /Nothing found!/,
rateLimit: 125,
both: true
};
const TSeeds = {
name: "TSeeds",
searchUrl: "https://www.torrentseeds.org/torrents?tmdbId=%tmdbid%",
Expand Down
85 changes: 30 additions & 55 deletions Find Unique Titles/src/trackers/TiK.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,35 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
import { parseSize } from "../utils/utils";
import { MetaData, Request, SearchResult, tracker } from "./tracker";
import { insertBefore } from "common/dom";
import { search, SearchResult as SR } from "common/searcher";
import { Tik as TikTracker } from "common/trackers";
import { addChild } from "common/dom";

const findTorrentsTable = () => {
let tables = document.querySelectorAll("table");

for (let table of tables) {
let firstRow = table.querySelector("tr");
let cells = firstRow.querySelectorAll("td");

if (
cells[0] &&
cells[0].innerText === "Type" &&
cells[1] &&
cells[1].innerText === "Name" &&
cells[2] &&
cells[3].innerText === "Director"
) {
return table;
}
}
console.log("No torrents table found.");
return undefined;
};
export default class TiK implements tracker {
canBeUsedAsSource(): boolean {
return true;
}

canBeUsedAsTarget(): boolean {
return false;
return true;
}

canRun(url: string): boolean {
return url.includes("cinematik.net");
}

async *getSearchRequest(): AsyncGenerator<MetaData | Request, void, void> {
const torrentsTable = findTorrentsTable();
if (!torrentsTable) {
yield {
total: 0,
};
return;
}
let nodes = torrentsTable.querySelectorAll("tr");
let elements = Array.from(
document.querySelectorAll(".torrent-search--list__results tbody tr")
) as Array<HTMLElement>;
yield {
total: nodes.length - 1,
total: elements.length,
};
for (let i = 1; i < nodes.length; i++) {
const element = nodes[i];
const link: HTMLAnchorElement | null = element.querySelector(
'a[href*="details.php?id"]'
);
if (!link) {
continue;
}
let response = await fetchAndParseHtml(
(link as HTMLAnchorElement).href
);
const imdbId = parseImdbIdFromLink(response as HTMLElement);
const size = parseSize(element.children[6].textContent as string);
for (let element of elements) {
let imdbId = "tt" + element.getAttribute("data-imdb-id");

let size = parseSize(
element.querySelector(".torrent-search--list__size")!.textContent!
);
const request: Request = {
torrents: [
{
Expand All @@ -70,11 +38,11 @@ export default class TiK implements tracker {
dom: element,
},
],
dom: [element as HTMLElement],
dom: element,
imdbId,
title: "",
query: "",
};
yield request
yield request;
}
}

Expand All @@ -83,13 +51,20 @@ export default class TiK implements tracker {
}

async search(request: Request): Promise<SearchResult> {
return SearchResult.NOT_CHECKED;
if (!request.imdbId) return SearchResult.NOT_CHECKED;
const result = await search(TikTracker, {
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 {
const stateSelect = document.getElementById("incldead");
const td = document.createElement("td");
td.appendChild(select);
insertBefore(td, stateSelect.parentElement);
select.classList.add("form__select");
addChild(
document.querySelectorAll(".panel__actions")[1] as HTMLElement,
select
);
}
}
}

0 comments on commit fe51f09

Please sign in to comment.