-
Notifications
You must be signed in to change notification settings - Fork 3
/
List.ts
31 lines (29 loc) · 869 Bytes
/
List.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
import { IListData, IDoujinInfo } from '../../Types'
import axios from 'axios'
import { load } from 'cheerio'
import { parseDoujinInfo } from '../../Parser'
export class List implements IListData {
constructor(
public title: string,
public id: string,
public cover: string | null,
public url: IListData['url']
) {}
/**
* Gets the contents of a doujin
* @returns The contents of the doujin
*/
public async getContents(): Promise<IDoujinInfo> {
return await axios
.get<string>(this.url)
.then(({ data }) =>
parseDoujinInfo(
load(data),
this.url.split('nhentai.')[1].split('/')[0] as 'to'
)
)
.catch((err) => {
throw new Error(err.message)
})
}
}