update test ytdl
Browse files- lib/all.js +14 -0
- plugins/alldownloader.js +41 -0
lib/all.js
CHANGED
@@ -136,6 +136,19 @@ async function TwitterDownloaderV2(url) {
|
|
136 |
}
|
137 |
}
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
export {
|
141 |
facebookdl,
|
@@ -170,4 +183,5 @@ export {
|
|
170 |
audioContent,
|
171 |
generateRandomTimestamp,
|
172 |
TwitterDownloaderV2,
|
|
|
173 |
};
|
|
|
136 |
}
|
137 |
}
|
138 |
|
139 |
+
async function YTDLDownloaderV2(url) {
|
140 |
+
try {
|
141 |
+
const result = await lubacotscaper.default.ytdl(url);
|
142 |
+
if (typeof result === "object") {
|
143 |
+
result.owner = "xtdevs";
|
144 |
+
delete result.issues;
|
145 |
+
return result;
|
146 |
+
}
|
147 |
+
} catch (error) {
|
148 |
+
console.error("Error fetching data:", error.message);
|
149 |
+
return null;
|
150 |
+
}
|
151 |
+
}
|
152 |
|
153 |
export {
|
154 |
facebookdl,
|
|
|
183 |
audioContent,
|
184 |
generateRandomTimestamp,
|
185 |
TwitterDownloaderV2,
|
186 |
+
YTDLDownloaderV2,
|
187 |
};
|
plugins/alldownloader.js
CHANGED
@@ -26,6 +26,7 @@ import {
|
|
26 |
SeachTiktok,
|
27 |
TelegramUseLog,
|
28 |
TwitterDownloaderV2,
|
|
|
29 |
} from '../lib/all.js';
|
30 |
|
31 |
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
@@ -62,6 +63,46 @@ async function downloadMedia(media) {
|
|
62 |
}
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/**
|
66 |
* @swagger
|
67 |
* /api/v1/dl/twitter-v2:
|
|
|
26 |
SeachTiktok,
|
27 |
TelegramUseLog,
|
28 |
TwitterDownloaderV2,
|
29 |
+
YTDLDownloaderV2,
|
30 |
} from '../lib/all.js';
|
31 |
|
32 |
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
|
|
63 |
}
|
64 |
}
|
65 |
|
66 |
+
/**
|
67 |
+
* @swagger
|
68 |
+
* /api/v1/dl/ytdl-v2:
|
69 |
+
* get:
|
70 |
+
* summary: Youtube V2 Downloader
|
71 |
+
* tags: [ALL-Downloader]
|
72 |
+
* parameters:
|
73 |
+
* - in: query
|
74 |
+
* name: url
|
75 |
+
* required: true
|
76 |
+
* description: null
|
77 |
+
* schema:
|
78 |
+
* type: string
|
79 |
+
* - in: header
|
80 |
+
* name: x-api-key
|
81 |
+
* required: true
|
82 |
+
* description: API key for authentication
|
83 |
+
* schema:
|
84 |
+
* type: string
|
85 |
+
* responses:
|
86 |
+
* 200:
|
87 |
+
* description: Success
|
88 |
+
* 400:
|
89 |
+
* description: Bad Request (e.g., missing or invalid URL)
|
90 |
+
* 401:
|
91 |
+
* description: Unauthorized (e.g., missing or invalid API key)
|
92 |
+
* 500:
|
93 |
+
* description: Internal Server Error
|
94 |
+
*/
|
95 |
+
AllDlRoutes.get('/api/v1/dl/ytdl-v2', async (req, res) => {
|
96 |
+
try {
|
97 |
+
const q = req.query.url;
|
98 |
+
const results = await TwitterDownloaderV2(q);
|
99 |
+
res.json({ message: results });
|
100 |
+
} catch (error) {
|
101 |
+
res.status(500).json({ error: error.message });
|
102 |
+
}
|
103 |
+
});
|
104 |
+
|
105 |
+
|
106 |
/**
|
107 |
* @swagger
|
108 |
* /api/v1/dl/twitter-v2:
|