randydev commited on
Commit
d995b8f
·
verified ·
1 Parent(s): cf40bd9
Files changed (1) hide show
  1. plugins/alldownloader.js +50 -2
plugins/alldownloader.js CHANGED
@@ -1,4 +1,5 @@
1
  import express from 'express';
 
2
  import { Database } from '../database/database.js';
3
  import {
4
  facebookdl,
@@ -58,6 +59,53 @@ async function downloadMedia(media) {
58
  }
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /**
62
  * @swagger
63
  * /api/v1/dl/terabox-v4:
@@ -88,7 +136,7 @@ async function downloadMedia(media) {
88
  * 500:
89
  * description: Internal Server Error
90
  */
91
- AllDlRoutes.get('/api/v1/dl/terabox-v4', async (req, res) => {
92
  try {
93
  const q = req.query.url;
94
  const results = await TeraboxV4Downloader(q);
@@ -128,7 +176,7 @@ AllDlRoutes.get('/api/v1/dl/terabox-v4', async (req, res) => {
128
  * 500:
129
  * description: Internal Server Error
130
  */
131
- AllDlRoutes.get('/api/v1/dl/twitter-v3', async (req, res) => {
132
  try {
133
  const q = req.query.url;
134
  const results = await TwitterDownloderV3(q);
 
1
  import express from 'express';
2
+ import ytdl from "ytdl-core";
3
  import { Database } from '../database/database.js';
4
  import {
5
  facebookdl,
 
59
  }
60
  }
61
 
62
+ /**
63
+ * @swagger
64
+ * /api/v1/dl/youtube-dl:
65
+ * get:
66
+ * summary: Youtube DL Downloader
67
+ * tags: [ALL-Downloader]
68
+ * parameters:
69
+ * - in: query
70
+ * name: url
71
+ * required: true
72
+ * description: null
73
+ * schema:
74
+ * type: string
75
+ * - in: header
76
+ * name: x-api-key
77
+ * required: true
78
+ * description: API key for authentication
79
+ * schema:
80
+ * type: string
81
+ * example: "lu api key di @aknuserbot telegram"
82
+ * responses:
83
+ * 200:
84
+ * description: Success
85
+ * 400:
86
+ * description: Bad Request (e.g., missing or invalid URL)
87
+ * 401:
88
+ * description: Unauthorized (e.g., missing or invalid API key)
89
+ * 500:
90
+ * description: Internal Server Error
91
+ */
92
+ AllDlRoutes.get('/api/v1/dl/youtube-dl', authenticateApiKey, apiLimiter, async (req, res) => {
93
+ try {
94
+ const url = req.query.url;
95
+ if (!url) return res.status(400).json({ error: 'Missing URL' });
96
+
97
+ const info = await ytdl.getInfo(url);
98
+ const { title, video_url, thumbnails } = info.videoDetails;
99
+ return res.json({
100
+ title,
101
+ video_url,
102
+ thumbnail: thumbnails?.[0]?.url || null,
103
+ });
104
+ } catch (err) {
105
+ res.status(500).json({ error: err.message });
106
+ }
107
+ });
108
+
109
  /**
110
  * @swagger
111
  * /api/v1/dl/terabox-v4:
 
136
  * 500:
137
  * description: Internal Server Error
138
  */
139
+ AllDlRoutes.get('/api/v1/dl/terabox-v4', authenticateApiKey, apiLimiter, async (req, res) => {
140
  try {
141
  const q = req.query.url;
142
  const results = await TeraboxV4Downloader(q);
 
176
  * 500:
177
  * description: Internal Server Error
178
  */
179
+ AllDlRoutes.get('/api/v1/dl/twitter-v3', authenticateApiKey, apiLimiter, async (req, res) => {
180
  try {
181
  const q = req.query.url;
182
  const results = await TwitterDownloderV3(q);