wudysoft commited on
Commit
6fa0808
·
verified ·
1 Parent(s): 1645953

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +5 -5
app.js CHANGED
@@ -8,7 +8,7 @@ import dotenv from 'dotenv';
8
  import os from 'os';
9
  import { io } from "socket.io-client";
10
  import ytSearch from 'yt-search';
11
- import stringComparison from 'string-comparison';
12
 
13
  dotenv.config();
14
  const app = express();
@@ -113,7 +113,7 @@ app.get('/ytdl', async (req, res) => {
113
  .filter(line => line.trim().startsWith('data:'))
114
  .map(line => line.substring(5).trim())
115
  .filter(url => url.startsWith('http'));
116
- res.json({ urls });
117
  } catch (error) {
118
  console.error(error);
119
  res.status(500).send('Something went wrong while processing the request.');
@@ -158,7 +158,7 @@ app.get('/ytdl/v1', async (req, res) => {
158
  return res.status(404).json({ error: 'No valid data found.' });
159
  }
160
 
161
- res.json(parsedData);
162
  } catch (error) {
163
  console.error(error);
164
  res.status(500).json({ error: 'Something went wrong while processing the request.' });
@@ -199,7 +199,7 @@ app.get('/ytdl/v2', async (req, res) => {
199
 
200
  if (!lastLine) return res.status(404).json({ error: 'No valid data found.' });
201
 
202
- res.json({ data: extractDownloadLinks(lastLine) });
203
  } catch (error) {
204
  console.error(error);
205
  res.status(500).json({ error: 'Something went wrong while processing the request.' });
@@ -216,7 +216,7 @@ app.get('/ytdl/search', async (req, res) => {
216
  return res.status(404).json({ error: 'No results found.' });
217
  }
218
 
219
- const cos = stringComparison.Cosine;
220
 
221
  const videosWithSimilarity = result.videos.map(video => {
222
  const videoId = video.url.split('v=')[1];
 
8
  import os from 'os';
9
  import { io } from "socket.io-client";
10
  import ytSearch from 'yt-search';
11
+ import { levenshtein } from "string-comparison";
12
 
13
  dotenv.config();
14
  const app = express();
 
113
  .filter(line => line.trim().startsWith('data:'))
114
  .map(line => line.substring(5).trim())
115
  .filter(url => url.startsWith('http'));
116
+ res.json({ data: urls });
117
  } catch (error) {
118
  console.error(error);
119
  res.status(500).send('Something went wrong while processing the request.');
 
158
  return res.status(404).json({ error: 'No valid data found.' });
159
  }
160
 
161
+ res.json({ data: parsedData });
162
  } catch (error) {
163
  console.error(error);
164
  res.status(500).json({ error: 'Something went wrong while processing the request.' });
 
199
 
200
  if (!lastLine) return res.status(404).json({ error: 'No valid data found.' });
201
 
202
+ res.json({ data: encodeURI(extractDownloadLinks(lastLine)[0]) });
203
  } catch (error) {
204
  console.error(error);
205
  res.status(500).json({ error: 'Something went wrong while processing the request.' });
 
216
  return res.status(404).json({ error: 'No results found.' });
217
  }
218
 
219
+ const cos = levenshtein;
220
 
221
  const videosWithSimilarity = result.videos.map(video => {
222
  const videoId = video.url.split('v=')[1];