anixartjs 0.0.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 (81) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +187 -0
  3. package/dist/api/auth.d.ts +11 -0
  4. package/dist/api/auth.js +49 -0
  5. package/dist/api/channel.d.ts +42 -0
  6. package/dist/api/channel.js +111 -0
  7. package/dist/api/collection.d.ts +30 -0
  8. package/dist/api/collection.js +57 -0
  9. package/dist/api/discover.d.ts +11 -0
  10. package/dist/api/discover.js +24 -0
  11. package/dist/api/feed.d.ts +9 -0
  12. package/dist/api/feed.js +18 -0
  13. package/dist/api/index.d.ts +9 -0
  14. package/dist/api/index.js +25 -0
  15. package/dist/api/notification.d.ts +14 -0
  16. package/dist/api/notification.js +33 -0
  17. package/dist/api/profile.d.ts +26 -0
  18. package/dist/api/profile.js +59 -0
  19. package/dist/api/release.d.ts +40 -0
  20. package/dist/api/release.js +101 -0
  21. package/dist/api/settings.d.ts +30 -0
  22. package/dist/api/settings.js +81 -0
  23. package/dist/classes/Article.d.ts +18 -0
  24. package/dist/classes/Article.js +43 -0
  25. package/dist/classes/ArticleComment.d.ts +15 -0
  26. package/dist/classes/ArticleComment.js +36 -0
  27. package/dist/classes/BaseArticle.d.ts +21 -0
  28. package/dist/classes/BaseArticle.js +23 -0
  29. package/dist/classes/BaseComment.d.ts +22 -0
  30. package/dist/classes/BaseComment.js +25 -0
  31. package/dist/classes/BaseProfile.d.ts +25 -0
  32. package/dist/classes/BaseProfile.js +37 -0
  33. package/dist/classes/Channel.d.ts +47 -0
  34. package/dist/classes/Channel.js +103 -0
  35. package/dist/classes/Dubber.d.ts +19 -0
  36. package/dist/classes/Dubber.js +24 -0
  37. package/dist/classes/Episode.d.ts +20 -0
  38. package/dist/classes/Episode.js +30 -0
  39. package/dist/classes/FullProfile.d.ts +53 -0
  40. package/dist/classes/FullProfile.js +75 -0
  41. package/dist/classes/Release.d.ts +88 -0
  42. package/dist/classes/Release.js +140 -0
  43. package/dist/classes/ReleaseComment.d.ts +16 -0
  44. package/dist/classes/ReleaseComment.js +44 -0
  45. package/dist/classes/Source.d.ts +15 -0
  46. package/dist/classes/Source.js +20 -0
  47. package/dist/classes/SuggestionArticle.d.ts +14 -0
  48. package/dist/classes/SuggestionArticle.js +28 -0
  49. package/dist/client.d.ts +27 -0
  50. package/dist/client.js +121 -0
  51. package/dist/endpoints.d.ts +18 -0
  52. package/dist/endpoints.js +25 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.js +20 -0
  55. package/dist/types/auth.d.ts +25 -0
  56. package/dist/types/auth.js +2 -0
  57. package/dist/types/channel.d.ts +178 -0
  58. package/dist/types/channel.js +2 -0
  59. package/dist/types/collection.d.ts +38 -0
  60. package/dist/types/collection.js +2 -0
  61. package/dist/types/index.d.ts +12 -0
  62. package/dist/types/index.js +25 -0
  63. package/dist/types/notification.d.ts +22 -0
  64. package/dist/types/notification.js +2 -0
  65. package/dist/types/profile.d.ts +141 -0
  66. package/dist/types/profile.js +21 -0
  67. package/dist/types/release.d.ts +240 -0
  68. package/dist/types/release.js +23 -0
  69. package/dist/types/request.d.ts +36 -0
  70. package/dist/types/request.js +2 -0
  71. package/dist/types/response.d.ts +51 -0
  72. package/dist/types/response.js +12 -0
  73. package/dist/types/settings.d.ts +61 -0
  74. package/dist/types/settings.js +14 -0
  75. package/dist/utils/ArticleBuilder.d.ts +36 -0
  76. package/dist/utils/ArticleBuilder.js +138 -0
  77. package/dist/utils/LinkParser.d.ts +110 -0
  78. package/dist/utils/LinkParser.js +119 -0
  79. package/dist/utils/Utils.d.ts +3 -0
  80. package/dist/utils/Utils.js +11 -0
  81. package/package.json +32 -0
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArticleBuilder = void 0;
4
+ const Article_1 = require("../classes/Article");
5
+ class ArticleBuilder {
6
+ constructor() {
7
+ this.blocks = [];
8
+ this.repostArticleId = null;
9
+ this.maxBlockCount = 25;
10
+ }
11
+ generateUniqueId() {
12
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_';
13
+ let id = '';
14
+ for (let i = 0; i < 9; i++) {
15
+ id += chars.charAt(Math.floor(Math.random() * chars.length));
16
+ }
17
+ return id;
18
+ }
19
+ returnBuildAricle() {
20
+ return {
21
+ repost_article_id: this.repostArticleId,
22
+ payload: {
23
+ time: Date.now(),
24
+ version: "2.29.0-rc.1",
25
+ blocks: this.blocks,
26
+ block_count: this.blocks.length
27
+ }
28
+ };
29
+ }
30
+ setRepostArticle(article) {
31
+ this.repostArticleId = article instanceof Article_1.Article ? article.id : article;
32
+ return this;
33
+ }
34
+ addBlock(data) {
35
+ this.addBlocks([data]);
36
+ return this;
37
+ }
38
+ addBlocks(data) {
39
+ for (const block of data) {
40
+ if (this.blocks.length >= this.maxBlockCount)
41
+ break;
42
+ let baseBlock;
43
+ switch (block.type) {
44
+ case "paragraph":
45
+ baseBlock = {
46
+ id: this.generateUniqueId(),
47
+ type: block.type,
48
+ name: block.type,
49
+ data: {
50
+ text: block.text,
51
+ text_length: block.text.length
52
+ }
53
+ };
54
+ break;
55
+ case "header":
56
+ baseBlock = {
57
+ id: this.generateUniqueId(),
58
+ type: block.type,
59
+ name: block.type,
60
+ data: {
61
+ text: block.text,
62
+ text_length: block.text.length,
63
+ level: 3
64
+ }
65
+ };
66
+ break;
67
+ case "quote":
68
+ baseBlock = {
69
+ id: this.generateUniqueId(),
70
+ type: block.type,
71
+ name: block.type,
72
+ data: {
73
+ text: block.text,
74
+ caption: block.caption,
75
+ alignment: "left",
76
+ text_length: block.text.length,
77
+ caption_length: block.caption.length
78
+ }
79
+ };
80
+ break;
81
+ case "delimiter":
82
+ baseBlock = {
83
+ id: this.generateUniqueId(),
84
+ type: block.type,
85
+ name: block.type,
86
+ data: {}
87
+ };
88
+ break;
89
+ case "unorderedList":
90
+ case "orderedList":
91
+ baseBlock = {
92
+ id: this.generateUniqueId(),
93
+ type: "list",
94
+ name: "list",
95
+ data: {
96
+ style: block.type == "orderedList" ? "ordered" : "unordered",
97
+ items: block.items,
98
+ item_count: block.items.length
99
+ }
100
+ };
101
+ break;
102
+ case "media":
103
+ baseBlock = {
104
+ id: this.generateUniqueId(),
105
+ type: "media",
106
+ name: "media",
107
+ data: {
108
+ items: block.items,
109
+ item_count: block.items.length
110
+ }
111
+ };
112
+ break;
113
+ case "embed":
114
+ baseBlock = {
115
+ id: this.generateUniqueId(),
116
+ type: block.type,
117
+ name: block.type,
118
+ data: {
119
+ hash: block.data.hash,
120
+ embed: block.data.embed,
121
+ image: block.data.image,
122
+ site_name: block.data.site_name,
123
+ title: block.data.title,
124
+ description: block.data.description,
125
+ width: block.data.width,
126
+ height: block.data.height,
127
+ url: block.data.url,
128
+ service: block.data.site_name.toLowerCase() !== "youtube" || block.data.site_name.toLowerCase() !== "vk" ? "link" : block.data.site_name.toLowerCase()
129
+ }
130
+ };
131
+ break;
132
+ }
133
+ this.blocks.push(baseBlock);
134
+ }
135
+ return this;
136
+ }
137
+ }
138
+ exports.ArticleBuilder = ArticleBuilder;
@@ -0,0 +1,110 @@
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 AniLibriaFile {
61
+ id: string;
62
+ skip: boolean;
63
+ file: string;
64
+ title: string;
65
+ poster: string;
66
+ download: string;
67
+ }
68
+ /**
69
+ * Ссылка на файл
70
+ */
71
+ export interface AniLibriaLink {
72
+ quality: string;
73
+ url: string;
74
+ }
75
+ /**
76
+ * Обьект файла
77
+ */
78
+ export interface AniLibriaFileObject {
79
+ id: string;
80
+ skip: boolean;
81
+ file: AniLibriaLink[];
82
+ title: string;
83
+ poster: string;
84
+ download: string;
85
+ }
86
+ /**
87
+ * Возвращаемый обьект
88
+ */
89
+ export interface AniLibriaReturnObject {
90
+ files: AniLibriaFileObject[];
91
+ }
92
+ /**
93
+ * Класс парсера анилибрии
94
+ */
95
+ export declare class AniLibriaParser {
96
+ private static _baseAniLibriaDomain;
97
+ private static _endpointUrl;
98
+ static settingsPattern: RegExp;
99
+ static filesPattern: RegExp;
100
+ static getDirectLinks(link: string): Promise<AniLibriaReturnObject | null>;
101
+ }
102
+ /**
103
+ * SibnetParser
104
+ * Парсер источника Sibnet
105
+ */
106
+ export declare class SibnetParser {
107
+ private static _baseSibnetDomain;
108
+ static srcMatch: RegExp;
109
+ static getDirectLink(link: string): Promise<string | null>;
110
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ /**
3
+ * Парсер различных источников
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ 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(/videoInfo.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(/videoInfo.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(/videoInfo.type\s=\s'(?<type>.*?)';/)) === null || _h === void 0 ? void 0 : _h.groups) === null || _j === void 0 ? void 0 : _j.type;
29
+ if (!videoInfoHash || !videoInfoId || !videoInfoType)
30
+ return null;
31
+ const requestBody = {
32
+ ...urlParams,
33
+ type: videoInfoType,
34
+ hash: videoInfoHash,
35
+ id: videoInfoId
36
+ };
37
+ const directLinksResponse = await fetch(`https://${this._baseKodikDomain}${endpointPath}?${new URLSearchParams(requestBody).toString()}`, {
38
+ referrer: '',
39
+ referrerPolicy: "no-referrer"
40
+ });
41
+ if (directLinksResponse.headers.get("content-type") !== "application/json")
42
+ return null;
43
+ const directLinks = await directLinksResponse.json();
44
+ const zCharCode = 'Z'.charCodeAt(0);
45
+ for (const [, sources] of Object.entries(directLinks.links)) {
46
+ for (const source of sources) {
47
+ const decryptedBase64 = source.src.replace(/[a-zA-Z]/g, e => {
48
+ let eCharCode = e.charCodeAt(0);
49
+ return String.fromCharCode((eCharCode <= zCharCode ? 90 : 122) >= (eCharCode = eCharCode + 13) ? eCharCode : eCharCode - 26);
50
+ });
51
+ source.src = atob(decryptedBase64);
52
+ }
53
+ }
54
+ return directLinks.links;
55
+ }
56
+ }
57
+ exports.KodikParser = KodikParser;
58
+ KodikParser._baseKodikDomain = 'kodik.info';
59
+ KodikParser._endpointUrl = '/ftor';
60
+ /**
61
+ * Класс парсера анилибрии
62
+ */
63
+ class AniLibriaParser {
64
+ static async getDirectLinks(link) {
65
+ const request = await fetch(link);
66
+ let body = await request.text();
67
+ let match = this.settingsPattern.exec(body);
68
+ if (match) {
69
+ let originalObject = JSON.parse(match[0]);
70
+ let returnedObject = {
71
+ files: [],
72
+ };
73
+ for (let x of originalObject) {
74
+ let res = {
75
+ ...x,
76
+ file: []
77
+ };
78
+ let filesMatch = x.file.match(this.filesPattern);
79
+ for (let y of filesMatch) {
80
+ let link = y.replace('[', '').split(']');
81
+ res.file.push({ quality: link[0], url: link[1] });
82
+ }
83
+ returnedObject.files.push(res);
84
+ }
85
+ return returnedObject;
86
+ }
87
+ return null;
88
+ }
89
+ }
90
+ exports.AniLibriaParser = AniLibriaParser;
91
+ AniLibriaParser._baseAniLibriaDomain = 'anixart.libria.fun';
92
+ AniLibriaParser._endpointUrl = '/public/iframe.php';
93
+ AniLibriaParser.settingsPattern = new RegExp(/\[{.*?}\]/g);
94
+ AniLibriaParser.filesPattern = new RegExp(/\[.*?\].*?(,|isAuthorized=\d)/g);
95
+ /**
96
+ * SibnetParser
97
+ * Парсер источника Sibnet
98
+ */
99
+ class SibnetParser {
100
+ static async getDirectLink(link) {
101
+ var _a;
102
+ const request = await fetch(link);
103
+ let body = await request.text();
104
+ let match = this.srcMatch.exec(body);
105
+ if (match) {
106
+ const srcRequest = await fetch(`https://${this._baseSibnetDomain}${match[1].replace(/"/g, '')}`, {
107
+ headers: {
108
+ host: this._baseSibnetDomain,
109
+ referer: link
110
+ }
111
+ });
112
+ return (_a = srcRequest.url) !== null && _a !== void 0 ? _a : null;
113
+ }
114
+ return null;
115
+ }
116
+ }
117
+ exports.SibnetParser = SibnetParser;
118
+ SibnetParser._baseSibnetDomain = 'video.sibnet.ru';
119
+ SibnetParser.srcMatch = new RegExp(/src: (".*?")/g);
@@ -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;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "anixartjs",
3
+ "version": "0.0.1",
4
+ "description": "Anixart API Wrapper for NodeJS",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "rm -rf ./dist && tsc",
10
+ "build-win": "rd .\\dist /s /q && tsc"
11
+ },
12
+ "keywords": [
13
+ "api",
14
+ "anixart",
15
+ "wrapper",
16
+ "anime"
17
+ ],
18
+ "homepage": "https://github.com/theDesConnet/AnixartJS",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/theDesConnet/AnixartJS.git"
22
+ },
23
+ "author": "Roman U. (DesConnet)",
24
+ "license": "GPL-2.0",
25
+ "devDependencies": {
26
+ "@types/node": "^22.10.2",
27
+ "typescript": "^5.7.2"
28
+ },
29
+ "dependencies": {
30
+ "form-data": "^4.0.2"
31
+ }
32
+ }