Skip to content

Commit

Permalink
Add waiting time between search requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Morea committed Aug 25, 2024
1 parent 3c82563 commit 44a91cd
Show file tree
Hide file tree
Showing 36 changed files with 260 additions and 228 deletions.
291 changes: 151 additions & 140 deletions Find Unique Titles/dist/find.unique.titles.user.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Find Unique Titles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import "./settings";
import { getSettings } from "./settings";
import { appendErrorMessage, showError } from "common/dom";
import { sleep } from "common/http";
import { LEVEL, logger } from "common/logger";

function hideTorrents(request: Request) {
Expand Down Expand Up @@ -88,8 +89,9 @@ const main = async function () {
hideTorrents(request);
continue;
}
await sleep(targetTracker.waitTimeInMillisBetweenRequest());
const response = await targetTracker.search(request);
logger.debug("Search response: {0}", response)
logger.debug("Search response: {0}", response);
if (
response == SearchResult.EXIST ||
response == SearchResult.NOT_ALLOWED
Expand Down Expand Up @@ -143,7 +145,7 @@ const main = async function () {
}
}
} catch (e) {
console.trace("Error occurred: ", e)
console.trace("Error occurred: ", e);
logger.info("Error occurred when checking {0}, {1]", request, e);
request.dom[0].setAttribute(
"title",
Expand Down
5 changes: 2 additions & 3 deletions Find Unique Titles/src/trackers/Aither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import {
parseYearAndTitle,
} from "../utils/utils";
import {
AbstractTracker,
Category,
MetaData,
Request,
SearchResult,
toGenerator,
tracker,
} from "./tracker";
import { addChild, insertAfter } from "common/dom";
import { fetchAndParseHtml } from "common/http";
Expand All @@ -29,7 +28,7 @@ const parseCategory = (element: HTMLElement): Category | undefined => {

return undefined;
};
export default class Aither implements tracker {
export default class Aither extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/AvistaZ.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parseImdbIdFromLink, parseYearAndTitle } from "../utils/utils";
import { tracker, Request, MetaData, SearchResult, Category } from "./tracker";
import { Request, MetaData, SearchResult, Category, AbstractTracker } from "./tracker";
import { addChild } from "common/dom";
import { search, SearchResult as SR } from "common/searcher";
import { AT as ATTracker } from "common/trackers";

export default class AvistaZ implements tracker {
export default class AvistaZ extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions Find Unique Titles/src/trackers/BHD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SearchResult,
toGenerator,
Torrent,
tracker,
AbstractTracker,
} from "./tracker";
import { insertBefore } from "common/dom";
import { fetchAndParseHtml } from "common/http";
Expand All @@ -21,8 +21,8 @@ const parseTorrents = (element: HTMLElement): Array<Torrent> => {
element
.querySelectorAll('tr[id^="resulttorrent"]')
.forEach((torrentElement) => {
const data = torrentElement.children[0].textContent.trim().split("/");
const size = parseSize(torrentElement.children[4].textContent.trim());
const data = torrentElement.children[0]!!.textContent!!.trim().split("/");
const size = parseSize(torrentElement.children[4]!!.textContent!!.trim());
const tags = parseTags(torrentElement.textContent);
const torrent: Torrent = {
container: data[0].trim(),
Expand Down Expand Up @@ -106,7 +106,7 @@ const isTorrentsPage = () => {
return window.location.href.includes("/torrents");
};

export default class BHD implements tracker {
export default class BHD extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/BLU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
Request,
SearchResult,
toGenerator,
tracker,
AbstractTracker,
} from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";

export default class BLU implements tracker {
export default class BLU extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/BTarg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseImdbId, parseSize } from "../utils/utils";
import { Category, MetaData, Request, SearchResult, tracker } from "./tracker";
import { Category, MetaData, Request, SearchResult, AbstractTracker } from "./tracker";
import { insertAfter } from "common/dom";
import { fetchAndParseHtml } from "common/http";

Expand All @@ -12,7 +12,7 @@ const parseCategory = (element: HTMLElement) => {
return Category.OTHER;
};

export default class BTarg implements tracker {
export default class BTarg extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/CG.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
import { Category, MetaData, Request, Resolution, SearchResult, toGenerator, tracker } from "./tracker";
import { Category, MetaData, Request, Resolution, SearchResult, toGenerator, AbstractTracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";

Expand Down Expand Up @@ -39,7 +39,7 @@ function parseTorrents(element: HTMLElement) {
];
}

export default class CG implements tracker {
export default class CG extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
26 changes: 10 additions & 16 deletions Find Unique Titles/src/trackers/CHD.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import {
parseImdbIdFromLink,
parseSize,
parseTags,
parseYearAndTitle,
} from "../utils/utils";
import {
MetaData,
MovieRequest,
Request,
SearchResult,
tracker,
} from "./tracker";
import { parseImdbIdFromLink, parseSize, parseTags, parseYearAndTitle } from "../utils/utils";
import { MetaData, MovieRequest, Request, SearchResult, AbstractTracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
import { search } from "common/searcher";
import { CHD as CHDTracker } from "common/trackers";
import { SearchResult as SR } from "common/searcher";
import { CHD as CHDTracker } from "common/trackers";

export default class CHD implements tracker {

export default class CHD extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down Expand Up @@ -98,4 +88,8 @@ export default class CHD implements tracker {
.children[2].querySelector("td td.rowfollow tr");
addChild(element as HTMLElement, select);
}
}

waitTimeInMillisBetweenRequest(): number {
return 5000;
}
}
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/CLAN-SUD.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { parseImdbIdFromLink, parseResolution, parseYearAndTitle } from "../utils/utils";
import { MetaData, Request, SearchResult, tracker, Category } from "./tracker";
import { MetaData, Request, SearchResult, Category, AbstractTracker } from "./tracker";
import { insertBefore } from "common/dom";
import { fetchAndParseHtml } from "common/http";

export default class CLANSUD implements tracker {
export default class CLANSUD extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/CinemaZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
Request,
MetaData,
SearchResult,
Category,
Category, AbstractTracker
} from "./tracker";
import { addChild } from "common/dom";
import { search, SearchResult as SR } from "common/searcher";
import { CZ as CZTracker } from "common/trackers";

export default class CinemaZ implements tracker {
export default class CinemaZ extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
5 changes: 2 additions & 3 deletions Find Unique Titles/src/trackers/FL.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
import { tracker, Request, MetaData, SearchResult } from "./tracker";
import { Request, MetaData, SearchResult, AbstractTracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
import url from "url";

export default class FL implements tracker {
export default class FL extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/GPW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
SearchResult,
toGenerator,
Torrent,
tracker,
AbstractTracker,
} from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";

export default class GPW implements tracker {
export default class GPW extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/HDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Request,
SearchResult,
Torrent,
tracker,
AbstractTracker,
} from "./tracker";
import { addChild } from "common/dom";
import { logger } from "common/logger";
Expand Down Expand Up @@ -66,7 +66,7 @@ function parseCategory(element: HTMLElement) {
}
}

export default class HDB implements tracker {
export default class HDB extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/HDSky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
MovieRequest,
Request,
SearchResult,
tracker,
AbstractTracker,
} from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";

export default class HDSky implements tracker {
export default class HDSky extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/HDT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
Request,
SearchResult,
toGenerator,
tracker,
AbstractTracker,
} from "./tracker";
import { addChild } from "common/dom";

export default class HDT implements tracker {
export default class HDT extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/IPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
MusicReleaseType,
Request,
SearchResult,
tracker,
AbstractTracker,
} from "./tracker";
import { insertAfter } from "common/dom";
import { fetchAndParseHtml } from "common/http";
Expand All @@ -27,7 +27,7 @@ const parseCategory = (element: HTMLElement): Category => {
if (categoryLogo.includes("TV-")) return Category.TV;
if (categoryLogo.includes("Music-")) return Category.MUSIC;
};
export default class CG implements tracker {
export default class CG extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/JPTV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
Request,
SearchResult,
toGenerator,
tracker,
AbstractTracker,
} from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";

export default class JPTV implements tracker {
export default class JPTV extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/JPop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseContainerAndFormat, parseSize } from "../utils/utils";
import { Category, MetaData, MusicReleaseType, MusicRequest, Request, SearchResult, Torrent, tracker } from "./tracker";
import { Category, MetaData, MusicReleaseType, MusicRequest, Request, SearchResult, Torrent, AbstractTracker } from "./tracker";
import { insertBefore } from "common/dom";


Expand Down Expand Up @@ -70,7 +70,7 @@ const parseAlbum = (element: Element): string[] => {

return Array.from(titles);
};
export default class JPop implements tracker {
export default class JPop extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/KG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Resolution,
SearchResult,
Torrent,
tracker,
AbstractTracker,
} from "./tracker";
import { insertBefore } from "common/dom";
import { search, SearchResult as SR } from "common/searcher";
Expand Down Expand Up @@ -56,7 +56,7 @@ const parseTorrent = (element: HTMLElement): Array<Torrent> => {
return torrents;
};

export default class KG implements tracker {
export default class KG extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/LatTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
parseTags,
parseYearAndTitle,
} from "../utils/utils";
import { Category, MetaData, Request, SearchResult, tracker } from "./tracker";
import { Category, MetaData, Request, SearchResult, AbstractTracker } from "./tracker";
import { addChild } from "common/dom";

const parseCategory = (element: Element) => {
Expand All @@ -16,7 +16,7 @@ const parseCategory = (element: Element) => {

return Category.OTHER;
};
export default class LatTeam implements tracker {
export default class LatTeam extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions Find Unique Titles/src/trackers/MTV.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseImdbIdFromLink, parseSize } from "../utils/utils";
import { Category, MetaData, Request, SearchResult, tracker } from "./tracker";
import { Category, MetaData, Request, SearchResult, AbstractTracker } from "./tracker";
import { addChild } from "common/dom";
import { fetchAndParseHtml } from "common/http";
import { search, SearchResult as SC } from "common/searcher";
Expand Down Expand Up @@ -31,7 +31,7 @@ const parseYearAndTitle = (
return { title: undefined, year: undefined };
};

export default class MTV implements tracker {
export default class MTV extends AbstractTracker {
canBeUsedAsSource(): boolean {
return true;
}
Expand Down
Loading

0 comments on commit 44a91cd

Please sign in to comment.