anixapi 0.2.1

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.
Files changed (164) hide show
  1. package/LICENSE +339 -0
  2. package/README.md +165 -0
  3. package/dist/api/auth.d.ts +129 -0
  4. package/dist/api/auth.js +156 -0
  5. package/dist/api/bookmarks/export.d.ts +19 -0
  6. package/dist/api/bookmarks/export.js +24 -0
  7. package/dist/api/bookmarks/import.d.ts +29 -0
  8. package/dist/api/bookmarks/import.js +36 -0
  9. package/dist/api/bookmarks/index.d.ts +2 -0
  10. package/dist/api/bookmarks/index.js +18 -0
  11. package/dist/api/channel/article.d.ts +119 -0
  12. package/dist/api/channel/article.js +144 -0
  13. package/dist/api/channel/articleComment.d.ts +119 -0
  14. package/dist/api/channel/articleComment.js +144 -0
  15. package/dist/api/channel/articleSuggestion.d.ts +69 -0
  16. package/dist/api/channel/articleSuggestion.js +84 -0
  17. package/dist/api/channel/channel.d.ts +249 -0
  18. package/dist/api/channel/channel.js +300 -0
  19. package/dist/api/channel/index.d.ts +4 -0
  20. package/dist/api/channel/index.js +20 -0
  21. package/dist/api/collection/collection.d.ts +59 -0
  22. package/dist/api/collection/collection.js +72 -0
  23. package/dist/api/collection/collectionComment.d.ts +109 -0
  24. package/dist/api/collection/collectionComment.js +132 -0
  25. package/dist/api/collection/collectionFavorite.d.ts +39 -0
  26. package/dist/api/collection/collectionFavorite.js +48 -0
  27. package/dist/api/collection/collectionMy.d.ts +69 -0
  28. package/dist/api/collection/collectionMy.js +84 -0
  29. package/dist/api/collection/index.d.ts +4 -0
  30. package/dist/api/collection/index.js +20 -0
  31. package/dist/api/config.d.ts +29 -0
  32. package/dist/api/config.js +36 -0
  33. package/dist/api/discover.d.ts +59 -0
  34. package/dist/api/discover.js +72 -0
  35. package/dist/api/feed.d.ts +39 -0
  36. package/dist/api/feed.js +48 -0
  37. package/dist/api/index.d.ts +12 -0
  38. package/dist/api/index.js +28 -0
  39. package/dist/api/notification/index.d.ts +2 -0
  40. package/dist/api/notification/index.js +18 -0
  41. package/dist/api/notification/notification.d.ts +199 -0
  42. package/dist/api/notification/notification.js +240 -0
  43. package/dist/api/notification/notificationPreference.d.ts +159 -0
  44. package/dist/api/notification/notificationPreference.js +192 -0
  45. package/dist/api/profile/index.d.ts +10 -0
  46. package/dist/api/profile/index.js +26 -0
  47. package/dist/api/profile/profile.d.ts +65 -0
  48. package/dist/api/profile/profile.js +80 -0
  49. package/dist/api/profile/profileBadge.d.ts +39 -0
  50. package/dist/api/profile/profileBadge.js +48 -0
  51. package/dist/api/profile/profileBlockList.d.ts +39 -0
  52. package/dist/api/profile/profileBlockList.js +48 -0
  53. package/dist/api/profile/profileDeletion.d.ts +39 -0
  54. package/dist/api/profile/profileDeletion.js +48 -0
  55. package/dist/api/profile/profileFriend.d.ts +99 -0
  56. package/dist/api/profile/profileFriend.js +120 -0
  57. package/dist/api/profile/profileHealth.d.ts +59 -0
  58. package/dist/api/profile/profileHealth.js +72 -0
  59. package/dist/api/profile/profileList.d.ts +49 -0
  60. package/dist/api/profile/profileList.js +60 -0
  61. package/dist/api/profile/profilePreference.d.ts +239 -0
  62. package/dist/api/profile/profilePreference.js +288 -0
  63. package/dist/api/profile/profileReleaseVote.d.ts +39 -0
  64. package/dist/api/profile/profileReleaseVote.js +48 -0
  65. package/dist/api/profile/profileRoleList.d.ts +19 -0
  66. package/dist/api/profile/profileRoleList.js +24 -0
  67. package/dist/api/release/episode.d.ts +99 -0
  68. package/dist/api/release/episode.js +120 -0
  69. package/dist/api/release/favorite.d.ts +39 -0
  70. package/dist/api/release/favorite.js +48 -0
  71. package/dist/api/release/filter.d.ts +19 -0
  72. package/dist/api/release/filter.js +24 -0
  73. package/dist/api/release/history.d.ts +39 -0
  74. package/dist/api/release/history.js +48 -0
  75. package/dist/api/release/index.d.ts +13 -0
  76. package/dist/api/release/index.js +29 -0
  77. package/dist/api/release/related.d.ts +19 -0
  78. package/dist/api/release/related.js +24 -0
  79. package/dist/api/release/release.d.ts +79 -0
  80. package/dist/api/release/release.js +96 -0
  81. package/dist/api/release/releaseComment.d.ts +109 -0
  82. package/dist/api/release/releaseComment.js +132 -0
  83. package/dist/api/release/releaseStreamingPlatform.d.ts +19 -0
  84. package/dist/api/release/releaseStreamingPlatform.js +24 -0
  85. package/dist/api/release/releaseVideo.d.ts +59 -0
  86. package/dist/api/release/releaseVideo.js +72 -0
  87. package/dist/api/release/releaseVideoAppeal.d.ts +49 -0
  88. package/dist/api/release/releaseVideoAppeal.js +60 -0
  89. package/dist/api/release/releaseVideoFavorite.d.ts +39 -0
  90. package/dist/api/release/releaseVideoFavorite.js +48 -0
  91. package/dist/api/release/schedule.d.ts +19 -0
  92. package/dist/api/release/schedule.js +24 -0
  93. package/dist/api/release/type.d.ts +39 -0
  94. package/dist/api/release/type.js +48 -0
  95. package/dist/api/report.d.ts +189 -0
  96. package/dist/api/report.js +228 -0
  97. package/dist/api/search.d.ts +129 -0
  98. package/dist/api/search.js +156 -0
  99. package/dist/classes/Article.d.ts +18 -0
  100. package/dist/classes/Article.js +44 -0
  101. package/dist/classes/ArticleComment.d.ts +15 -0
  102. package/dist/classes/ArticleComment.js +37 -0
  103. package/dist/classes/BaseArticle.d.ts +21 -0
  104. package/dist/classes/BaseArticle.js +23 -0
  105. package/dist/classes/BaseComment.d.ts +22 -0
  106. package/dist/classes/BaseComment.js +25 -0
  107. package/dist/classes/BaseProfile.d.ts +29 -0
  108. package/dist/classes/BaseProfile.js +52 -0
  109. package/dist/classes/Channel.d.ts +47 -0
  110. package/dist/classes/Channel.js +108 -0
  111. package/dist/classes/Collection.d.ts +29 -0
  112. package/dist/classes/Collection.js +58 -0
  113. package/dist/classes/Dubber.d.ts +19 -0
  114. package/dist/classes/Dubber.js +24 -0
  115. package/dist/classes/Episode.d.ts +20 -0
  116. package/dist/classes/Episode.js +30 -0
  117. package/dist/classes/FullProfile.d.ts +70 -0
  118. package/dist/classes/FullProfile.js +92 -0
  119. package/dist/classes/Release.d.ts +91 -0
  120. package/dist/classes/Release.js +150 -0
  121. package/dist/classes/ReleaseComment.d.ts +16 -0
  122. package/dist/classes/ReleaseComment.js +45 -0
  123. package/dist/classes/Source.d.ts +15 -0
  124. package/dist/classes/Source.js +20 -0
  125. package/dist/classes/SuggestionArticle.d.ts +14 -0
  126. package/dist/classes/SuggestionArticle.js +30 -0
  127. package/dist/client.d.ts +49 -0
  128. package/dist/client.js +183 -0
  129. package/dist/endpoints.d.ts +63 -0
  130. package/dist/endpoints.js +67 -0
  131. package/dist/errors.d.ts +37 -0
  132. package/dist/errors.js +122 -0
  133. package/dist/index.d.ts +5 -0
  134. package/dist/index.js +23 -0
  135. package/dist/types/auth.d.ts +127 -0
  136. package/dist/types/auth.js +47 -0
  137. package/dist/types/channel.d.ts +350 -0
  138. package/dist/types/channel.js +104 -0
  139. package/dist/types/collection.d.ts +105 -0
  140. package/dist/types/collection.js +44 -0
  141. package/dist/types/config.d.ts +41 -0
  142. package/dist/types/config.js +4 -0
  143. package/dist/types/index.d.ts +13 -0
  144. package/dist/types/index.js +26 -0
  145. package/dist/types/notification.d.ts +81 -0
  146. package/dist/types/notification.js +2 -0
  147. package/dist/types/profile.d.ts +339 -0
  148. package/dist/types/profile.js +46 -0
  149. package/dist/types/release.d.ts +467 -0
  150. package/dist/types/release.js +39 -0
  151. package/dist/types/request.d.ts +138 -0
  152. package/dist/types/request.js +2 -0
  153. package/dist/types/response.d.ts +104 -0
  154. package/dist/types/response.js +35 -0
  155. package/dist/types/settings.d.ts +119 -0
  156. package/dist/types/settings.js +48 -0
  157. package/dist/utils/ArticleBuilder.d.ts +38 -0
  158. package/dist/utils/ArticleBuilder.js +144 -0
  159. package/dist/utils/LinkParser.d.ts +253 -0
  160. package/dist/utils/LinkParser.js +253 -0
  161. package/dist/utils/Utils.d.ts +3 -0
  162. package/dist/utils/Utils.js +11 -0
  163. package/docs/DOCUMENTATION.md +290 -0
  164. package/package.json +55 -0
@@ -0,0 +1,253 @@
1
+ /**
2
+ * Парсер различных источников
3
+ */
4
+ /**
5
+ * KodikParser
6
+ * Парсер источника Kodik
7
+ * Большая часть кода основана на KodikWrapper (https://github.com/thedvxchsquad/kodikwrapper/blob/master/src/video-links.ts)
8
+ */
9
+ /**
10
+ * Качество
11
+ */
12
+ export type KodikQuality = '240' | '360' | '480' | '720' | '1080' | string;
13
+ export interface KodikVideoSource {
14
+ src: string;
15
+ type: string;
16
+ }
17
+ export type KodikVideoLinks = Record<KodikQuality, KodikVideoSource[]>;
18
+ export interface KodikVast {
19
+ title_small: string;
20
+ src: string;
21
+ timer?: number;
22
+ hide_interface?: boolean;
23
+ async_load?: boolean;
24
+ vpaid_target_event?: string;
25
+ vpaid_max_load_time?: number;
26
+ vpaid_max_start_time?: number;
27
+ vpaid_start_event?: string;
28
+ vpaid_timer_start_event?: string;
29
+ vpaid_ad_skippable_state?: boolean;
30
+ advert_id?: string;
31
+ save_views?: boolean;
32
+ start_muted?: boolean;
33
+ max_length?: number;
34
+ disable_advert_click?: number;
35
+ send_stat_method?: string;
36
+ stop_timer_on_pause?: boolean;
37
+ }
38
+ export interface KodikDirectLinkResponse {
39
+ advert_script: string;
40
+ domain: string;
41
+ default: number;
42
+ links: KodikVideoLinks;
43
+ vast: KodikVast[];
44
+ reserve_vast: KodikVast[];
45
+ ip: string;
46
+ }
47
+ export declare class KodikParser {
48
+ private static _baseKodikDomain;
49
+ private static _endpointUrl;
50
+ static getLatestLink(url: string): Promise<string | null>;
51
+ static getDirectLinks(url: string, endpointPath?: string): Promise<KodikVideoLinks | null>;
52
+ }
53
+ /**
54
+ * AniLibriaParser
55
+ * Парсер источника Libria
56
+ */
57
+ /**
58
+ * Тайтл
59
+ */
60
+ export interface AniLibriaAnime {
61
+ id: number;
62
+ type: {
63
+ value: string;
64
+ description: string;
65
+ };
66
+ year: number;
67
+ name: {
68
+ main: string;
69
+ english: string;
70
+ alternative: string;
71
+ };
72
+ alias: string;
73
+ season: {
74
+ value: string;
75
+ description: string;
76
+ };
77
+ poster: {
78
+ src: string;
79
+ preview: string;
80
+ thumbnail: string;
81
+ optimized: {
82
+ src: string;
83
+ preview: string;
84
+ thumbnail: string;
85
+ };
86
+ };
87
+ fresh_at: string;
88
+ created_at: string;
89
+ updated_at: string;
90
+ is_ongoing: boolean;
91
+ age_rating: {
92
+ value: string;
93
+ description: string;
94
+ label: string;
95
+ is_adult: boolean;
96
+ };
97
+ publish_day: {
98
+ value: string;
99
+ description: string;
100
+ };
101
+ description: string;
102
+ notification: any;
103
+ episodes_count: number | null;
104
+ external_player: any;
105
+ is_in_production: boolean;
106
+ is_blocked_by_geo: boolean;
107
+ is_blocked_by_copyrights: boolean;
108
+ added_in_users_favorites: number;
109
+ average_duration_of_episode: any;
110
+ added_in_planned_collection: number;
111
+ added_in_watched_collection: number;
112
+ added_in_watching_collection: number;
113
+ added_in_postponed_collection: number;
114
+ added_in_abandoned_collection: number;
115
+ genres: AniLibriaGenre[];
116
+ members: AniLibriaMember[];
117
+ sponsor: {
118
+ id: string;
119
+ title: string;
120
+ description: string;
121
+ url_title: string;
122
+ url: string;
123
+ };
124
+ episodes: AniLibriaEpisode[];
125
+ }
126
+ /**
127
+ * Жанр
128
+ */
129
+ export interface AniLibriaGenre {
130
+ id: number;
131
+ name: string;
132
+ image: {
133
+ preview: string;
134
+ thumbnail: string;
135
+ optimized: {
136
+ preview: string;
137
+ thumbnail: string;
138
+ };
139
+ };
140
+ total_releases: number;
141
+ }
142
+ /**
143
+ * Участник Anilibria
144
+ */
145
+ export interface AniLibriaMember {
146
+ id: string;
147
+ role: {
148
+ value: string;
149
+ description: string;
150
+ };
151
+ nickname: string;
152
+ user: any;
153
+ }
154
+ /**
155
+ * Эпизод
156
+ */
157
+ export interface AniLibriaEpisode {
158
+ id: string;
159
+ name: string | null;
160
+ ordinal: number;
161
+ opening: {
162
+ stop: number | null;
163
+ start: number | null;
164
+ };
165
+ ending: {
166
+ stop: number | null;
167
+ start: number | null;
168
+ };
169
+ preview: {
170
+ src: string;
171
+ preview: string;
172
+ thumbnail: string;
173
+ optimized: {
174
+ src: string;
175
+ preview: string;
176
+ thumbnail: string;
177
+ };
178
+ };
179
+ hls_480: string;
180
+ hls_720: string;
181
+ hls_1080: string;
182
+ duration: number;
183
+ rutube_id: any;
184
+ youtube_id: any;
185
+ updated_at: string;
186
+ sort_order: number;
187
+ release_id: number;
188
+ name_english: string | null;
189
+ }
190
+ /**
191
+ * Возвращаемый обьект
192
+ */
193
+ export interface AniLibriaReturnObject {
194
+ [key: string]: {
195
+ src: string;
196
+ };
197
+ }
198
+ /**
199
+ * Класс парсера анилибрии
200
+ */
201
+ export declare class AniLibriaParser {
202
+ private static _baseAniLibriaDomain;
203
+ private static _endpointUrl;
204
+ static idPattern: RegExp;
205
+ static episodePattern: RegExp;
206
+ static getDirectLinks(link: string): Promise<AniLibriaReturnObject | null>;
207
+ }
208
+ /**
209
+ * SibnetParser
210
+ * Парсер источника Sibnet
211
+ */
212
+ export declare class SibnetParser {
213
+ private static _baseSibnetDomain;
214
+ static srcMatch: RegExp;
215
+ static getDirectLink(link: string): Promise<string | null>;
216
+ }
217
+ /**
218
+ * RutubeParser
219
+ * Парсер источника Rutube
220
+ */
221
+ export declare class RutubeParser {
222
+ private static _baseRutubeDomain;
223
+ private static _regExpUrl;
224
+ private static _regExpDirectLink;
225
+ static getDirectLinks(link: string): Promise<Record<string, string> | null>;
226
+ }
227
+ export interface VKVideoTokenResponse {
228
+ token: string;
229
+ expires_at: number;
230
+ }
231
+ /**
232
+ * VKVideoParser
233
+ * Парсер источника VKVideo
234
+ */
235
+ export declare class VKVideoParser {
236
+ private static _baseVkDomain;
237
+ private static _iosUserAgent;
238
+ private static oidRegExp;
239
+ private static idRegExp;
240
+ private static hashRegExp;
241
+ private static _regExpDirectLink;
242
+ static getDirectLinks(link: string): Promise<Record<string, string> | null>;
243
+ }
244
+ /**
245
+ * OKParser
246
+ * Парсер источника OK
247
+ */
248
+ export declare class OKParser {
249
+ private static _regExpDataOptions;
250
+ private static _regExpDirectLink;
251
+ private static _okUserAgent;
252
+ static getDirectLinks(link: string): Promise<Record<string, string> | null>;
253
+ }
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ /**
3
+ * Парсер различных источников
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OKParser = exports.VKVideoParser = exports.RutubeParser = exports.SibnetParser = exports.AniLibriaParser = exports.KodikParser = void 0;
7
+ class KodikParser {
8
+ static async getLatestLink(url) {
9
+ var _a, _b, _c, _d;
10
+ const endpointUrlRegex = new RegExp(/url:atob\(\"(?<encodedPath>[^"]+)\"\)/is);
11
+ const appPlayerPathRegex = new RegExp(/src="(?<path>\/assets\/js\/app\.player_single\..*?\.js)"\>/is);
12
+ const playerResponse = await (await fetch(url)).text();
13
+ const appPlayerPath = (_b = (_a = playerResponse.match(appPlayerPathRegex)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.path;
14
+ if (!appPlayerPath)
15
+ return null;
16
+ const appPlayerResponse = await (await fetch(`https://${new URL(url).host}${appPlayerPath}`)).text();
17
+ const latestEndpoint = (_d = (_c = appPlayerResponse.match(endpointUrlRegex)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.encodedPath;
18
+ if (!latestEndpoint)
19
+ return null;
20
+ return atob(latestEndpoint);
21
+ }
22
+ static async getDirectLinks(url, endpointPath = this._endpointUrl) {
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
24
+ const urlResponse = await (await fetch(url)).text();
25
+ const urlParams = JSON.parse((_c = (_b = (_a = urlResponse.match(/var\surlParams\s=\s'(?<params>.*?)';/is)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.params) !== null && _c !== void 0 ? _c : "{}");
26
+ const videoInfoHash = (_e = (_d = urlResponse.match(/\w+.hash\s=\s'(?<hash>.*?)';/is)) === null || _d === void 0 ? void 0 : _d.groups) === null || _e === void 0 ? void 0 : _e.hash;
27
+ const videoInfoId = (_g = (_f = urlResponse.match(/\w+.id\s=\s'(?<id>.*?)';/is)) === null || _f === void 0 ? void 0 : _f.groups) === null || _g === void 0 ? void 0 : _g.id;
28
+ const videoInfoType = (_j = (_h = urlResponse.match(/\w+.type\s=\s'(?<type>.*?)';/)) === null || _h === void 0 ? void 0 : _h.groups) === null || _j === void 0 ? void 0 : _j.type;
29
+ const validKodikUrl = /\/\/(get|cloud)\.(kodik-storage|solodcdn)\.com\/useruploads\/.*?\/.*?\/(240|360|480|720|1080)\.mp4:hls:manifest.m3u8/s;
30
+ if (!videoInfoHash || !videoInfoId || !videoInfoType)
31
+ return null;
32
+ const requestBody = {
33
+ ...urlParams,
34
+ type: videoInfoType,
35
+ hash: videoInfoHash,
36
+ id: videoInfoId
37
+ };
38
+ const directLinksResponse = await fetch(`https://${this._baseKodikDomain}${endpointPath}?${new URLSearchParams(requestBody).toString()}`, {
39
+ referrer: '',
40
+ referrerPolicy: "no-referrer"
41
+ });
42
+ if (directLinksResponse.headers.get("content-type") !== "application/json")
43
+ return null;
44
+ const directLinks = await directLinksResponse.json();
45
+ const zCharCode = 'Z'.charCodeAt(0);
46
+ for (const [, sources] of Object.entries(directLinks.links)) {
47
+ for (const source of sources) {
48
+ if (validKodikUrl.test(source.src))
49
+ continue;
50
+ const decryptedBase64 = source.src.replace(/[a-zA-Z]/g, e => {
51
+ let eCharCode = e.charCodeAt(0);
52
+ return String.fromCharCode((eCharCode <= zCharCode ? 90 : 122) >= (eCharCode = eCharCode + 18) ? eCharCode : eCharCode - 26);
53
+ });
54
+ source.src = atob(decryptedBase64);
55
+ }
56
+ }
57
+ return directLinks.links;
58
+ }
59
+ }
60
+ exports.KodikParser = KodikParser;
61
+ KodikParser._baseKodikDomain = 'kodikplayer.com';
62
+ KodikParser._endpointUrl = '/ftor';
63
+ /**
64
+ * Класс парсера анилибрии
65
+ */
66
+ class AniLibriaParser {
67
+ static async getDirectLinks(link) {
68
+ var _a, _b, _c, _d, _e;
69
+ const id = (_b = (_a = this.idPattern.exec(link)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.id;
70
+ const episode = (_d = (_c = this.episodePattern.exec(link)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.ep;
71
+ const request = await fetch(`https://${this._baseAniLibriaDomain}${this._endpointUrl}/${id}`);
72
+ let body = await request.json();
73
+ if (!body || typeof episode != 'string')
74
+ return null;
75
+ const ep = (_e = body.episodes.find(e => e.ordinal == parseInt(episode))) !== null && _e !== void 0 ? _e : null;
76
+ if (ep) {
77
+ return {
78
+ "1080": {
79
+ src: ep.hls_1080
80
+ },
81
+ "720": {
82
+ src: ep.hls_720
83
+ },
84
+ "480": {
85
+ src: ep.hls_480
86
+ }
87
+ };
88
+ }
89
+ return null;
90
+ }
91
+ }
92
+ exports.AniLibriaParser = AniLibriaParser;
93
+ AniLibriaParser._baseAniLibriaDomain = 'aniliberty.top';
94
+ AniLibriaParser._endpointUrl = '/api/v1/anime/releases';
95
+ AniLibriaParser.idPattern = /id=(?<id>\d+)/;
96
+ AniLibriaParser.episodePattern = /ep=(?<ep>\d+)/;
97
+ /**
98
+ * SibnetParser
99
+ * Парсер источника Sibnet
100
+ */
101
+ class SibnetParser {
102
+ static async getDirectLink(link) {
103
+ var _a;
104
+ const request = await fetch(link);
105
+ let body = await request.text();
106
+ let match = this.srcMatch.exec(body);
107
+ if (match) {
108
+ const srcRequest = await fetch(`https://${this._baseSibnetDomain}${match[1].replace(/"/g, '')}`, {
109
+ headers: {
110
+ host: this._baseSibnetDomain,
111
+ referer: link
112
+ }
113
+ });
114
+ return (_a = srcRequest.url) !== null && _a !== void 0 ? _a : null;
115
+ }
116
+ return null;
117
+ }
118
+ }
119
+ exports.SibnetParser = SibnetParser;
120
+ SibnetParser._baseSibnetDomain = 'video.sibnet.ru';
121
+ SibnetParser.srcMatch = new RegExp(/src: (".*?")/);
122
+ /**
123
+ * RutubeParser
124
+ * Парсер источника Rutube
125
+ */
126
+ class RutubeParser {
127
+ static async getDirectLinks(link) {
128
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
129
+ const match = (_c = (_b = (_a = this._regExpUrl.exec(link)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.videoId) !== null && _c !== void 0 ? _c : null;
130
+ if (!match)
131
+ return null;
132
+ const request = await fetch(`https://${this._baseRutubeDomain}/api/play/options/${match}/?no_404=true&referer&pver=v2`);
133
+ const body = await request.json();
134
+ const balancerUrl = (_d = body['video_balancer'].default) !== null && _d !== void 0 ? _d : null;
135
+ if (!balancerUrl)
136
+ return null;
137
+ const balancerRequest = await fetch(balancerUrl);
138
+ const balancerBody = await balancerRequest.text();
139
+ let directLinkMatch = this._regExpDirectLink.exec(balancerBody);
140
+ if ((directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.length) == 0)
141
+ return null;
142
+ let directLinks = {};
143
+ do {
144
+ const width = (_f = (_e = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : null;
145
+ const heigth = (_h = (_g = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _g === void 0 ? void 0 : _g.heigth) !== null && _h !== void 0 ? _h : null;
146
+ const url = (_k = (_j = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _j === void 0 ? void 0 : _j.url) !== null && _k !== void 0 ? _k : null;
147
+ if (!width || !heigth || !url)
148
+ break;
149
+ directLinks[`${heigth}`] = url;
150
+ directLinkMatch = this._regExpDirectLink.exec(balancerBody);
151
+ } while (directLinkMatch);
152
+ return directLinks;
153
+ }
154
+ }
155
+ exports.RutubeParser = RutubeParser;
156
+ RutubeParser._baseRutubeDomain = 'rutube.ru';
157
+ RutubeParser._regExpUrl = /(http|https):\/\/(?<domain>\w+.\w+)\/play\/embed\/(?<videoId>\w+)/;
158
+ RutubeParser._regExpDirectLink = /^.*\s*RESOLUTION=(?<width>\d+)x(?<heigth>\d+)\n(?<url>.*)$/gm;
159
+ /**
160
+ * VKVideoParser
161
+ * Парсер источника VKVideo
162
+ */
163
+ class VKVideoParser {
164
+ static async getDirectLinks(link) {
165
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
166
+ const oid = (_c = (_b = (_a = this.oidRegExp.exec(link)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.oid) !== null && _c !== void 0 ? _c : null;
167
+ const id = (_f = (_e = (_d = this.idRegExp.exec(link)) === null || _d === void 0 ? void 0 : _d.groups) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null;
168
+ const hash = (_j = (_h = (_g = this.hashRegExp.exec(link)) === null || _g === void 0 ? void 0 : _g.groups) === null || _h === void 0 ? void 0 : _h.hash) !== null && _j !== void 0 ? _j : null;
169
+ if (!oid || !id || !hash)
170
+ return null;
171
+ const uuid = crypto.randomUUID();
172
+ const tokenResponse = await fetch(`https://oauth.${this._baseVkDomain}/oauth/get_anonym_token?client_id=51552953&client_secret=qgr0yWwXCrsxA1jnRtRX&device_id=${uuid}`, {
173
+ headers: {
174
+ 'User-Agent': this._iosUserAgent,
175
+ 'Host': `oauth.${this._baseVkDomain}`,
176
+ }
177
+ });
178
+ const anonymToken = await tokenResponse.json();
179
+ const getLinksResponse = await fetch(`https://api.${this._baseVkDomain}/method/video.get`, {
180
+ headers: {
181
+ 'User-Agent': this._iosUserAgent,
182
+ 'Host': `api.${this._baseVkDomain}`,
183
+ },
184
+ method: 'POST',
185
+ body: `anonymous_token=${anonymToken.token}&device_id=${uuid}&lang=en&v=5.244&videos=${oid}_${id}_${hash}`,
186
+ });
187
+ const getLinksResponseJson = await getLinksResponse.json();
188
+ const hlsMasterRequest = await fetch(getLinksResponseJson.response.items[0].files.hls);
189
+ const vkServerUrl = new URL(hlsMasterRequest.url).host;
190
+ const hlsMasterBody = await hlsMasterRequest.text();
191
+ let directLinkMatch = this._regExpDirectLink.exec(hlsMasterBody);
192
+ if ((directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.length) == 0)
193
+ return null;
194
+ let directLinks = {};
195
+ do {
196
+ const width = (_l = (_k = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _k === void 0 ? void 0 : _k.width) !== null && _l !== void 0 ? _l : null;
197
+ const heigth = (_o = (_m = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _m === void 0 ? void 0 : _m.heigth) !== null && _o !== void 0 ? _o : null;
198
+ const url = (_q = (_p = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _p === void 0 ? void 0 : _p.url) !== null && _q !== void 0 ? _q : null;
199
+ if (!width || !heigth || !url)
200
+ break;
201
+ directLinks[`${heigth}`] = `https://${vkServerUrl}${url}`;
202
+ directLinkMatch = this._regExpDirectLink.exec(hlsMasterBody);
203
+ } while (directLinkMatch);
204
+ return directLinks;
205
+ }
206
+ }
207
+ exports.VKVideoParser = VKVideoParser;
208
+ VKVideoParser._baseVkDomain = 'vk.com';
209
+ VKVideoParser._iosUserAgent = "com.vk.vkvideo.prod/822 (iPhone, iOS 16.7.7, iPhone10,4, Scale/2.0) SAK/1.119";
210
+ VKVideoParser.oidRegExp = /[?&]oid=(?<oid>(-|)\d+)/;
211
+ VKVideoParser.idRegExp = /[?&]id=(?<id>(-|)\d+)/;
212
+ VKVideoParser.hashRegExp = /[?&]hash=(?<hash>\w+)/;
213
+ VKVideoParser._regExpDirectLink = /^.*\s*RESOLUTION=(?<width>\d+)x(?<heigth>\d+)\n(?<url>.*)$/gm;
214
+ /**
215
+ * OKParser
216
+ * Парсер источника OK
217
+ */
218
+ class OKParser {
219
+ static async getDirectLinks(link) {
220
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
221
+ const request = await fetch(link, { headers: { 'User-Agent': this._okUserAgent } });
222
+ const body = await request.text();
223
+ const dataOptionsMatch = (_c = (_b = (_a = this._regExpDataOptions.exec(body)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.content) !== null && _c !== void 0 ? _c : null;
224
+ if (!dataOptionsMatch)
225
+ return null;
226
+ const dataOptions = dataOptionsMatch.replace(/&quot;/g, "\"").replace(/\\\\u0026/g, "&");
227
+ const dataOptionsJson = JSON.parse(dataOptions);
228
+ const metadataJson = JSON.parse(dataOptionsJson.flashvars.metadata);
229
+ if (metadataJson.provider != "UPLOADED_ODKL" || metadataJson.isLive)
230
+ return null;
231
+ const hlsMasterRequest = await fetch(metadataJson.hlsManifestUrl, { headers: { 'User-Agent': this._okUserAgent } });
232
+ const hlsMasterBody = await hlsMasterRequest.text();
233
+ const okServerUrl = new URL(hlsMasterRequest.url).host;
234
+ let directLinkMatch = this._regExpDirectLink.exec(hlsMasterBody);
235
+ if ((directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.length) == 0)
236
+ return null;
237
+ let directLinks = {};
238
+ do {
239
+ const width = (_e = (_d = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _d === void 0 ? void 0 : _d.width) !== null && _e !== void 0 ? _e : null;
240
+ const heigth = (_g = (_f = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _f === void 0 ? void 0 : _f.heigth) !== null && _g !== void 0 ? _g : null;
241
+ const url = (_j = (_h = directLinkMatch === null || directLinkMatch === void 0 ? void 0 : directLinkMatch.groups) === null || _h === void 0 ? void 0 : _h.url) !== null && _j !== void 0 ? _j : null;
242
+ if (!width || !heigth || !url)
243
+ break;
244
+ directLinks[`${heigth}`] = `https://${okServerUrl}${url}`;
245
+ directLinkMatch = this._regExpDirectLink.exec(hlsMasterBody);
246
+ } while (directLinkMatch);
247
+ return directLinks;
248
+ }
249
+ }
250
+ exports.OKParser = OKParser;
251
+ OKParser._regExpDataOptions = /data-options="(?<content>{.*})"/m;
252
+ OKParser._regExpDirectLink = /^.*\s*RESOLUTION=(?<width>\d+)x(?<heigth>\d+)\n(?<url>.*)$/gm;
253
+ OKParser._okUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36";
@@ -0,0 +1,3 @@
1
+ export declare class Utils {
2
+ static generateTempFileName(): string;
3
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Utils = void 0;
4
+ class Utils {
5
+ static generateTempFileName() {
6
+ const now = new Date();
7
+ const timestamp = now.toISOString().replace(/[-T:.Z]/g, "").slice(0, 15); // YYYYMMDD_HHMMSS
8
+ return `temp_file_${timestamp}.jpg`;
9
+ }
10
+ }
11
+ exports.Utils = Utils;