This repository was archived by the owner on Nov 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDridespoon.ts
More file actions
181 lines (165 loc) · 5.59 KB
/
Dridespoon.ts
File metadata and controls
181 lines (165 loc) · 5.59 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import {
Chapter,
ChapterDetails,
HomeSection,
LanguageCode,
Manga,
MangaStatus,
MangaTile,
MangaUpdates,
PagedResults,
Request,
RequestManager,
SearchRequest,
Source,
SourceInfo,
TagType,
} from "paperback-extensions-common"
import {DridespoonParser} from "./DridespoonParser";
const BASE = "http://dridesp.ooo"
export const DridespoonInfo: SourceInfo = {
icon: "icon.png",
version: "1.0.1",
name: "Dridespoon",
author: "PythonCoderAS",
authorWebsite: "https://github.com/PythonCoderAS",
description: "Extension that pulls manga from Dridespoon",
language: "en",
hentaiSource: false,
websiteBaseURL: BASE,
sourceTags: [
{
text: "Notifications",
type: TagType.GREEN
},
{
text: "Site Down Forever",
type: TagType.RED
},
{
text: "Deprecated - Will Not Be Updated",
type: TagType.RED
}
]
}
export class Dridespoon extends Source {
private readonly parser: DridespoonParser = new DridespoonParser();
readonly requestManager: RequestManager = createRequestManager({
requestsPerSecond: 5,
requestTimeout: 10000
});
getMangaShareUrl(mangaId: string): string {
return `${BASE}/n/${mangaId}`;
}
async getHomePageSections(sectionCallback: (section: HomeSection) => void): Promise<void> {
const options: Request = createRequestObject({
url: `${BASE}/n/`,
method: 'GET'
});
let response = await this.requestManager.schedule(options, 1);
let $ = this.cheerio.load(response.data);
sectionCallback(createHomeSection({
id: "1",
items: this.parser.parseMangaList($, BASE, "sfw"),
title: "Involvements"
}));
sectionCallback(createHomeSection({
id: "2",
items: this.parser.parseMangaList($, BASE, "collapseOne"),
title: "Past Involvements"
}));
sectionCallback(createHomeSection({
id: "3",
items: this.parser.parseMangaList($, BASE, "collapseThree"),
title: "Finished Projects"
}));
}
async getWebsiteMangaDirectory(metadata: any): Promise<PagedResults> {
const options: Request = createRequestObject({
url: `${BASE}/n/`,
method: 'GET'
});
let response = await this.requestManager.schedule(options, 1);
let $ = this.cheerio.load(response.data);
return createPagedResults({
results: this.parser.parseMangaList($, BASE, "main")
})
}
async getChapterDetails(mangaId: string, chapterId: string): Promise<ChapterDetails> {
let url = this.getMangaShareUrl(mangaId);
if (chapterId !== "Paperback-iOS-sentinel-id"){
url += "/" + chapterId
}
const options: Request = createRequestObject({
url: url,
method: 'GET'
});
let response = await this.requestManager.schedule(options, 1);
let $ = this.cheerio.load(response.data);
const pages = this.parser.parsePages($, BASE)
return createChapterDetails({
id: chapterId,
longStrip: false,
mangaId: mangaId,
pages: pages
})
}
async getChapters(mangaId: string): Promise<Chapter[]> {
const options: Request = createRequestObject({
url: this.getMangaShareUrl(mangaId),
method: 'GET'
});
let response = await this.requestManager.schedule(options, 1);
let $ = this.cheerio.load(response.data);
let parsedPages = this.parser.parsePages($, BASE);
if (parsedPages.length !== 0) {
return [createChapter({
chapNum: 1,
id: "Paperback-iOS-sentinel-id",
langCode: LanguageCode.ENGLISH,
mangaId: mangaId
})]
} else {
return this.parser.parseChapterList($, mangaId);
}
}
async getMangaDetails(mangaId: string): Promise<Manga> {
const options: Request = createRequestObject({
url: this.getMangaShareUrl(mangaId),
method: 'GET'
});
let response = await this.requestManager.schedule(options, 1);
let $ = this.cheerio.load(response.data);
let parsedPages = this.parser.parsePages($, BASE);
if (parsedPages.length !== 0){
return createManga({
id: mangaId,
image: parsedPages[0],
rating: 0,
status: MangaStatus.COMPLETED,
titles: [mangaId]
})
} else {
return this.parser.parseManga($, mangaId, BASE);
}
}
async searchRequest(query: SearchRequest, metadata: any): Promise<PagedResults> {
// TODO: Wait for search to be implemented on the website.
const results = (await this.getWebsiteMangaDirectory(null)).results;
const data: MangaTile[] = [];
for (let i = 0; i < results.length; i++) {
const key = results[i];
if (query.title) {
if ((key.title.text || "").toLowerCase().includes((query.title.toLowerCase()))) {
data.push(key);
}
}
}
return createPagedResults({
results: data
});
}
async filterUpdatedManga(mangaUpdatesFoundCallback: (updates: MangaUpdates) => void, time: Date, ids: string[]): Promise<void> {
mangaUpdatesFoundCallback(createMangaUpdates({ids: ids}));
}
}