HerzaJ commited on
Commit
558ea6b
·
verified ·
1 Parent(s): 5cd1bac

Update plugins/suno4.js

Browse files
Files changed (1) hide show
  1. plugins/suno4.js +68 -15
plugins/suno4.js CHANGED
@@ -1,5 +1,18 @@
1
  const axios = require('axios');
2
  const crypto = require('crypto');
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  const aiMu = {
5
  api: {
@@ -35,9 +48,17 @@ const aiMu = {
35
 
36
  opts: async () => {
37
  try {
 
 
 
 
 
 
 
 
38
  const res = await axios.get(
39
  `${aiMu.api.base}${aiMu.api.endpoint.options}`,
40
- { headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() } }
41
  );
42
 
43
  const { code, msg, data } = res.data;
@@ -83,9 +104,17 @@ const aiMu = {
83
 
84
  getCredits: async () => {
85
  try {
 
 
 
 
 
 
 
 
86
  const res = await axios.get(
87
  `${aiMu.api.base}${aiMu.api.endpoint.credits}`,
88
- { headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() } }
89
  );
90
  const { code, msg, data } = res.data;
91
  if (code === 200) {
@@ -154,16 +183,24 @@ const aiMu = {
154
  const payload = { make_instrumental, vocal_only, lyrics, prompt, ...params };
155
 
156
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  const res = await axios.post(
158
  `${aiMu.api.base}${aiMu.api.endpoint.musicAI}`,
159
  payload,
160
- {
161
- headers: {
162
- ...aiMu.headers,
163
- 'content-type': 'application/json',
164
- 'x-device-id': aiMu.getDeviceId(),
165
- },
166
- }
167
  );
168
  const { code, msg, data } = res.data;
169
  if (code === 200) {
@@ -214,12 +251,20 @@ const aiMu = {
214
  };
215
  }
216
  try {
 
 
 
 
 
 
 
 
 
 
 
217
  const res = await axios.get(
218
  `${aiMu.api.base}${aiMu.api.endpoint.taskStatus}`,
219
- {
220
- params: { task_id: taskId },
221
- headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() },
222
- }
223
  );
224
  const { code, msg, data } = res.data;
225
  if (code === 200) {
@@ -257,9 +302,17 @@ const aiMu = {
257
 
258
  getGenerateList: async () => {
259
  try {
 
 
 
 
 
 
 
 
260
  const res = await axios.get(
261
  `${aiMu.api.base}${aiMu.api.endpoint.generateList}`,
262
- { headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() } }
263
  );
264
  const { code, msg, data } = res.data;
265
  if (code === 200) {
@@ -403,7 +456,7 @@ const handler = async (req, res) => {
403
  };
404
 
405
  module.exports = {
406
- name: 'SunoV4 Music Generator',
407
  description: 'Generate music using AiMu AI model',
408
  type: 'GET',
409
  routes: ['api/AI/suno4'],
 
1
  const axios = require('axios');
2
  const crypto = require('crypto');
3
+ const HttpProxyAgent = require('http-proxy-agent');
4
+ const HttpsProxyAgent = require('https-proxy-agent');
5
+
6
+ async function getRandomProxy() {
7
+ try {
8
+ const response = await axios.get('https://raw.githubusercontent.com/proxifly/free-proxy-list/refs/heads/main/proxies/protocols/https/data.json');
9
+ const proxies = response.data;
10
+ if (proxies.length === 0) return null;
11
+ return proxies[Math.floor(Math.random() * proxies.length)].proxy;
12
+ } catch (err) {
13
+ return null;
14
+ }
15
+ }
16
 
17
  const aiMu = {
18
  api: {
 
48
 
49
  opts: async () => {
50
  try {
51
+ const proxyUrl = await getRandomProxy();
52
+ const axiosConfig = { headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() } };
53
+
54
+ if (proxyUrl) {
55
+ axiosConfig.httpAgent = new HttpProxyAgent(proxyUrl);
56
+ axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
57
+ }
58
+
59
  const res = await axios.get(
60
  `${aiMu.api.base}${aiMu.api.endpoint.options}`,
61
+ axiosConfig
62
  );
63
 
64
  const { code, msg, data } = res.data;
 
104
 
105
  getCredits: async () => {
106
  try {
107
+ const proxyUrl = await getRandomProxy();
108
+ const axiosConfig = { headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() } };
109
+
110
+ if (proxyUrl) {
111
+ axiosConfig.httpAgent = new HttpProxyAgent(proxyUrl);
112
+ axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
113
+ }
114
+
115
  const res = await axios.get(
116
  `${aiMu.api.base}${aiMu.api.endpoint.credits}`,
117
+ axiosConfig
118
  );
119
  const { code, msg, data } = res.data;
120
  if (code === 200) {
 
183
  const payload = { make_instrumental, vocal_only, lyrics, prompt, ...params };
184
 
185
  try {
186
+ const proxyUrl = await getRandomProxy();
187
+ const axiosConfig = {
188
+ headers: {
189
+ ...aiMu.headers,
190
+ 'content-type': 'application/json',
191
+ 'x-device-id': aiMu.getDeviceId(),
192
+ },
193
+ };
194
+
195
+ if (proxyUrl) {
196
+ axiosConfig.httpAgent = new HttpProxyAgent(proxyUrl);
197
+ axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
198
+ }
199
+
200
  const res = await axios.post(
201
  `${aiMu.api.base}${aiMu.api.endpoint.musicAI}`,
202
  payload,
203
+ axiosConfig
 
 
 
 
 
 
204
  );
205
  const { code, msg, data } = res.data;
206
  if (code === 200) {
 
251
  };
252
  }
253
  try {
254
+ const proxyUrl = await getRandomProxy();
255
+ const axiosConfig = {
256
+ params: { task_id: taskId },
257
+ headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() },
258
+ };
259
+
260
+ if (proxyUrl) {
261
+ axiosConfig.httpAgent = new HttpProxyAgent(proxyUrl);
262
+ axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
263
+ }
264
+
265
  const res = await axios.get(
266
  `${aiMu.api.base}${aiMu.api.endpoint.taskStatus}`,
267
+ axiosConfig
 
 
 
268
  );
269
  const { code, msg, data } = res.data;
270
  if (code === 200) {
 
302
 
303
  getGenerateList: async () => {
304
  try {
305
+ const proxyUrl = await getRandomProxy();
306
+ const axiosConfig = { headers: { ...aiMu.headers, 'x-device-id': aiMu.getDeviceId() } };
307
+
308
+ if (proxyUrl) {
309
+ axiosConfig.httpAgent = new HttpProxyAgent(proxyUrl);
310
+ axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
311
+ }
312
+
313
  const res = await axios.get(
314
  `${aiMu.api.base}${aiMu.api.endpoint.generateList}`,
315
+ axiosConfig
316
  );
317
  const { code, msg, data } = res.data;
318
  if (code === 200) {
 
456
  };
457
 
458
  module.exports = {
459
+ name: 'Sunov4 Music Generator',
460
  description: 'Generate music using AiMu AI model',
461
  type: 'GET',
462
  routes: ['api/AI/suno4'],