Update anime.js
Browse files45 unmodified lines464748495051525354555657585960616263646566671 unmodified line6970717273747576777879808182838485868788899091929345 unmodified linesconst dom = new JSDOM(html);const torrents = [];dom.window.document.querySelectorAll('.data-list .row').forEach(row => {const magnetLinkElement = row.querySelector('a[href^="//btsow.motorcycles/magnet/detail/hash/"]');const titleElement = row.querySelector('.file');const metaElement = row.querySelector('.size-date');if (!magnetLinkElement || !titleElement || !metaElement) return;const detailUrl = 'https:' + magnetLinkElement.getAttribute('href');const title = titleElement.textContent.trim();const quality = extractQuality(title);// β Extract hash and generate magnet linkconst hash = extractHash(detailUrl);const directMagnet = hash ? createMagnetLink(hash) : '';// β Extract size informationconst metaText = metaElement.textContent.trim();const sizeMatch = metaText.match(/Size:([^/]+)/);const size = sizeMatch ? sizeMatch[1].trim() : 'Unknown';1 unmodified linetorrents.push({title,detailUrl,hash,size,quality,magnetLink: directMagnet // β Ensure magnetLink is always included});});// β If no magnet links are found, try fetching from detail pagesawait Promise.all(torrents.map(async (torrent) => {if (!torrent.magnetLink) {const magnetLinks = await extractMagnetLinksFromPage(torrent.detailUrl);if (magnetLinks.length > 0) {torrent.magnetLink = magnetLinks[0]; // β Use the first valid magnet link}}}));console.log(`β Found ${torrents.length} torrents.`);return torrents.filter(torrent => torrent.magnetLink); // β Ensure only torrents with magnet links are returned} catch (error) {console.error('β Error fetching from BTSOW:', error);45 unmodified lines464748495051525354555657585960616263646566676869707172731 unmodified line7576777879808182838485868788899091929394959697989910010145 unmodified linesconst dom = new JSDOM(html);const torrents = [];// β Extract magnet links from the search page firstdom.window.document.querySelectorAll('.data-list .row').forEach(row => {const magnetElement = row.querySelector('a[href^="magnet:?xt=urn:btih:"]');const detailElement = row.querySelector('a[href^="//btsow.motorcycles/magnet/detail/hash/"]');const titleElement = row.querySelector('.file');const metaElement = row.querySelector('.size-date');if (!titleElement || !metaElement || (!magnetElement && !detailElement)) return;const title = titleElement.textContent.trim();const detailUrl = detailElement ? 'https:' + detailElement.getAttribute('href') : null;const quality = extractQuality(title);let magnetLink = magnetElement ? magnetElement.getAttribute('href') : null;// β Extract hash to generate magnet link if not found in the search pageif (!magnetLink && detailUrl) {const hash = extractHash(detailUrl);if (hash) magnetLink = createMagnetLink(hash);}// β Extract meta info (size)const metaText = metaElement.textContent.trim();const sizeMatch = metaText.match(/Size:([^/]+)/);const size = sizeMatch ? sizeMatch[1].trim() : 'Unknown';1 unmodified linetorrents.push({title,detailUrl,quality,size,magnetLink});});// β If magnet links are still missing, fetch from detail pagesawait Promise.all(torrents.map(async (torrent) => {if (!torrent.magnetLink && torrent.detailUrl) {const magnetLinks = await extractMagnetLinksFromPage(torrent.detailUrl);if (magnetLinks.length > 0) {torrent.magnetLink = magnetLinks[0]; // β Assign first valid magnet link}}}));// β Ensure only torrents with magnet links are returnedconst validTorrents = torrents.filter(torrent => torrent.magnetLink);console.log(`β Found ${validTorrents.length} torrents with magnet links.`);return validTorrents;} catch (error) {console.error('β Error fetching from BTSOW:', error);
anime.js+23-15