Update anime.js
Browse files
anime.js
CHANGED
|
@@ -46,22 +46,28 @@ async function fetchRSSFeeds(searchQuery) {
|
|
| 46 |
const dom = new JSDOM(html);
|
| 47 |
const torrents = [];
|
| 48 |
|
|
|
|
| 49 |
dom.window.document.querySelectorAll('.data-list .row').forEach(row => {
|
| 50 |
-
const
|
|
|
|
| 51 |
const titleElement = row.querySelector('.file');
|
| 52 |
const metaElement = row.querySelector('.size-date');
|
| 53 |
|
| 54 |
-
if (!
|
| 55 |
|
| 56 |
-
const detailUrl = 'https:' + magnetLinkElement.getAttribute('href');
|
| 57 |
const title = titleElement.textContent.trim();
|
|
|
|
| 58 |
const quality = extractQuality(title);
|
| 59 |
|
| 60 |
-
|
| 61 |
-
const hash = extractHash(detailUrl);
|
| 62 |
-
const directMagnet = hash ? createMagnetLink(hash) : '';
|
| 63 |
|
| 64 |
-
// β
Extract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
const metaText = metaElement.textContent.trim();
|
| 66 |
const sizeMatch = metaText.match(/Size:([^/]+)/);
|
| 67 |
const size = sizeMatch ? sizeMatch[1].trim() : 'Unknown';
|
|
@@ -69,25 +75,27 @@ async function fetchRSSFeeds(searchQuery) {
|
|
| 69 |
torrents.push({
|
| 70 |
title,
|
| 71 |
detailUrl,
|
| 72 |
-
hash,
|
| 73 |
-
size,
|
| 74 |
quality,
|
| 75 |
-
|
|
|
|
| 76 |
});
|
| 77 |
});
|
| 78 |
|
| 79 |
-
// β
If
|
| 80 |
await Promise.all(torrents.map(async (torrent) => {
|
| 81 |
-
if (!torrent.magnetLink) {
|
| 82 |
const magnetLinks = await extractMagnetLinksFromPage(torrent.detailUrl);
|
| 83 |
if (magnetLinks.length > 0) {
|
| 84 |
-
torrent.magnetLink = magnetLinks[0]; // β
|
| 85 |
}
|
| 86 |
}
|
| 87 |
}));
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
} catch (error) {
|
| 93 |
console.error('β Error fetching from BTSOW:', error);
|
|
|
|
| 46 |
const dom = new JSDOM(html);
|
| 47 |
const torrents = [];
|
| 48 |
|
| 49 |
+
// β
Extract magnet links from the search page first
|
| 50 |
dom.window.document.querySelectorAll('.data-list .row').forEach(row => {
|
| 51 |
+
const magnetElement = row.querySelector('a[href^="magnet:?xt=urn:btih:"]');
|
| 52 |
+
const detailElement = row.querySelector('a[href^="//btsow.motorcycles/magnet/detail/hash/"]');
|
| 53 |
const titleElement = row.querySelector('.file');
|
| 54 |
const metaElement = row.querySelector('.size-date');
|
| 55 |
|
| 56 |
+
if (!titleElement || !metaElement || (!magnetElement && !detailElement)) return;
|
| 57 |
|
|
|
|
| 58 |
const title = titleElement.textContent.trim();
|
| 59 |
+
const detailUrl = detailElement ? 'https:' + detailElement.getAttribute('href') : null;
|
| 60 |
const quality = extractQuality(title);
|
| 61 |
|
| 62 |
+
let magnetLink = magnetElement ? magnetElement.getAttribute('href') : null;
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
// β
Extract hash to generate magnet link if not found in the search page
|
| 65 |
+
if (!magnetLink && detailUrl) {
|
| 66 |
+
const hash = extractHash(detailUrl);
|
| 67 |
+
if (hash) magnetLink = createMagnetLink(hash);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
// β
Extract meta info (size)
|
| 71 |
const metaText = metaElement.textContent.trim();
|
| 72 |
const sizeMatch = metaText.match(/Size:([^/]+)/);
|
| 73 |
const size = sizeMatch ? sizeMatch[1].trim() : 'Unknown';
|
|
|
|
| 75 |
torrents.push({
|
| 76 |
title,
|
| 77 |
detailUrl,
|
|
|
|
|
|
|
| 78 |
quality,
|
| 79 |
+
size,
|
| 80 |
+
magnetLink
|
| 81 |
});
|
| 82 |
});
|
| 83 |
|
| 84 |
+
// β
If magnet links are still missing, fetch from detail pages
|
| 85 |
await Promise.all(torrents.map(async (torrent) => {
|
| 86 |
+
if (!torrent.magnetLink && torrent.detailUrl) {
|
| 87 |
const magnetLinks = await extractMagnetLinksFromPage(torrent.detailUrl);
|
| 88 |
if (magnetLinks.length > 0) {
|
| 89 |
+
torrent.magnetLink = magnetLinks[0]; // β
Assign first valid magnet link
|
| 90 |
}
|
| 91 |
}
|
| 92 |
}));
|
| 93 |
|
| 94 |
+
// β
Ensure only torrents with magnet links are returned
|
| 95 |
+
const validTorrents = torrents.filter(torrent => torrent.magnetLink);
|
| 96 |
+
|
| 97 |
+
console.log(`β
Found ${validTorrents.length} torrents with magnet links.`);
|
| 98 |
+
return validTorrents;
|
| 99 |
|
| 100 |
} catch (error) {
|
| 101 |
console.error('β Error fetching from BTSOW:', error);
|