-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.ts
48 lines (38 loc) · 1.18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { getDomainName } from '../../utils/string_utils';
import BasePage from '../base_page';
class Animepahe extends BasePage {
constructor(hostname: string, pathname: string, document: Document) {
super(hostname, pathname, document);
const domainName = getDomainName(hostname);
this.providerName = domainName;
}
getTitle() {
const titleElement = this.document.getElementsByTagName('title')[0];
if (!titleElement) {
return '';
}
return titleElement.innerHTML.split('. Ep')[0];
}
getIdentifier() {
const [identifierScript] = Array.from(
this.document.getElementsByTagName('script')
).filter((script) => script.innerHTML.includes('getUrls'));
if (!identifierScript) {
return '';
}
const matches = identifierScript.innerHTML.match(/getUrls\((\d+)/);
if (!matches) {
return '';
}
return matches[1];
}
getRawEpisodeNumber() {
const episodeMenuButton = this.document.getElementById('episodeMenu');
if (!episodeMenuButton) {
return 0;
}
const episodeString = episodeMenuButton.innerHTML.split('Episode ')[1];
return parseInt(episodeString, 10);
}
}
export default Animepahe;