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,47 @@
1
+ import { Anixart } from "../client";
2
+ import { IChannel, IChannelBlockInfo, IChannelBlockManageRequest, IChannelCreateRequest, ResponseCode } from "../types";
3
+ import { ArticleBuilder } from "../utils/ArticleBuilder";
4
+ import { SuggestionArticle } from "./SuggestionArticle";
5
+ import { Article } from "./Article";
6
+ import { BaseProfile } from "./BaseProfile";
7
+ import { FullProfile } from "./FullProfile";
8
+ export declare class Channel {
9
+ private readonly client;
10
+ readonly id: number;
11
+ readonly title: string;
12
+ readonly description: string;
13
+ readonly channelAvatar: string;
14
+ readonly channelCover: string;
15
+ readonly clientPermission: number;
16
+ readonly articleCount: number;
17
+ readonly subscriberCount: number;
18
+ readonly creationDate: Date;
19
+ readonly lastUpdateDate: Date;
20
+ readonly isBlog: boolean;
21
+ readonly isCommentingEnabled: boolean;
22
+ readonly isArticleSuggestionEnabled: boolean;
23
+ readonly isVerified: boolean;
24
+ readonly isDeleted: boolean;
25
+ readonly blogProfileId: number;
26
+ readonly isSubscribed: boolean;
27
+ readonly isBlocked: boolean;
28
+ readonly blockReason: string;
29
+ readonly blockExpiredDate: Date;
30
+ readonly isPermBlocked: boolean;
31
+ readonly isAdministratorOrHigher: boolean;
32
+ constructor(client: Anixart, channelResponce: IChannel);
33
+ private writeProperties;
34
+ getArticles(page: number, date?: number): Promise<(Article | undefined)[]>;
35
+ getArticleById(id: number): Promise<Article | null>;
36
+ createArticle(data: ArticleBuilder): Promise<Article | null>;
37
+ subscribe(): Promise<ResponseCode>;
38
+ unsubscribe(): Promise<ResponseCode>;
39
+ setAvatar(file: Buffer): Promise<this>;
40
+ setCover(file: Buffer): Promise<this>;
41
+ getMediaToken(isSuggestionMode?: boolean, isEditMode?: boolean): Promise<string | null>;
42
+ edit(data: IChannelCreateRequest): Promise<Channel | null>;
43
+ getArticleSuggestions(page: number): Promise<(SuggestionArticle[] | null)>;
44
+ createArticleSuggestion(data: ArticleBuilder): Promise<SuggestionArticle | null>;
45
+ manageBlocklist(profile: BaseProfile | FullProfile | number, data: Omit<IChannelBlockManageRequest, "target_profile_id">): Promise<ResponseCode>;
46
+ getBlocklist(profile: BaseProfile | FullProfile | number): Promise<IChannelBlockInfo | null>;
47
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Channel = void 0;
4
+ const SuggestionArticle_1 = require("./SuggestionArticle");
5
+ const Article_1 = require("./Article");
6
+ class Channel {
7
+ constructor(client, channelResponce) {
8
+ this.client = client;
9
+ this.id = channelResponce.id;
10
+ this.title = channelResponce.title;
11
+ this.description = channelResponce.description;
12
+ this.channelAvatar = channelResponce.avatar;
13
+ this.channelCover = channelResponce.cover;
14
+ this.clientPermission = channelResponce.permission;
15
+ this.articleCount = channelResponce.article_count;
16
+ this.subscriberCount = channelResponce.subscriber_count;
17
+ this.creationDate = new Date(channelResponce.creation_date * 1000);
18
+ this.lastUpdateDate = new Date(channelResponce.last_update_date * 1000);
19
+ this.isBlog = channelResponce.is_blog;
20
+ this.isCommentingEnabled = channelResponce.is_commenting_enabled;
21
+ this.isArticleSuggestionEnabled = channelResponce.is_article_suggestion_enabled;
22
+ this.isVerified = channelResponce.is_verified;
23
+ this.isDeleted = channelResponce.is_deleted;
24
+ this.blogProfileId = channelResponce.blog_profile_id;
25
+ this.isSubscribed = channelResponce.is_subscribed;
26
+ this.isBlocked = channelResponce.is_blocked;
27
+ this.blockReason = channelResponce.block_reason;
28
+ this.blockExpiredDate = new Date(channelResponce.block_expire_date * 1000);
29
+ this.isPermBlocked = channelResponce.is_perm_blocked;
30
+ this.isAdministratorOrHigher = channelResponce.is_administrator_or_higher;
31
+ }
32
+ writeProperties(prop, value) {
33
+ this[prop] = value;
34
+ }
35
+ async getArticles(page, date) {
36
+ const request = await this.client.endpoints.channel.getArticles(this.id, page, date !== null && date !== void 0 ? date : 0);
37
+ return request.content.map(article => new Article_1.Article(this.client, article, this));
38
+ }
39
+ async getArticleById(id) {
40
+ const request = await this.client.endpoints.channel.getArticle(id);
41
+ return request.article ? new Article_1.Article(this.client, request.article) : null;
42
+ }
43
+ async createArticle(data) {
44
+ const request = await this.client.endpoints.channel.createArticle(this.id, data.returnBuildAricle());
45
+ return request.article ? new Article_1.Article(this.client, request.article) : null;
46
+ }
47
+ async subscribe() {
48
+ const request = await this.client.endpoints.channel.subscribe(this.id);
49
+ if (request.code == 0) {
50
+ this.writeProperties("isSubscribed", true);
51
+ }
52
+ return request.code;
53
+ }
54
+ async unsubscribe() {
55
+ const request = await this.client.endpoints.channel.unsubscribe(this.id);
56
+ if (request.code == 0) {
57
+ this.writeProperties("isSubscribed", false);
58
+ }
59
+ return request.code;
60
+ }
61
+ async setAvatar(file) {
62
+ const request = await this.client.endpoints.channel.uploadChannelAvatar(this.id, file);
63
+ if (request.code == 0) {
64
+ this.writeProperties("channelAvatar", request.url);
65
+ }
66
+ return this;
67
+ }
68
+ async setCover(file) {
69
+ const request = await this.client.endpoints.channel.uploadChannelCover(this.id, file);
70
+ if (request.code == 0) {
71
+ this.writeProperties("channelCover", request.url);
72
+ }
73
+ return this;
74
+ }
75
+ async getMediaToken(isSuggestionMode = false, isEditMode = false) {
76
+ const request = await this.client.endpoints.channel.getAvaliableEditor(this.id, isSuggestionMode, isEditMode);
77
+ return request.media_upload_token;
78
+ }
79
+ async edit(data) {
80
+ const request = await this.client.endpoints.channel.editChannel(this.id, data);
81
+ return (request === null || request === void 0 ? void 0 : request.channel) ? new Channel(this.client, request.channel) : null;
82
+ }
83
+ async getArticleSuggestions(page) {
84
+ const request = await this.client.endpoints.channel.getArticleSuggestions(this.id, page);
85
+ return request.content ? request.content.map(article => new SuggestionArticle_1.SuggestionArticle(this.client, article, this)) : null;
86
+ }
87
+ async createArticleSuggestion(data) {
88
+ const request = await this.client.endpoints.channel.createArticleSuggestion(this.id, data.returnBuildAricle());
89
+ return request.code == 0 ? new SuggestionArticle_1.SuggestionArticle(this.client, request.article, this) : null;
90
+ }
91
+ async manageBlocklist(profile, data) {
92
+ const request = await this.client.endpoints.channel.manageChannelBlocklist(this.id, {
93
+ target_profile_id: typeof (profile) == "number" ? profile : profile.id,
94
+ ...data
95
+ });
96
+ return request.code;
97
+ }
98
+ async getBlocklist(profile) {
99
+ const request = await this.client.endpoints.channel.getChannelBlock(this.id, typeof (profile) == "number" ? profile : profile.id);
100
+ return request.channel_block;
101
+ }
102
+ }
103
+ exports.Channel = Channel;
@@ -0,0 +1,19 @@
1
+ import { Release } from "./Release";
2
+ import { Anixart } from "../client";
3
+ import { IDubber } from "../types";
4
+ import { Source } from "./Source";
5
+ export declare class Dubber {
6
+ private readonly client;
7
+ readonly release: Release;
8
+ readonly localId: number;
9
+ readonly id: number;
10
+ readonly episodeCount: number;
11
+ readonly icon: string | null;
12
+ readonly name: string;
13
+ readonly isSub: boolean;
14
+ readonly pinned: boolean;
15
+ readonly viewCount: number;
16
+ readonly workers: string;
17
+ constructor(client: Anixart, dubberResponce: IDubber, release: Release);
18
+ getSources(): Promise<Source[]>;
19
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dubber = void 0;
4
+ const Source_1 = require("./Source");
5
+ class Dubber {
6
+ constructor(client, dubberResponce, release) {
7
+ this.client = client;
8
+ this.release = release;
9
+ this.localId = dubberResponce["@id"];
10
+ this.id = dubberResponce.id;
11
+ this.episodeCount = dubberResponce.episode_count;
12
+ this.icon = dubberResponce.icon;
13
+ this.name = dubberResponce.name;
14
+ this.isSub = dubberResponce.is_sub;
15
+ this.pinned = dubberResponce.pinned,
16
+ this.viewCount = dubberResponce.view_count;
17
+ this.workers = dubberResponce.workers;
18
+ }
19
+ async getSources() {
20
+ const request = await this.client.endpoints.release.getDubberSources(this.release.id, this.id);
21
+ return request.sources.map(source => new Source_1.Source(this.client, source, this));
22
+ }
23
+ }
24
+ exports.Dubber = Dubber;
@@ -0,0 +1,20 @@
1
+ import { Anixart } from '../client';
2
+ import { IEpisode, IRelease, ISource, ResponseCode } from '../types';
3
+ import { Source } from './Source';
4
+ export declare class Episode {
5
+ private readonly client;
6
+ readonly source: Source;
7
+ readonly localId: number;
8
+ readonly position: number;
9
+ readonly release: IRelease | number;
10
+ readonly sourceRaw: ISource | number;
11
+ readonly name: string;
12
+ readonly url: string;
13
+ readonly iframe: boolean;
14
+ readonly addedDate: Date;
15
+ readonly isFilter: boolean;
16
+ readonly isWatched: boolean;
17
+ constructor(client: Anixart, episode: IEpisode, source: Source);
18
+ setWatched(isWatched: boolean): Promise<ResponseCode>;
19
+ addToHistory(): Promise<ResponseCode>;
20
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Episode = void 0;
4
+ class Episode {
5
+ constructor(client, episode, source) {
6
+ this.client = client;
7
+ this.source = source;
8
+ this.localId = episode["@id"];
9
+ this.position = episode.position;
10
+ this.release = episode.release;
11
+ this.sourceRaw = episode.source;
12
+ this.name = episode.name;
13
+ this.url = episode.url;
14
+ this.iframe = episode.iframe;
15
+ this.addedDate = new Date(episode.addedDate * 1000);
16
+ this.isFilter = episode.is_filter;
17
+ this.isWatched = episode.is_watched;
18
+ }
19
+ async setWatched(isWatched) {
20
+ const request = isWatched ?
21
+ await this.client.endpoints.release.markEpisodeAsWatched(this.source.dubber.release.id, this.source.id, this.position)
22
+ : await this.client.endpoints.release.unmarkEpisodeAsWatched(this.source.dubber.release.id, this.source.id, this.position);
23
+ return request.code;
24
+ }
25
+ async addToHistory() {
26
+ const request = await this.client.endpoints.release.addToHistory(this.source.dubber.release.id, this.source.id, this.position);
27
+ return request.code;
28
+ }
29
+ }
30
+ exports.Episode = Episode;
@@ -0,0 +1,53 @@
1
+ import { Anixart } from "../client";
2
+ import { BaseProfile } from "./BaseProfile";
3
+ import { IProfile, IRole } from "../types";
4
+ import { Release } from "./Release";
5
+ export declare class FullProfile extends BaseProfile {
6
+ readonly client: Anixart;
7
+ readonly status: string;
8
+ readonly sponsorshipExpires: number;
9
+ readonly history: Release[];
10
+ readonly votes: Release[];
11
+ readonly lastActivityTime: number;
12
+ readonly registerDate: number;
13
+ readonly vkPage: string;
14
+ readonly tgPage: string;
15
+ readonly instPage: string;
16
+ readonly ttPage: string;
17
+ readonly discordPage: string;
18
+ readonly banNote: unknown;
19
+ readonly watchingCount: number;
20
+ readonly planCount: number;
21
+ readonly completedCount: number;
22
+ readonly holdOnCount: number;
23
+ readonly droppedCount: number;
24
+ readonly favoriteCount: number;
25
+ readonly commentCount: number;
26
+ readonly collectionCount: number;
27
+ readonly videoCount: number;
28
+ readonly watchedEpisodeCount: number;
29
+ readonly watchedTime: number;
30
+ readonly isPrivate: boolean;
31
+ readonly isSponsorTransferred: boolean;
32
+ readonly isBookmarksTransferred: boolean;
33
+ readonly isVkBound: boolean;
34
+ readonly isGoogleBound: boolean;
35
+ readonly isReleaseTypeNotificationsEnabled: boolean;
36
+ readonly isEpisodeNotificationsEnabled: boolean;
37
+ readonly isFirstEpisodeNotificationEnabled: boolean;
38
+ readonly isRelatedReleaseNotificationsEnabled: boolean;
39
+ readonly isReportProcessNotificationsEnabled: boolean;
40
+ readonly isCommentNotificationsEnabled: boolean;
41
+ readonly isMyCollectionCommentNotificationsEnabled: boolean;
42
+ readonly watchDynamics: any[];
43
+ readonly ratingScore: number;
44
+ readonly isPermBanned: boolean;
45
+ readonly isBlocked: boolean;
46
+ readonly isMeBlocked: boolean;
47
+ readonly isStatsHidden: boolean;
48
+ readonly isCountsHidden: boolean;
49
+ readonly isSocialHidden: boolean;
50
+ readonly isFriendRequestsDisallowed: boolean;
51
+ readonly roles: IRole[];
52
+ constructor(client: Anixart, profile: IProfile);
53
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FullProfile = void 0;
4
+ const BaseProfile_1 = require("./BaseProfile");
5
+ const Release_1 = require("./Release");
6
+ class FullProfile extends BaseProfile_1.BaseProfile {
7
+ constructor(client, profile) {
8
+ var _a, _b, _c, _d, _e, _f, _g, _h;
9
+ super(client, {
10
+ id: profile.id,
11
+ login: profile.login,
12
+ avatar: profile.avatar,
13
+ ban_expires: profile.ban_expires,
14
+ ban_reason: profile.ban_reason,
15
+ privilege_level: profile.privilege_level,
16
+ badge_id: (_b = (_a = profile === null || profile === void 0 ? void 0 : profile.badge) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
17
+ badge_name: (_d = (_c = profile === null || profile === void 0 ? void 0 : profile.badge) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : null,
18
+ badge_type: (_f = (_e = profile === null || profile === void 0 ? void 0 : profile.badge) === null || _e === void 0 ? void 0 : _e.type) !== null && _f !== void 0 ? _f : null,
19
+ badge_url: (_h = (_g = profile === null || profile === void 0 ? void 0 : profile.badge) === null || _g === void 0 ? void 0 : _g.image_url) !== null && _h !== void 0 ? _h : null,
20
+ is_banned: profile.is_banned,
21
+ is_sponsor: profile.is_sponsor,
22
+ is_verified: profile.is_verified,
23
+ is_online: profile.is_online,
24
+ friend_count: profile.friend_count,
25
+ friend_status: profile.friend_status
26
+ });
27
+ this.client = client;
28
+ this.status = profile.status;
29
+ this.sponsorshipExpires = profile.sponsorshipExpires;
30
+ this.history = profile.history.map(release => new Release_1.Release(this.client, release));
31
+ this.votes = profile.votes.map(release => new Release_1.Release(this.client, release));
32
+ this.lastActivityTime = profile.last_activity_time;
33
+ this.registerDate = profile.register_date;
34
+ this.vkPage = profile.vk_page;
35
+ this.tgPage = profile.tg_page;
36
+ this.instPage = profile.inst_page;
37
+ this.ttPage = profile.tt_page;
38
+ this.discordPage = profile.discord_page;
39
+ this.banNote = profile.ban_note;
40
+ this.watchingCount = profile.watching_count;
41
+ this.planCount = profile.plan_count;
42
+ this.completedCount = profile.completed_count;
43
+ this.holdOnCount = profile.hold_on_count;
44
+ this.droppedCount = profile.dropped_count;
45
+ this.favoriteCount = profile.favorite_count;
46
+ this.commentCount = profile.comment_count;
47
+ this.collectionCount = profile.collection_count;
48
+ this.videoCount = profile.video_count;
49
+ this.watchedEpisodeCount = profile.watched_episode_count;
50
+ this.watchedTime = profile.watched_time;
51
+ this.isPrivate = profile.is_private;
52
+ this.isSponsorTransferred = profile.is_sponsor_transferred;
53
+ this.isBookmarksTransferred = profile.is_bookmarks_transferred;
54
+ this.isVkBound = profile.is_vk_bound;
55
+ this.isGoogleBound = profile.is_google_bound;
56
+ this.isReleaseTypeNotificationsEnabled = profile.is_release_type_notifications_enabled;
57
+ this.isEpisodeNotificationsEnabled = profile.is_episode_notifications_enabled;
58
+ this.isFirstEpisodeNotificationEnabled = profile.is_first_episode_notification_enabled;
59
+ this.isRelatedReleaseNotificationsEnabled = profile.is_related_release_notifications_enabled;
60
+ this.isReportProcessNotificationsEnabled = profile.is_report_process_notifications_enabled;
61
+ this.isCommentNotificationsEnabled = profile.is_comment_notifications_enabled;
62
+ this.isMyCollectionCommentNotificationsEnabled = profile.is_my_collection_comment_notifications_enabled;
63
+ this.watchDynamics = profile.watch_dynamics;
64
+ this.ratingScore = profile.rating_score;
65
+ this.isBlocked = profile.is_blocked;
66
+ this.isMeBlocked = profile.is_me_blocked;
67
+ this.isStatsHidden = profile.is_stats_hidden;
68
+ this.isCountsHidden = profile.is_counts_hidden;
69
+ this.isSocialHidden = profile.is_social_hidden;
70
+ this.isFriendRequestsDisallowed = profile.is_friend_requests_disallowed;
71
+ this.roles = profile.roles;
72
+ this.isPermBanned = profile.is_perm_banned;
73
+ }
74
+ }
75
+ exports.FullProfile = FullProfile;
@@ -0,0 +1,88 @@
1
+ import { Anixart } from "../client";
2
+ import { BookmarkType, IBaseCommentAddRequest, IEpisodeLastUpdate, IRelated, IRelease, IReleaseCategory, IReleaseStatus, ResponseCode } from "../types";
3
+ import { Dubber } from "./Dubber";
4
+ import { ReleaseComment } from "./ReleaseComment";
5
+ export declare class Release {
6
+ private readonly client;
7
+ readonly id: number;
8
+ readonly poster: string;
9
+ readonly image: string;
10
+ readonly year: string;
11
+ readonly genres: string;
12
+ readonly country: string;
13
+ readonly director: string;
14
+ readonly author: string;
15
+ readonly translators: string;
16
+ readonly studio: string;
17
+ readonly description: string;
18
+ readonly note: null;
19
+ readonly related: IRelated;
20
+ readonly category: IReleaseCategory;
21
+ readonly rating: number;
22
+ readonly grade: number;
23
+ readonly status: IReleaseStatus;
24
+ readonly duration: number;
25
+ readonly season: number;
26
+ readonly broadcast: number;
27
+ readonly screenshots: any[];
28
+ readonly comments: any[];
29
+ readonly titleOriginal: string;
30
+ readonly titleRu: string;
31
+ readonly titleAlt: null;
32
+ readonly episodesReleased: number;
33
+ readonly episodesTotal: number;
34
+ readonly releaseDate: string;
35
+ readonly vote1Count: number;
36
+ readonly vote2Count: number;
37
+ readonly vote3Count: number;
38
+ readonly vote4Count: number;
39
+ readonly vote5Count: number;
40
+ readonly voteCount: number;
41
+ readonly creationDate: Date;
42
+ readonly lastUpdateDate: Date;
43
+ readonly airedOnDate: number;
44
+ readonly favoritesCount: number;
45
+ readonly watchingCount: number;
46
+ readonly planCount: number;
47
+ readonly completedCount: number;
48
+ readonly holdOnCount: number;
49
+ readonly droppedCount: number;
50
+ readonly isAdult: boolean;
51
+ readonly isPlayDisabled: boolean;
52
+ readonly isTppDisabled: boolean;
53
+ readonly canVideoAppeal: boolean;
54
+ readonly canTorlookSearch: boolean;
55
+ readonly isDeleted: boolean;
56
+ readonly ageRating: number;
57
+ readonly yourVote: number;
58
+ readonly relatedCount: number;
59
+ readonly commentCount: number;
60
+ readonly commentsCount: number;
61
+ readonly collectionCount: number;
62
+ readonly profileListStatus: number;
63
+ readonly statusId: number;
64
+ readonly lastViewTimestamp: number;
65
+ readonly lastViewEpisode: null;
66
+ readonly isViewed: boolean;
67
+ readonly isFavorite: boolean;
68
+ readonly isViewBlocked: boolean;
69
+ readonly screenshotImages: any[];
70
+ readonly relatedReleases: Release[] | null;
71
+ readonly recommendedReleases: Release[];
72
+ readonly episodeLastUpdate: IEpisodeLastUpdate;
73
+ readonly commentPerDayCount: number;
74
+ readonly videoBanners: any[];
75
+ readonly profileReleaseTypeNotificationPreferenceCount: number;
76
+ readonly isReleaseTypeNotificationsEnabled: boolean;
77
+ constructor(client: Anixart, releaseResponse: IRelease);
78
+ private writeProperties;
79
+ getDubbers(): Promise<Dubber[]>;
80
+ removeFromHistory(): Promise<ResponseCode>;
81
+ setFavorite(favorite: boolean): Promise<ResponseCode>;
82
+ addToList(type: BookmarkType): Promise<ResponseCode>;
83
+ removeFromList(type?: BookmarkType): Promise<ResponseCode>;
84
+ getRelatedReleases(page?: number): Promise<Release[] | null>;
85
+ getComments(page?: number, sort?: number): Promise<ReleaseComment[] | null>;
86
+ addComment(data: IBaseCommentAddRequest): Promise<ReleaseComment | null>;
87
+ addVote(vote: 1 | 2 | 3 | 4 | 5): Promise<ResponseCode>;
88
+ }
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Release = void 0;
4
+ const Dubber_1 = require("./Dubber");
5
+ const ReleaseComment_1 = require("./ReleaseComment");
6
+ class Release {
7
+ constructor(client, releaseResponse) {
8
+ var _a, _b;
9
+ this.client = client;
10
+ this.id = releaseResponse.id;
11
+ this.poster = releaseResponse.poster;
12
+ this.image = releaseResponse.image;
13
+ this.year = releaseResponse.year;
14
+ this.genres = releaseResponse.genres;
15
+ this.country = releaseResponse.country;
16
+ this.director = releaseResponse.director;
17
+ this.author = releaseResponse.author;
18
+ this.translators = releaseResponse.translators;
19
+ this.studio = releaseResponse.studio;
20
+ this.description = releaseResponse.description;
21
+ this.note = releaseResponse.note;
22
+ this.related = releaseResponse.related;
23
+ this.category = releaseResponse.category;
24
+ this.rating = releaseResponse.rating;
25
+ this.grade = releaseResponse.grade;
26
+ this.status = releaseResponse.status;
27
+ this.duration = releaseResponse.duration;
28
+ this.season = releaseResponse.season;
29
+ this.broadcast = releaseResponse.broadcast;
30
+ this.screenshots = releaseResponse.screenshots;
31
+ this.comments = releaseResponse.comments;
32
+ this.titleOriginal = releaseResponse.title_original;
33
+ this.titleRu = releaseResponse.title_ru;
34
+ this.titleAlt = releaseResponse.title_alt;
35
+ this.episodesReleased = releaseResponse.episodes_released;
36
+ this.episodesTotal = releaseResponse.episodes_total;
37
+ this.releaseDate = releaseResponse.release_date;
38
+ this.vote1Count = releaseResponse.vote_1_count;
39
+ this.vote2Count = releaseResponse.vote_2_count;
40
+ this.vote3Count = releaseResponse.vote_3_count;
41
+ this.vote4Count = releaseResponse.vote_4_count;
42
+ this.vote5Count = releaseResponse.vote_5_count;
43
+ this.voteCount = releaseResponse.vote_count;
44
+ this.creationDate = new Date(releaseResponse.creation_date * 1000);
45
+ this.lastUpdateDate = new Date(releaseResponse.last_update_date * 1000);
46
+ this.airedOnDate = releaseResponse.aired_on_date;
47
+ this.favoritesCount = releaseResponse.favorites_count;
48
+ this.watchingCount = releaseResponse.watching_count;
49
+ this.planCount = releaseResponse.plan_count;
50
+ this.completedCount = releaseResponse.completed_count;
51
+ this.holdOnCount = releaseResponse.hold_on_count;
52
+ this.droppedCount = releaseResponse.dropped_count;
53
+ this.isAdult = releaseResponse.is_adult;
54
+ this.isPlayDisabled = releaseResponse.is_play_disabled;
55
+ this.isTppDisabled = releaseResponse.is_tpp_disabled;
56
+ this.canVideoAppeal = releaseResponse.can_video_appeal;
57
+ this.canTorlookSearch = releaseResponse.can_torlook_search;
58
+ this.isDeleted = releaseResponse.is_deleted;
59
+ this.ageRating = releaseResponse.age_rating;
60
+ this.yourVote = releaseResponse.your_vote;
61
+ this.relatedCount = releaseResponse.related_count;
62
+ this.commentCount = releaseResponse.comment_count;
63
+ this.commentsCount = releaseResponse.comments_count;
64
+ this.collectionCount = releaseResponse.collection_count;
65
+ this.profileListStatus = releaseResponse.profile_list_status;
66
+ this.statusId = releaseResponse.status_id;
67
+ this.lastViewTimestamp = releaseResponse.last_view_timestamp;
68
+ this.lastViewEpisode = releaseResponse.last_view_episode;
69
+ this.isViewed = releaseResponse.is_viewed;
70
+ this.isFavorite = releaseResponse.is_favorite;
71
+ this.isViewBlocked = releaseResponse.is_view_blocked;
72
+ this.screenshotImages = releaseResponse.screenshot_images;
73
+ this.relatedReleases = (_a = releaseResponse.related_releases) === null || _a === void 0 ? void 0 : _a.map(release => new Release(this.client, release));
74
+ this.recommendedReleases = (_b = releaseResponse.recommended_releases) === null || _b === void 0 ? void 0 : _b.map(release => new Release(this.client, release));
75
+ this.episodeLastUpdate = releaseResponse.episode_last_update;
76
+ this.commentPerDayCount = releaseResponse.comment_per_day_count;
77
+ this.videoBanners = releaseResponse.video_banners;
78
+ this.profileReleaseTypeNotificationPreferenceCount = releaseResponse.profile_release_type_notification_preference_count;
79
+ this.isReleaseTypeNotificationsEnabled = releaseResponse.is_release_type_notifications_enabled;
80
+ }
81
+ writeProperties(prop, value) {
82
+ this[prop] = value;
83
+ }
84
+ async getDubbers() {
85
+ const request = await this.client.endpoints.release.getDubbers(this.id);
86
+ return request.types.map(dubber => new Dubber_1.Dubber(this.client, dubber, this));
87
+ }
88
+ async removeFromHistory() {
89
+ const request = await this.client.endpoints.release.removeFromHistory(this.id);
90
+ return request.code;
91
+ }
92
+ async setFavorite(favorite) {
93
+ const request = favorite ?
94
+ await this.client.endpoints.release.addFavorite(this.id) :
95
+ await this.client.endpoints.release.removeFavorite(this.id);
96
+ if (request.code == 0) {
97
+ this.writeProperties("isFavorite", favorite);
98
+ }
99
+ return request.code;
100
+ }
101
+ async addToList(type) {
102
+ const request = await this.client.endpoints.release.addToProfileList(this.id, type);
103
+ if (request.code == 0) {
104
+ this.writeProperties("profileListStatus", type);
105
+ }
106
+ return request.code;
107
+ }
108
+ async removeFromList(type) {
109
+ const request = await this.client.endpoints.release.removeFromProfileList(this.id, type ? type : this.profileListStatus);
110
+ if (request.code == 0) {
111
+ this.writeProperties("profileListStatus", null);
112
+ }
113
+ return request.code;
114
+ }
115
+ async getRelatedReleases(page = 0) {
116
+ const request = await this.client.endpoints.release.getRelatedReleases(this.related.id, page);
117
+ return request.code == 0 ? request.content.map(release => new Release(this.client, release)) : null;
118
+ }
119
+ async getComments(page = 0, sort = 0) {
120
+ const request = await this.client.endpoints.release.getComments({ page, sort, id: this.id });
121
+ return request.code == 0 ? request.content.map(comment => new ReleaseComment_1.ReleaseComment(this.client, comment, this)) : null;
122
+ }
123
+ async addComment(data) {
124
+ const request = await this.client.endpoints.release.addComment(this.id, data);
125
+ if (request.code == 0) {
126
+ this.writeProperties("commentCount", this.commentCount + 1);
127
+ this.writeProperties("commentsCount", this.commentsCount + 1);
128
+ }
129
+ return request.code == 0 ? new ReleaseComment_1.ReleaseComment(this.client, request.comment, this) : null;
130
+ }
131
+ async addVote(vote) {
132
+ const request = await this.client.endpoints.release.addVote(this.id, vote);
133
+ if (request.code == 0) {
134
+ this.writeProperties("voteCount", this.voteCount + 1);
135
+ this.writeProperties("yourVote", vote);
136
+ }
137
+ return request.code;
138
+ }
139
+ }
140
+ exports.Release = Release;
@@ -0,0 +1,16 @@
1
+ import { Anixart } from '../client';
2
+ import { ICommentRelease, ResponseCode, VoteType } from '../types';
3
+ import { BaseComment } from './BaseComment';
4
+ import { BaseProfile } from './BaseProfile';
5
+ import { Release } from './Release';
6
+ export declare class ReleaseComment extends BaseComment {
7
+ readonly client: Anixart;
8
+ readonly release: Release;
9
+ constructor(client: Anixart, releaseComment: ICommentRelease, releaseClass?: Release);
10
+ private writeProperties;
11
+ getVotes(page?: number, sort?: number): Promise<BaseProfile[]>;
12
+ getReplies(page?: number, sort?: number): Promise<ReleaseComment[]>;
13
+ delete(): Promise<ResponseCode>;
14
+ setVote(type: VoteType): Promise<ResponseCode>;
15
+ edit(content: string, isSpoiler: boolean): Promise<ResponseCode>;
16
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReleaseComment = void 0;
4
+ const BaseComment_1 = require("./BaseComment");
5
+ const BaseProfile_1 = require("./BaseProfile");
6
+ const Release_1 = require("./Release");
7
+ class ReleaseComment extends BaseComment_1.BaseComment {
8
+ constructor(client, releaseComment, releaseClass) {
9
+ super(client, releaseComment);
10
+ this.client = client;
11
+ this.release = releaseClass !== null && releaseClass !== void 0 ? releaseClass : new Release_1.Release(this.client, releaseComment.release);
12
+ }
13
+ writeProperties(prop, value) {
14
+ this[prop] = value;
15
+ }
16
+ async getVotes(page, sort) {
17
+ const request = await this.client.endpoints.channel.getVotes(this.id, page !== null && page !== void 0 ? page : 0, sort !== null && sort !== void 0 ? sort : 2);
18
+ return request.content.map(profile => new BaseProfile_1.BaseProfile(this.client, profile));
19
+ }
20
+ async getReplies(page, sort) {
21
+ const request = await this.client.endpoints.release.getCommentReplies({ id: this.id, page: page !== null && page !== void 0 ? page : 0, sort: sort !== null && sort !== void 0 ? sort : 2 });
22
+ return request.content.map(comment => new ReleaseComment(this.client, comment));
23
+ }
24
+ async delete() {
25
+ const request = await this.client.endpoints.release.removeComment(this.id);
26
+ return request.code;
27
+ }
28
+ async setVote(type) {
29
+ const request = await this.client.endpoints.release.voteComment(this.id, type);
30
+ if (request.code == 0) {
31
+ this.writeProperties("vote", type == this.vote ? 0 : type);
32
+ }
33
+ return request.code;
34
+ }
35
+ async edit(content, isSpoiler) {
36
+ const request = await this.client.endpoints.release.editComment(this.id, content, isSpoiler);
37
+ if (request.code == 0) {
38
+ this.writeProperties("message", content);
39
+ this.writeProperties("isSpoiler", isSpoiler);
40
+ }
41
+ return request.code;
42
+ }
43
+ }
44
+ exports.ReleaseComment = ReleaseComment;