wudysoft commited on
Commit
97cd08c
·
verified ·
1 Parent(s): 546d5fd

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +21 -6
app.js CHANGED
@@ -158,13 +158,28 @@ app.get('/ytdl', async (req, res) => {
158
  await browser.close();
159
 
160
  // Memproses hasil teks
161
- const processedData = rawText
162
- .split('\n') // Memisahkan berdasarkan baris
163
- .filter((line) => line.startsWith('data:')) // Memilih baris yang dimulai dengan "data:"
164
- .map((line) => line.slice(5)) // Menghapus prefix "data:"
165
- .filter((line) => line.trim() !== ''); // Menghapus baris kosong
 
 
166
 
167
- // Mengirimkan hasil sebagai respons JSON
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  res.json(processedData);
169
  } catch (error) {
170
  console.error(error);
 
158
  await browser.close();
159
 
160
  // Memproses hasil teks
161
+ const processedData = rawText;
162
+ res.json(processedData);
163
+ } catch (error) {
164
+ console.error(error);
165
+ res.status(500).send('Something went wrong while processing the request.');
166
+ }
167
+ });
168
 
169
+ app.get('/ace', async (req, res) => {
170
+ const id = req.query.id;
171
+
172
+ if (!id) {
173
+ return res.status(400).send('Parameter "id" is required.');
174
+ }
175
+
176
+ try {
177
+
178
+ const apiUrl = `https://www.acethinker.com/downloader/api/video_info.php?url=https://www.youtube.com/watch?v=${id}&israpid=1&ismp3=0`;
179
+ const response = await fetch(apiUrl);
180
+ if (!response.ok) throw new Error('AceThinker API request failed');
181
+
182
+ const processedData = await response.json();
183
  res.json(processedData);
184
  } catch (error) {
185
  console.error(error);