@irfanshadikrishad/anilist 1.8.0 → 2.0.0-forbidden
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.
- package/LICENSE.md +382 -0
- package/README.md +0 -1
- package/bin/helpers/auth.d.ts +5 -0
- package/bin/helpers/auth.js +352 -18
- package/bin/helpers/lists.d.ts +1 -5
- package/bin/helpers/lists.js +19 -141
- package/bin/helpers/mutations.d.ts +2 -2
- package/bin/helpers/mutations.js +6 -9
- package/bin/helpers/queries.d.ts +4 -1
- package/bin/helpers/queries.js +35 -1
- package/bin/helpers/types.d.ts +53 -15
- package/bin/helpers/validation.d.ts +2 -2
- package/bin/helpers/validation.js +3 -3
- package/bin/helpers/workers.d.ts +3 -2
- package/bin/helpers/workers.js +22 -2
- package/bin/index.js +8 -22
- package/package.json +8 -9
- package/CITATION.cff +0 -8
- /package/bin/{lib → helpers/lib}/colorize.d.ts +0 -0
- /package/bin/{lib → helpers/lib}/colorize.js +0 -0
package/bin/helpers/auth.js
CHANGED
|
@@ -14,16 +14,17 @@ import fetch from 'node-fetch';
|
|
|
14
14
|
import open from 'open';
|
|
15
15
|
import os from 'os';
|
|
16
16
|
import path from 'path';
|
|
17
|
+
import { exit } from 'process';
|
|
17
18
|
import Spinner from 'tiny-spinner';
|
|
18
|
-
import { colorize } from '../lib/colorize.js';
|
|
19
19
|
import { fetcher } from './fetcher.js';
|
|
20
|
+
import { colorize } from './lib/colorize.js';
|
|
20
21
|
import { AniDB, AniList, MyAnimeList } from './lists.js';
|
|
21
|
-
import { deleteActivityMutation, deleteMangaEntryMutation, deleteMediaEntryMutation, saveTextActivityMutation, toggleFollowMutation, } from './mutations.js';
|
|
22
|
-
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, } from './queries.js';
|
|
22
|
+
import { deleteActivityMutation, deleteMangaEntryMutation, deleteMediaEntryMutation, likeActivityMutation, saveTextActivityMutation, toggleFollowMutation, } from './mutations.js';
|
|
23
|
+
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, followingActivitiesQuery, globalActivitiesQuery, specificUserActivitiesQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, userQuery, } from './queries.js';
|
|
23
24
|
import { responsiveOutput } from './truncate.js';
|
|
24
|
-
import { aniListEndpoint, getTitle, redirectUri, timestampToTimeAgo, } from './workers.js';
|
|
25
|
+
import { activityBy, aniListEndpoint, getTitle, redirectUri, timestampToTimeAgo, } from './workers.js';
|
|
25
26
|
const home_dir = os.homedir();
|
|
26
|
-
const save_path = path.join(home_dir, '.
|
|
27
|
+
const save_path = path.join(home_dir, '.anilist_token');
|
|
27
28
|
const spinner = new Spinner();
|
|
28
29
|
const vigenere = new Cipher.Vigenere('anilist');
|
|
29
30
|
class Auth {
|
|
@@ -318,7 +319,7 @@ Statistics (Manga):
|
|
|
318
319
|
const isDeleted = (_f = (_e = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _e === void 0 ? void 0 : _e.DeleteActivity) === null || _f === void 0 ? void 0 : _f.deleted;
|
|
319
320
|
count++;
|
|
320
321
|
totalCount++;
|
|
321
|
-
console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? '✔' : '✘'}`);
|
|
322
|
+
console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? colorize.Green('✔') : colorize.Red('✘')}`);
|
|
322
323
|
// Avoiding rate-limit
|
|
323
324
|
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
324
325
|
}
|
|
@@ -395,7 +396,7 @@ Statistics (Manga):
|
|
|
395
396
|
const response = yield fetcher(deleteMediaEntryMutation, { id: id });
|
|
396
397
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
397
398
|
const deleted = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.DeleteMediaListEntry) === null || _b === void 0 ? void 0 : _b.deleted;
|
|
398
|
-
console.log(`del ${title ? getTitle(title) : ''} ${deleted ? '✔' : '✘'}`);
|
|
399
|
+
console.log(`del ${title ? getTitle(title) : ''} ${deleted ? colorize.Green('✔') : colorize.Red('✘')}`);
|
|
399
400
|
}
|
|
400
401
|
else {
|
|
401
402
|
console.log(`\nError deleting anime. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _c === void 0 ? void 0 : _c.message}`);
|
|
@@ -470,7 +471,7 @@ Statistics (Manga):
|
|
|
470
471
|
const statusMessage = title ? getTitle(title) : '';
|
|
471
472
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
472
473
|
const deleted = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.DeleteMediaListEntry) === null || _b === void 0 ? void 0 : _b.deleted;
|
|
473
|
-
console.log(`del ${statusMessage} ${deleted ? '✔' : '✘'}`);
|
|
474
|
+
console.log(`del ${statusMessage} ${deleted ? colorize.Green('✔') : colorize.Red('✘')}`);
|
|
474
475
|
}
|
|
475
476
|
else {
|
|
476
477
|
console.error(`Error deleting manga. ${(_d = (_c = response === null || response === void 0 ? void 0 : response.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
@@ -572,6 +573,342 @@ Statistics (Manga):
|
|
|
572
573
|
}
|
|
573
574
|
});
|
|
574
575
|
}
|
|
576
|
+
static LikeFollowing() {
|
|
577
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
+
var _a, _b, _c, _d, _e, _f;
|
|
579
|
+
try {
|
|
580
|
+
let page = 1;
|
|
581
|
+
let hasMoreActivities = true;
|
|
582
|
+
let retryCount = 0;
|
|
583
|
+
const maxRetries = 5;
|
|
584
|
+
let likedCount = 0;
|
|
585
|
+
while (hasMoreActivities) {
|
|
586
|
+
const activities = yield fetcher(followingActivitiesQuery, {
|
|
587
|
+
page,
|
|
588
|
+
perPage: 50,
|
|
589
|
+
});
|
|
590
|
+
if (activities && ((_b = (_a = activities === null || activities === void 0 ? void 0 : activities.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities.length) > 0) {
|
|
591
|
+
spinner.success(`Got ${(_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities.length} activities..`);
|
|
592
|
+
retryCount = 0; // Reset retry count on successful fetch
|
|
593
|
+
const activiti = (_f = (_e = activities === null || activities === void 0 ? void 0 : activities.data) === null || _e === void 0 ? void 0 : _e.Page) === null || _f === void 0 ? void 0 : _f.activities;
|
|
594
|
+
for (let activ of activiti) {
|
|
595
|
+
if (!activ.isLiked && activ.id) {
|
|
596
|
+
try {
|
|
597
|
+
const like = yield fetcher(likeActivityMutation, {
|
|
598
|
+
activityId: activ.id,
|
|
599
|
+
});
|
|
600
|
+
if (like === null || like === void 0 ? void 0 : like.data) {
|
|
601
|
+
likedCount++;
|
|
602
|
+
}
|
|
603
|
+
responsiveOutput(`${(like === null || like === void 0 ? void 0 : like.data) ? colorize.Green('✔') : colorize.Red('✘')} ${activityBy(activ, likedCount)}`);
|
|
604
|
+
}
|
|
605
|
+
catch (error) {
|
|
606
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
responsiveOutput(`${colorize.Yellow('⚉')} ${activityBy(activ, likedCount)}`);
|
|
611
|
+
}
|
|
612
|
+
// avoiding rate-limit
|
|
613
|
+
yield new Promise((resolve) => {
|
|
614
|
+
setTimeout(resolve, 2000);
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
page++;
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
if (retryCount < maxRetries) {
|
|
621
|
+
spinner.start('Getting activities...');
|
|
622
|
+
retryCount++;
|
|
623
|
+
spinner.update(`Empty activities returned. Retrying... (${retryCount}/${maxRetries})`);
|
|
624
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
spinner.error(`Probably the end of activities after ${maxRetries} retries.`);
|
|
628
|
+
hasMoreActivities = false;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
catch (error) {
|
|
634
|
+
console.error(`\nError from likeFollowing. ${error.message}`);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
static LikeGlobal() {
|
|
639
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
640
|
+
var _a, _b, _c, _d, _e, _f;
|
|
641
|
+
try {
|
|
642
|
+
let page = 1;
|
|
643
|
+
let hasMoreActivities = true;
|
|
644
|
+
let likedCount = 0;
|
|
645
|
+
spinner.start(`Getting global activities...`);
|
|
646
|
+
while (hasMoreActivities) {
|
|
647
|
+
const activities = yield fetcher(globalActivitiesQuery, {
|
|
648
|
+
page,
|
|
649
|
+
perPage: 50,
|
|
650
|
+
});
|
|
651
|
+
if (activities && ((_b = (_a = activities === null || activities === void 0 ? void 0 : activities.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities.length) > 0) {
|
|
652
|
+
const activiti = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
|
|
653
|
+
spinner.success(`Got ${activiti.length} activities...`);
|
|
654
|
+
for (let activ of activiti) {
|
|
655
|
+
if (!activ.isLiked && activ.id) {
|
|
656
|
+
try {
|
|
657
|
+
const like = yield fetcher(likeActivityMutation, {
|
|
658
|
+
activityId: activ.id,
|
|
659
|
+
});
|
|
660
|
+
// const ToggleLike = like?.data?.ToggleLike
|
|
661
|
+
likedCount++;
|
|
662
|
+
responsiveOutput(`${(like === null || like === void 0 ? void 0 : like.data) ? colorize.Green('✔') : colorize.Red('✘')} ${activityBy(activ, likedCount)}`);
|
|
663
|
+
}
|
|
664
|
+
catch (error) {
|
|
665
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
responsiveOutput(`${colorize.Yellow('⚉')} ${activityBy(activ, likedCount)}`);
|
|
670
|
+
}
|
|
671
|
+
// avoiding rate-limit
|
|
672
|
+
yield new Promise((resolve) => {
|
|
673
|
+
setTimeout(resolve, 1500);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
page++;
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
// No more activities to like
|
|
680
|
+
spinner.error(`Probably the end of activities. ${(_f = (_e = activities === null || activities === void 0 ? void 0 : activities.data) === null || _e === void 0 ? void 0 : _e.Page) === null || _f === void 0 ? void 0 : _f.activities}`);
|
|
681
|
+
hasMoreActivities = false;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
console.error(`\nError from likeFollowing. ${error.message}`);
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
static LikeSpecificUser() {
|
|
691
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
692
|
+
var _a, _b, _c, _d;
|
|
693
|
+
try {
|
|
694
|
+
const { username } = yield inquirer.prompt([
|
|
695
|
+
{
|
|
696
|
+
type: 'input',
|
|
697
|
+
name: 'username',
|
|
698
|
+
message: 'Username of the user:',
|
|
699
|
+
},
|
|
700
|
+
]);
|
|
701
|
+
const { toLikeAmount } = yield inquirer.prompt([
|
|
702
|
+
{
|
|
703
|
+
type: 'number',
|
|
704
|
+
name: 'toLikeAmount',
|
|
705
|
+
message: 'Likes to give:',
|
|
706
|
+
},
|
|
707
|
+
]);
|
|
708
|
+
const userDetails = yield fetcher(userQuery, { username: username });
|
|
709
|
+
spinner.start(`Getting activities by ${username}`);
|
|
710
|
+
if ((_b = (_a = userDetails === null || userDetails === void 0 ? void 0 : userDetails.data) === null || _a === void 0 ? void 0 : _a.User) === null || _b === void 0 ? void 0 : _b.id) {
|
|
711
|
+
let page = 1;
|
|
712
|
+
const perPage = 50;
|
|
713
|
+
const userId = userDetails.data.User.id;
|
|
714
|
+
let likedCount = 0;
|
|
715
|
+
while (likedCount < toLikeAmount) {
|
|
716
|
+
const activities = yield fetcher(specificUserActivitiesQuery, {
|
|
717
|
+
page,
|
|
718
|
+
perPage,
|
|
719
|
+
userId,
|
|
720
|
+
});
|
|
721
|
+
const activiti = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
|
|
722
|
+
if (!activiti || activiti.length === 0) {
|
|
723
|
+
spinner.error('No more activities found.');
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
spinner.success(`Got ${activiti.length} activities...`);
|
|
727
|
+
for (let activ of activiti) {
|
|
728
|
+
if (!activ.isLiked && activ.id) {
|
|
729
|
+
try {
|
|
730
|
+
const like = yield fetcher(likeActivityMutation, {
|
|
731
|
+
activityId: activ.id,
|
|
732
|
+
});
|
|
733
|
+
likedCount++;
|
|
734
|
+
responsiveOutput(`${(like === null || like === void 0 ? void 0 : like.data) ? colorize.Green('✔') : colorize.Red('✘')} ${activityBy(activ, likedCount)}`);
|
|
735
|
+
if (likedCount >= toLikeAmount) {
|
|
736
|
+
spinner.success(`Finished liking ${likedCount} activities of ${username}.`);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
catch (error) {
|
|
741
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
responsiveOutput(`${colorize.Yellow('⚉')} ${activityBy(activ, likedCount)}`);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
page += 1;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
spinner.error(`User ${username} does not exist.`);
|
|
753
|
+
exit(1);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
catch (error) {
|
|
757
|
+
console.error(`\nError from LikeSpecificUser. ${error.message}`);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
static LikeFollowingActivityV2(perPage) {
|
|
762
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
763
|
+
var _a, _b, _c, _d, _e;
|
|
764
|
+
try {
|
|
765
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
766
|
+
console.error(`\nPlease log in to use this feature.`);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const allFollowingUsers = [];
|
|
770
|
+
let hasNextPage = true;
|
|
771
|
+
let page = 1;
|
|
772
|
+
let liked = 0;
|
|
773
|
+
// ------------------------
|
|
774
|
+
// Fetch all following users
|
|
775
|
+
// ------------------------
|
|
776
|
+
spinner.start(`Gathering following information...`);
|
|
777
|
+
while (hasNextPage) {
|
|
778
|
+
spinner.update(`Fetched page ${page}...`);
|
|
779
|
+
const followingUsers = yield fetcher(userFollowingQuery, {
|
|
780
|
+
userId: yield Auth.MyUserId(),
|
|
781
|
+
page,
|
|
782
|
+
});
|
|
783
|
+
if (!((_b = (_a = followingUsers === null || followingUsers === void 0 ? void 0 : followingUsers.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.following)) {
|
|
784
|
+
console.error(`\nFailed to fetch following users.`);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
allFollowingUsers.push(...followingUsers.data.Page.following);
|
|
788
|
+
hasNextPage = followingUsers.data.Page.pageInfo.hasNextPage;
|
|
789
|
+
page++;
|
|
790
|
+
}
|
|
791
|
+
spinner.stop(`Got ${allFollowingUsers.length} following user.`);
|
|
792
|
+
// Extract the IDs of all following users
|
|
793
|
+
const followingUserIds = allFollowingUsers.map((user) => user.id);
|
|
794
|
+
// --------------------
|
|
795
|
+
// APPROXIMATE TIME
|
|
796
|
+
// --------------------
|
|
797
|
+
const totalActivities = followingUserIds.length * perPage;
|
|
798
|
+
const perActivityTimeInSec = 1;
|
|
799
|
+
const rateLimitTimeInSec = 60;
|
|
800
|
+
const batchSize = 29;
|
|
801
|
+
const batches = Math.floor(totalActivities / batchSize);
|
|
802
|
+
const remaining = totalActivities % batchSize;
|
|
803
|
+
const processingTime = batches * batchSize * perActivityTimeInSec +
|
|
804
|
+
remaining * perActivityTimeInSec;
|
|
805
|
+
const waitTime = (batches - 1) * rateLimitTimeInSec;
|
|
806
|
+
const totalWaitTimeInSec = processingTime + (batches > 0 ? waitTime : 0);
|
|
807
|
+
const hours = Math.floor(totalWaitTimeInSec / 3600);
|
|
808
|
+
const minutes = Math.floor((totalWaitTimeInSec % 3600) / 60);
|
|
809
|
+
const seconds = totalWaitTimeInSec % 60;
|
|
810
|
+
const time = `${String(hours).padStart(2, '0')}h ${String(minutes).padStart(2, '0')}m ${String(seconds).padStart(2, '0')}s`;
|
|
811
|
+
console.log(`\nTotal following: ${followingUserIds.length}\nApproximately ${totalActivities} to like.\nWill take around ${time}`);
|
|
812
|
+
// -------------------
|
|
813
|
+
// Traverse the array and
|
|
814
|
+
// fetch users' activities one by one
|
|
815
|
+
// -------------------
|
|
816
|
+
let userNumber = 0;
|
|
817
|
+
for (const userId of followingUserIds) {
|
|
818
|
+
userNumber++;
|
|
819
|
+
console.log(`\n[${userNumber}]\tID: ${userId}`);
|
|
820
|
+
// Fetch `perPage` activities for the current user
|
|
821
|
+
const activities = yield fetcher(specificUserActivitiesQuery, {
|
|
822
|
+
userId,
|
|
823
|
+
page: 1, // Always fetch from the first page
|
|
824
|
+
perPage,
|
|
825
|
+
});
|
|
826
|
+
if (!((_e = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities) === null || _e === void 0 ? void 0 : _e.length)) {
|
|
827
|
+
console.log(`[${userNumber}] No activities found for User ID: ${userId}`);
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
const activiti = activities.data.Page.activities;
|
|
831
|
+
for (let i = 0; i < activiti.length; i++) {
|
|
832
|
+
const activ = activiti[i];
|
|
833
|
+
if (!activ.isLiked && activ.id) {
|
|
834
|
+
try {
|
|
835
|
+
const like = yield fetcher(likeActivityMutation, {
|
|
836
|
+
activityId: activ.id,
|
|
837
|
+
});
|
|
838
|
+
responsiveOutput(`${(like === null || like === void 0 ? void 0 : like.data) ? colorize.Green('✔') : colorize.Red('✘')} ${activityBy(activ, i + 1)}`);
|
|
839
|
+
if (like === null || like === void 0 ? void 0 : like.data) {
|
|
840
|
+
liked++;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
catch (error) {
|
|
844
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
responsiveOutput(`${colorize.Yellow('⚉')} ${activityBy(activ, i + 1)}`);
|
|
849
|
+
}
|
|
850
|
+
// Avoid rate-limiting
|
|
851
|
+
yield new Promise((resolve) => setTimeout(resolve, 1200));
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
console.log(`\n${colorize.Green('✔')} All ${liked} activities liked successfully.`);
|
|
855
|
+
}
|
|
856
|
+
catch (error) {
|
|
857
|
+
console.error(`\nError in LikeFollowingActivityV2: ${error.message}`);
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
static AutoLike() {
|
|
862
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
863
|
+
try {
|
|
864
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
865
|
+
console.error(`\nPlease login to use this feature.`);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
const { activityType } = yield inquirer.prompt([
|
|
869
|
+
{
|
|
870
|
+
type: 'list',
|
|
871
|
+
name: 'activityType',
|
|
872
|
+
message: 'Select activity type:',
|
|
873
|
+
choices: [
|
|
874
|
+
{ name: 'Following • v1', value: 1 },
|
|
875
|
+
{ name: 'Following • v2', value: 2 },
|
|
876
|
+
{ name: 'Global', value: 3 },
|
|
877
|
+
{ name: 'Specific User', value: 4 },
|
|
878
|
+
],
|
|
879
|
+
pageSize: 10,
|
|
880
|
+
},
|
|
881
|
+
]);
|
|
882
|
+
switch (activityType) {
|
|
883
|
+
case 1:
|
|
884
|
+
yield this.LikeFollowing();
|
|
885
|
+
break;
|
|
886
|
+
case 2: {
|
|
887
|
+
const { count } = yield inquirer.prompt([
|
|
888
|
+
{
|
|
889
|
+
type: 'number',
|
|
890
|
+
name: 'count',
|
|
891
|
+
message: 'Likes to give:',
|
|
892
|
+
},
|
|
893
|
+
]);
|
|
894
|
+
yield this.LikeFollowingActivityV2(count);
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
897
|
+
case 3:
|
|
898
|
+
yield this.LikeGlobal();
|
|
899
|
+
break;
|
|
900
|
+
case 4:
|
|
901
|
+
yield this.LikeSpecificUser();
|
|
902
|
+
break;
|
|
903
|
+
default:
|
|
904
|
+
console.error(`\nInvalid choice. (${activityType})`);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
catch (error) {
|
|
908
|
+
console.error(`\nError from autolike. ${error.message}`);
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
}
|
|
575
912
|
}
|
|
576
913
|
class Social {
|
|
577
914
|
/**
|
|
@@ -583,7 +920,7 @@ class Social {
|
|
|
583
920
|
try {
|
|
584
921
|
let pager = 1;
|
|
585
922
|
let hasNextPage = true;
|
|
586
|
-
|
|
923
|
+
let allFollowerUsers = [];
|
|
587
924
|
let followedBack = 0;
|
|
588
925
|
spinner.start('Fetching all the followers...');
|
|
589
926
|
while (hasNextPage) {
|
|
@@ -611,13 +948,10 @@ class Social {
|
|
|
611
948
|
// Traverse and follow back
|
|
612
949
|
const maxIdLength = Math.max(...notFollowing.map(({ id }) => String(id).length));
|
|
613
950
|
const maxNameLength = Math.max(...notFollowing.map(({ name }) => name.length));
|
|
614
|
-
for (
|
|
951
|
+
for (let nf of notFollowing) {
|
|
615
952
|
try {
|
|
616
953
|
const follow = yield fetcher(toggleFollowMutation, { userId: nf.id });
|
|
617
|
-
console.log(`${String(`[${nf.id}]`).padEnd(maxIdLength)}`
|
|
618
|
-
`\t${String(`[${(_k = (_j = follow === null || follow === void 0 ? void 0 : follow.data) === null || _j === void 0 ? void 0 : _j.ToggleFollow) === null || _k === void 0 ? void 0 : _k.name}]`).padEnd(maxNameLength)}` +
|
|
619
|
-
`\t${((_m = (_l = follow === null || follow === void 0 ? void 0 : follow.data) === null || _l === void 0 ? void 0 : _l.ToggleFollow) === null || _m === void 0 ? void 0 : _m.id) ? colorize.Green('✔') : colorize.Red('✘')}`);
|
|
620
|
-
// Count the followed back users
|
|
954
|
+
console.log(`${String(`[${nf.id}]`).padEnd(maxIdLength)}\t${String(`[${(_k = (_j = follow === null || follow === void 0 ? void 0 : follow.data) === null || _j === void 0 ? void 0 : _j.ToggleFollow) === null || _k === void 0 ? void 0 : _k.name}]`).padEnd(maxNameLength)}\t${((_m = (_l = follow === null || follow === void 0 ? void 0 : follow.data) === null || _l === void 0 ? void 0 : _l.ToggleFollow) === null || _m === void 0 ? void 0 : _m.id) ? colorize.Green('✔') : colorize.Red('✘')}`); // Count the followed back users
|
|
621
955
|
if ((_p = (_o = follow === null || follow === void 0 ? void 0 : follow.data) === null || _o === void 0 ? void 0 : _o.ToggleFollow) === null || _p === void 0 ? void 0 : _p.id) {
|
|
622
956
|
followedBack++;
|
|
623
957
|
}
|
|
@@ -642,7 +976,7 @@ class Social {
|
|
|
642
976
|
try {
|
|
643
977
|
let pager = 1;
|
|
644
978
|
let hasNextPage = true;
|
|
645
|
-
|
|
979
|
+
let allFollowingUsers = [];
|
|
646
980
|
let unfollowedUsers = 0;
|
|
647
981
|
spinner.start('Fetching all following users...');
|
|
648
982
|
while (hasNextPage) {
|
|
@@ -657,7 +991,7 @@ class Social {
|
|
|
657
991
|
allFollowingUsers.push(...(((_h = (_g = followingUsers === null || followingUsers === void 0 ? void 0 : followingUsers.data) === null || _g === void 0 ? void 0 : _g.Page) === null || _h === void 0 ? void 0 : _h.following) || []));
|
|
658
992
|
pager++;
|
|
659
993
|
}
|
|
660
|
-
spinner.update(
|
|
994
|
+
spinner.update(`Fetching complete. Total got ${allFollowingUsers.length} users.`);
|
|
661
995
|
// Filter users that do no follow me
|
|
662
996
|
const notFollowingMe = allFollowingUsers
|
|
663
997
|
.filter((user) => !user.isFollower)
|
|
@@ -669,7 +1003,7 @@ class Social {
|
|
|
669
1003
|
spinner.stop(`Unfollow process activated with ${notFollowingMe.length} users.`);
|
|
670
1004
|
let nfmCount = 0;
|
|
671
1005
|
console.log(`\n`);
|
|
672
|
-
for (
|
|
1006
|
+
for (let nfm of notFollowingMe) {
|
|
673
1007
|
nfmCount++;
|
|
674
1008
|
try {
|
|
675
1009
|
const unfollow = yield fetcher(toggleFollowMutation, {
|
|
@@ -685,7 +1019,7 @@ class Social {
|
|
|
685
1019
|
console.log(`unfollow_toggle_follow. ${error.message}`);
|
|
686
1020
|
}
|
|
687
1021
|
}
|
|
688
|
-
console.log(`\
|
|
1022
|
+
console.log(`\n${colorize.Green('✔')} Total Unfollowed: ${unfollowedUsers} of ${nfmCount} users.`);
|
|
689
1023
|
}
|
|
690
1024
|
catch (error) {
|
|
691
1025
|
console.error(`\nautomate_unfollow: ${error.message}`);
|
package/bin/helpers/lists.d.ts
CHANGED
|
@@ -23,8 +23,4 @@ declare class MyAnimeList {
|
|
|
23
23
|
declare class AniDB {
|
|
24
24
|
static importAnime(): Promise<void>;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
static AnimeList(): Promise<void>;
|
|
28
|
-
static MangaList(): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
export { AniDB, AniList, MoveTo, MyAnimeList };
|
|
26
|
+
export { AniDB, AniList, MyAnimeList };
|