-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Morea
committed
Aug 24, 2024
1 parent
cf071e0
commit 7774e21
Showing
5 changed files
with
203 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
parseCodec, | ||
parseResolution, | ||
parseSize, | ||
parseTags, | ||
parseYearAndTitle, | ||
} from "../utils/utils"; | ||
import { Category, MetaData, Request, SearchResult, tracker } from "./tracker"; | ||
import { addChild } from "common/dom"; | ||
|
||
const parseCategory = (element: Element) => { | ||
const icon = element.querySelector(".torrent-search--list__category i"); | ||
if (!icon) return Category.OTHER; | ||
if (icon?.classList.contains("fa-film")) return Category.MOVIE; | ||
if (icon?.classList.contains("fa-tv-retro")) return Category.TV; | ||
|
||
return Category.OTHER; | ||
}; | ||
export default class LatTeam implements tracker { | ||
canBeUsedAsSource(): boolean { | ||
return true; | ||
} | ||
|
||
canBeUsedAsTarget(): boolean { | ||
return false; | ||
} | ||
|
||
canRun(url: string): boolean { | ||
return url.includes("lat-team.com"); | ||
} | ||
|
||
async *getSearchRequest(): AsyncGenerator<MetaData | Request, void, void> { | ||
const rows = document.querySelectorAll( | ||
".torrent-search--list__results tbody tr" | ||
); | ||
let elements = Array.from(rows); | ||
yield { | ||
total: elements.length, | ||
}; | ||
for (let element of elements) { | ||
const imdbId = element.getAttribute("data-imdb-id"); | ||
let fullTitle = element | ||
.querySelector("a.torrent-search--list__name") | ||
?.textContent?.trim(); | ||
const { title, year } = parseYearAndTitle(fullTitle); | ||
const size = parseSize( | ||
element | ||
.querySelector(".torrent-search--list__size") | ||
?.textContent?.trim() | ||
); | ||
const tags = parseTags(fullTitle); | ||
const category = parseCategory(element); | ||
const resolution = parseResolution( | ||
element | ||
.querySelector(".torrent-search--list__resolution") | ||
?.textContent?.trim() | ||
); | ||
|
||
const request: Request = { | ||
torrents: [ | ||
{ | ||
dom: element, | ||
size, | ||
tags, | ||
resolution, | ||
container: parseCodec(fullTitle), | ||
}, | ||
], | ||
dom: [element], | ||
imdbId, | ||
title, | ||
year, | ||
category, | ||
}; | ||
yield request; | ||
} | ||
} | ||
|
||
name(): string { | ||
return "LatTeam"; | ||
} | ||
|
||
insertTrackersSelect(select: HTMLElement): void { | ||
select.classList.add("form__select"); | ||
select.style.width = "180px"; | ||
addChild( | ||
document.querySelector( | ||
".panelV2.torrent-search__results .panel__actions" | ||
) as HTMLElement, | ||
select | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters