-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
218 lines (201 loc) · 5.9 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* IDK :) */
global.APIsFSPR = {};
global.APIFSPR = (name, path = "/", query = {}, apikeyqueryname) =>
(name in global.APIsFSPR ? global.APIsFSPR[name] : name) +
path +
(query || apikeyqueryname
? "?" +
new URLSearchParams(
Object.entries({
...query,
...(apikeyqueryname
? {
[apikeyqueryname]:
global.APIsFSPR[
name in global.APIsFSPR ? global.APIsFSPR[name] : name
],
}
: {}),
}),
)
: "");
global.resolveFSPR = (...args) => {
let data;
if (typeof args[0] === "object") {
data = args[0];
} else {
data = args.join(" ");
}
return {
status: 200,
data: data,
msg: null,
};
};
global.rejectFSPR = (msg) => {
return {
status: 404,
msg: msg?.message || msg,
data: null,
};
};
global.throwFSPR = (...args) => {
var data = global.resolveFSPR(...args);
data.status = 404;
data.msg = data.data;
data.data = null;
throw new Error(JSON.stringify(data));
};
global.isUrlFSPR = (str) => /^https?:\/\//.test(str);
/* DOWNLOADER */
const TiktokDownloader = require("./lib/Downloaders/Tiktok-Downloader.js");
const InstagramDownloader = require("./lib/Downloaders/Instagram-Downloader.js");
const CapcutDownloader = require("./lib/Downloaders/Capcut-Downloader.js");
const DriveDownloader = require("./lib/Downloaders/Drive-Downloader.js");
const MediaFireDownloader = require("./lib/Downloaders/MediaFire-Downloader.js");
const FacebookDownloader = require("./lib/Downloaders/Facebook-Downloader.js");
const TwitterDownloader = require("./lib/Downloaders/Twitter-Downloader.js");
const SpotifyDownloader = require("./lib/Downloaders/Spotify-Downloader.js");
const PinterestDownloader = require("./lib/Downloaders/Pinterest-Downloader.js");
const YouTubeDownloader = require("./lib/Downloaders/YouTube-Downloader.js");
const SfileDownloader = require("./lib/Downloaders/Sfile-Downloader.js");
/* AI */
const GGemini = require("./lib/AI/G-Gemini.js");
const FAIIGGTranslate = require("./lib/AI/FAIIGG-Translate.js");
const KarloAI = require("./lib/AI/KarloAI.js");
const AiRateMyPhoto = require("./lib/AI/RateMyPhoto.js");
/* TOOLS */
const ToolGtts = require("./lib/Tools/Gtts.js");
const ToolTranslator = require("./lib/Tools/Translator.js");
const ToolGLens = require("./lib/Tools/GoogleLens.js");
const ToolRemoveBackground = require("./lib/Tools/RemoveBackground.js");
const ToolDiscordCloud = require("./lib/Tools/DiscordCloud.js");
/* Search */
const YouTubeScraperSearch = require("./lib/Search/YouTubeSearch.js");
const YouTubeScraperChannel = require("./lib/Search/YouTubeChannel.js");
/* SHORT URL */
const Short1 = require("./lib/Shorts/Shorter.Me.js");
/* FUNCTIONS */
function downloadTiktokVideo(url) {
return new Promise((resolve, reject) => {
TiktokDownloader.tikVideo(url).then(resolve).catch(reject);
});
}
function downloadTiktokUser(url) {
return new Promise((resolve, reject) => {
TiktokDownloader.tikUser(url).then(resolve).catch(reject);
});
}
function downloadYouTubeSearch(...q) {
return new Promise((resolve, reject) => {
new YouTubeScraperChannel()
.search(...q)
.then(resolve)
.catch(reject);
});
}
function downloadYouTube(...args) {
return new Promise((resolve, reject) => {
YouTubeDownloader(/*.ytdl*/ ...args)
.then(resolve)
.catch(reject);
});
}
/* AUTO DOWNLOADER BY URL */
function downloadByService(url) {
return new Promise(async (resolve, reject) => {
if (url.match(/tiktok/i)) {
resolve({
type: "tiktok",
...(await downloadTiktokVideo(url)),
});
} else if (url.match(/instagram/i)) {
resolve({
type: "instagram",
...(await InstagramDownloader(url)),
});
} else if (url.match(/capcut/i)) {
resolve({
type: "capcut",
...(await CapcutDownloader(url)),
});
} else if (url.match(/drive\.google\.com/i)) {
resolve({
type: "drive",
...(await DriveDownloader(url)),
});
} else if (url.match(/mediafire/i)) {
resolve({
type: "mediafire",
...(await MediaFireDownloader(url)),
});
} else if (url.match(/facebook/i)) {
resolve({
type: "facebook",
...(await FacebookDownloader(url)),
});
} else if (url.match(/x\.com|twitter\.com/i)) {
resolve({
type: "twitter",
...(await TwitterDownloader(url)),
});
} else if (url.match(/spotify/i)) {
resolve({
type: "spotify",
...(await SpotifyDownloader(url)),
});
} else if (url.match(/pinterest\.com|pin\.it/i)) {
resolve({
type: "pinterest",
...(await PinterestDownloader(url)),
});
} else if (url.match(/youtube\.com/i)) {
resolve({
type: "youtube",
...(await downloadYouTube(url)),
});
} else if (url.match(/sfile\.mobi/i)) {
resolve({
type: "sfile",
...(await SfileDownloader(url)),
});
} else {
reject(global.rejectFSPR("Unsupported service or invalid URL"));
}
});
}
/* IMPORT ALL */
module.exports = {
/* DOWNLOADER */
AutoDL: downloadByService,
TiktokVideo: downloadTiktokVideo,
TiktokUser: downloadTiktokUser,
Instagram: InstagramDownloader,
Capcut: CapcutDownloader,
Drive: DriveDownloader,
MediaFire: MediaFireDownloader,
Facebook: FacebookDownloader,
Twitter: TwitterDownloader,
Spotify: SpotifyDownloader,
Pinterest: PinterestDownloader,
Sfile: SfileDownloader,
YouTube: {
search: downloadYouTubeSearch,
channelInfo: YouTubeScraperChannel,
down: downloadYouTube,
},
/* AI */
//GGemini, //Not yet fixed
FAIIGGTranslate,
KarloAI,
AiRateMyPhoto,
/* TOOLS */
Gtts: ToolGtts,
Translator: ToolTranslator,
GoogleLens: ToolGLens,
RemoveBg: ToolRemoveBackground,
DiscordCloud: ToolDiscordCloud,
/* Search */
/* SHORT URL */
Short1,
};