mikmc5 commited on
Commit
4292e2b
·
verified ·
1 Parent(s): eaf7675

Update solid.js

Browse files
Files changed (1) hide show
  1. solid.js +12 -9
solid.js CHANGED
@@ -9,6 +9,12 @@ const SITE_CONFIG = {
9
  ]
10
  };
11
 
 
 
 
 
 
 
12
  function extractQuality(title) {
13
  if (!title) return '';
14
  const qualityMatch = title.match(/\b(2160p|1080p|720p|4k|uhd)\b/i);
@@ -20,10 +26,6 @@ function extractHash(magnetLink) {
20
  return hashMatch ? hashMatch[1] : '';
21
  }
22
 
23
- function createMagnetLink(hash) {
24
- return `magnet:?xt=urn:btih:${hash}`;
25
- }
26
-
27
  function parseSize(sizeStr) {
28
  if (!sizeStr) return 0;
29
  const match = sizeStr.match(/([\d.]+)\s*(B|KB|MB|GB|TB)/i);
@@ -57,7 +59,6 @@ function parseSearchResults(html) {
57
  const sizeElement = item.querySelector('.stats div:nth-child(2)');
58
  const seedersElement = item.querySelector('.stats div:nth-child(3) font');
59
  const leechersElement = item.querySelector('.stats div:nth-child(4) font');
60
- const tokenElement = magnetElement ? magnetElement.getAttribute('data-token') : null;
61
 
62
  if (!titleElement || !magnetElement) return;
63
 
@@ -68,7 +69,6 @@ function parseSearchResults(html) {
68
  const size = sizeElement ? sizeElement.textContent.trim() : 'Unknown';
69
  const seeders = seedersElement ? parseInt(seedersElement.textContent) : 0;
70
  const leechers = leechersElement ? parseInt(leechersElement.textContent) : 0;
71
- const token = tokenElement ? tokenElement.trim() : null;
72
 
73
  results.push({
74
  title,
@@ -78,7 +78,6 @@ function parseSearchResults(html) {
78
  size,
79
  seeders,
80
  leechers,
81
- token,
82
  mainFileSize: parseSize(size)
83
  });
84
  } catch (error) {
@@ -96,19 +95,23 @@ async function searchTorrents(searchQuery) {
96
  }
97
 
98
  console.log(`\n🔄 Searching SolidTorrents for: "${searchQuery}"`);
 
99
 
100
  try {
101
  const url = `${SITE_CONFIG.baseUrl}/search?q=${encodeURIComponent(searchQuery)}`;
102
- console.log('Request URL:', url);
 
103
 
104
  const response = await fetch(url, {
105
  headers: {
106
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
107
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
108
  'Referer': `${SITE_CONFIG.baseUrl}/search?q=${encodeURIComponent(searchQuery)}`
109
  }
110
  });
111
 
 
 
112
  if (!response.ok) {
113
  throw new Error(`Search request failed: ${response.status}`);
114
  }
 
9
  ]
10
  };
11
 
12
+ const USER_AGENTS = [
13
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
14
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36',
15
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
16
+ ];
17
+
18
  function extractQuality(title) {
19
  if (!title) return '';
20
  const qualityMatch = title.match(/\b(2160p|1080p|720p|4k|uhd)\b/i);
 
26
  return hashMatch ? hashMatch[1] : '';
27
  }
28
 
 
 
 
 
29
  function parseSize(sizeStr) {
30
  if (!sizeStr) return 0;
31
  const match = sizeStr.match(/([\d.]+)\s*(B|KB|MB|GB|TB)/i);
 
59
  const sizeElement = item.querySelector('.stats div:nth-child(2)');
60
  const seedersElement = item.querySelector('.stats div:nth-child(3) font');
61
  const leechersElement = item.querySelector('.stats div:nth-child(4) font');
 
62
 
63
  if (!titleElement || !magnetElement) return;
64
 
 
69
  const size = sizeElement ? sizeElement.textContent.trim() : 'Unknown';
70
  const seeders = seedersElement ? parseInt(seedersElement.textContent) : 0;
71
  const leechers = leechersElement ? parseInt(leechersElement.textContent) : 0;
 
72
 
73
  results.push({
74
  title,
 
78
  size,
79
  seeders,
80
  leechers,
 
81
  mainFileSize: parseSize(size)
82
  });
83
  } catch (error) {
 
95
  }
96
 
97
  console.log(`\n🔄 Searching SolidTorrents for: "${searchQuery}"`);
98
+ await new Promise(resolve => setTimeout(resolve, 2000)); // Prevents rate limiting
99
 
100
  try {
101
  const url = `${SITE_CONFIG.baseUrl}/search?q=${encodeURIComponent(searchQuery)}`;
102
+ const userAgent = USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)];
103
+ console.log('Request URL:', url, '\nUsing User-Agent:', userAgent);
104
 
105
  const response = await fetch(url, {
106
  headers: {
107
+ 'User-Agent': userAgent,
108
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
109
  'Referer': `${SITE_CONFIG.baseUrl}/search?q=${encodeURIComponent(searchQuery)}`
110
  }
111
  });
112
 
113
+ console.log('Response Headers:', response.headers.raw());
114
+
115
  if (!response.ok) {
116
  throw new Error(`Search request failed: ${response.status}`);
117
  }