multporn-api-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,233 @@
1
+ type ListingItem = {
2
+ title: string;
3
+ url: string;
4
+ thumb?: string;
5
+ proxiedThumb?: string;
6
+ };
7
+ type ExposedOption = {
8
+ value: string;
9
+ label: string;
10
+ selected?: boolean;
11
+ };
12
+ type ExposedSelect = {
13
+ name: string;
14
+ label?: string;
15
+ options: ExposedOption[];
16
+ };
17
+ interface SortingUI {
18
+ actionPath: string;
19
+ selects: ExposedSelect[];
20
+ appliedParams: Record<string, string>;
21
+ }
22
+ type Page<T> = {
23
+ page: number;
24
+ items: T[];
25
+ hasNext: boolean;
26
+ totalPages?: number;
27
+ pageSize?: number;
28
+ alphabet?: AlphabetBlock;
29
+ sorting?: SortingUI;
30
+ };
31
+ type Post = {
32
+ title: string;
33
+ url: string;
34
+ images: string[];
35
+ tags: string[];
36
+ author: string | null;
37
+ };
38
+ type ViewName = 'new_mini' | 'user_upload_front' | 'updated_manga' | 'updated_manga_promoted' | 'updated_games' | 'random_top_comics' | 'top_random_characters';
39
+ type UpdatesResult = {
40
+ items: ListingItem[];
41
+ first: number;
42
+ last: number;
43
+ html: string;
44
+ viewName: string;
45
+ };
46
+ type MultpornUpdatesParams = {
47
+ first?: number;
48
+ last?: number;
49
+ view_args?: string;
50
+ view_path?: string;
51
+ view_base_path?: string;
52
+ view_display_id?: string;
53
+ view_name?: ViewName | string;
54
+ jcarousel_dom_id?: string | number;
55
+ };
56
+ type ResolvedListingRoute = {
57
+ route: 'listing';
58
+ data: Page<ListingItem> & {
59
+ absoluteUrl: string;
60
+ path: string;
61
+ };
62
+ };
63
+ type ResolvedViewerRoute = {
64
+ route: 'viewer';
65
+ data: {
66
+ absoluteUrl: string;
67
+ viewer: {
68
+ kind: 'images' | 'video' | 'other';
69
+ images?: Array<{
70
+ original?: string;
71
+ large?: string;
72
+ medium?: string;
73
+ small?: string;
74
+ thumb?: string;
75
+ proxied?: string;
76
+ }>;
77
+ video?: {
78
+ poster?: string;
79
+ sources: Array<{
80
+ url?: string;
81
+ proxied?: string;
82
+ type?: string;
83
+ label?: string;
84
+ }>;
85
+ };
86
+ meta?: Record<string, unknown>;
87
+ };
88
+ recommendations?: ListingItem[];
89
+ };
90
+ };
91
+ type ResolvedRoute = ResolvedListingRoute | ResolvedViewerRoute;
92
+ type AlphabetSection = 'comics' | 'category_comic' | 'characters' | 'authors_comics' | 'pipictures' | 'porn_gifs' | 'manga' | 'authors_hentai';
93
+ type AlphabetLetter = {
94
+ label: string;
95
+ value: string;
96
+ href: string;
97
+ count?: number;
98
+ active?: boolean;
99
+ };
100
+ interface AlphabetBlock {
101
+ section: string;
102
+ letters: AlphabetLetter[];
103
+ }
104
+ type LinkItem = {
105
+ title: string;
106
+ url: string;
107
+ };
108
+ type ViewerKind = 'manga' | 'comics' | 'pictures' | 'humor' | 'video' | 'game' | 'other' | 'images';
109
+ interface ViewerImage {
110
+ original: string;
111
+ large?: string;
112
+ medium?: string;
113
+ small?: string;
114
+ thumb?: string;
115
+ proxied?: string;
116
+ }
117
+ interface ViewerVideoSource {
118
+ url: string;
119
+ type?: string;
120
+ label?: string;
121
+ proxied?: string;
122
+ }
123
+ interface ViewerVideo {
124
+ poster?: string;
125
+ sources: ViewerVideoSource[];
126
+ }
127
+ interface ViewerMeta {
128
+ nodeId: number | null;
129
+ fieldSys: string | null;
130
+ title: string;
131
+ kind: ViewerKind;
132
+ breadcrumbs: LinkItem[];
133
+ authors: LinkItem[];
134
+ sections: LinkItem[];
135
+ tags: LinkItem[];
136
+ characters: LinkItem[];
137
+ userTags: LinkItem[];
138
+ rating?: number;
139
+ votes?: number;
140
+ views?: number;
141
+ related?: LinkItem[];
142
+ }
143
+ interface ViewerResult {
144
+ kind: ViewerKind;
145
+ meta: ViewerMeta;
146
+ images?: ViewerImage[];
147
+ video?: ViewerVideo;
148
+ }
149
+ type ListingPayload = {
150
+ page: Page<ListingItem>;
151
+ absoluteUrl: string;
152
+ path: string;
153
+ title?: string;
154
+ breadcrumbs?: LinkItem[];
155
+ };
156
+ type ViewerPayload = {
157
+ viewer: ViewerResult;
158
+ absoluteUrl: string;
159
+ path: string;
160
+ recommendations?: ListingItem[];
161
+ };
162
+ interface ResolveOptions {
163
+ proxyImage?: (url: string) => string;
164
+ proxyVideo?: (url: string) => string;
165
+ signal?: AbortSignal;
166
+ }
167
+ type ListingQuery = Record<string, string | number | boolean | undefined>;
168
+
169
+ type RetryPolicy = {
170
+ retries: number;
171
+ factor: number;
172
+ minDelayMs: number;
173
+ maxDelayMs: number;
174
+ retryOn: (status?: number) => boolean;
175
+ };
176
+ declare const defaultRetryPolicy: RetryPolicy;
177
+ declare class HttpError extends Error {
178
+ status?: number | undefined;
179
+ constructor(message: string, status?: number | undefined);
180
+ }
181
+ type HttpClientOptions = {
182
+ baseURL: string;
183
+ headers?: Record<string, string>;
184
+ timeoutMs?: number;
185
+ retry?: Partial<RetryPolicy>;
186
+ userAgent?: string;
187
+ };
188
+ declare class HttpClient {
189
+ private baseURL;
190
+ private headers;
191
+ private timeoutMs;
192
+ private retry;
193
+ private userAgent;
194
+ constructor(opts: HttpClientOptions);
195
+ private buildURL;
196
+ getHtml(pathOrUrl: string, attempt?: number): Promise<string>;
197
+ getJson<T = any>(pathOrUrl: string, attempt?: number): Promise<T>;
198
+ postForm<T = any>(pathOrUrl: string, form: Record<string, string | string[]>, attempt?: number): Promise<T>;
199
+ }
200
+
201
+ declare function parseHubListing(html: string, baseURL: string, page: number): Page<ListingItem>;
202
+
203
+ declare function parsePost(html: string, baseURL: string, url: string): Post;
204
+
205
+ type MultpornClientOptions = Omit<HttpClientOptions, 'baseURL'> & {
206
+ baseURL?: string;
207
+ };
208
+ declare class MultpornClient {
209
+ private http;
210
+ private baseURL;
211
+ constructor(opts?: MultpornClientOptions);
212
+ latest(page?: number, params?: ListingQuery): Promise<Page<ListingItem>>;
213
+ listByPath(path: string, page?: number, params?: ListingQuery & {
214
+ letter?: string;
215
+ }): Promise<Page<ListingItem>>;
216
+ search(query: string, page?: number): Promise<Page<ListingItem>>;
217
+ getPost(urlOrSlug: string): Promise<Post>;
218
+ resolve(urlOrSlug: string, opts?: ResolveOptions): Promise<ViewerResult>;
219
+ resolveSmart(urlOrSlug: string, opts?: ResolveOptions): Promise<ResolvedRoute>;
220
+ updates(params?: MultpornUpdatesParams): Promise<UpdatesResult>;
221
+ viewUpdates(viewName: ViewName, params?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
222
+ updatesNewMini(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
223
+ userUploadFront(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
224
+ updatedManga(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
225
+ updatedMangaPromoted(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
226
+ updatedGames(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
227
+ randomTopComics(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
228
+ topRandomCharacters(p?: Omit<MultpornUpdatesParams, 'view_name'>): Promise<UpdatesResult>;
229
+ alphabetLetters(section: AlphabetSection): Promise<AlphabetLetter[]>;
230
+ alphabet(section: AlphabetSection, letter: string, page?: number): Promise<Page<ListingItem>>;
231
+ }
232
+
233
+ export { type AlphabetBlock, type AlphabetLetter, type AlphabetSection, type ExposedOption, type ExposedSelect, HttpClient, type HttpClientOptions, HttpError, type LinkItem, type ListingItem, type ListingPayload, type ListingQuery, MultpornClient, type MultpornClientOptions, type MultpornUpdatesParams, type Page, type Post, type ResolveOptions, type ResolvedListingRoute, type ResolvedRoute, type ResolvedViewerRoute, type RetryPolicy, type SortingUI, type UpdatesResult, type ViewName, type ViewerImage, type ViewerKind, type ViewerMeta, type ViewerPayload, type ViewerResult, type ViewerVideo, type ViewerVideoSource, defaultRetryPolicy, parseHubListing as parseListing, parsePost };