diff --git a/1tamilcrow/1tamilcrow.js b/1tamilcrow/1tamilcrow.js index 857cfbb..6e059fe 100644 --- a/1tamilcrow/1tamilcrow.js +++ b/1tamilcrow/1tamilcrow.js @@ -1,27 +1,36 @@ async function searchResults(keyword) { const results = []; - const regex = /
]*>\s*([^<]+)\s*<\/a>/g; + + const articleRegex = /]*class="post-item[^"]*"[^>]*>([\s\S]*?)<\/article>/g; + const imageRegex = /]*src="([^"]+)"[^>]*alt="([^"]*)"[^>]*>/; + const linkRegex = /]*class="post-listing-title"[^>]*href="([^"]+)"[^>]*title="[^"]*">([^<]+)<\/a>/; try { const response = await fetchv2("https://www.1tamilcrow.net/?s=" + keyword); const html = await response.text(); - + let match; - while ((match = regex.exec(html)) !== null) { - results.push({ - href: match[2].trim(), - title: decodeHtml(match[3].trim()), - image: match[1] ? match[1].trim() : "No Image" - }); - } + while ((match = articleRegex.exec(html)) !== null) { + const articleContent = match[1]; + + const imageMatch = imageRegex.exec(articleContent); + const image = imageMatch ? imageMatch[1].trim() : "No Image"; + + + const linkMatch = linkRegex.exec(articleContent); + if (linkMatch) { + results.push({ + href: linkMatch[1].trim(), + title: decodeHtml(linkMatch[2].trim()), + image: image + }); + } + } + return JSON.stringify(results); } catch (err) { - return JSON.stringify([{ - title: "Error", - image: "Error", - href: "Error" - }]); + return JSON.stringify([{ title: "Error", image: "Error", href: "Error" }]); } } @@ -51,19 +60,27 @@ async function extractDetails(url) { }]); } } - async function extractEpisodes(url) { const results = []; try { const response = await fetchv2(url); const html = await response.text(); - console.log(html); - const regex = /]*SRC="(https:\/\/(?:videospk|vidhidevip)[^"]+)"[^>]*>/; - const match = html.match(regex); + + const regex = /]*src=["']([^"']+)["'][^>]*>/gi; + let match; + let foundUrl = null; - if (match) { + while ((match = regex.exec(html)) !== null) { + const iframeUrl = match[1].trim(); + if (!iframeUrl.includes('voe.sx')) { + foundUrl = iframeUrl; + break; + } + } + + if (foundUrl) { results.push({ - href: match[1].trim(), + href: foundUrl, number: 1 }); } else { @@ -86,18 +103,24 @@ async function extractStreamUrl(url) { try { const response = await fetchv2(url); const html = await response.text(); - const obfuscatedScript = html.match(/]*>\s*(eval\(function\(p,a,c,k,e,d.*?\)[\s\S]*?)<\/script>/); const unpackedScript = unpack(obfuscatedScript[1]); - - const streamMatch = unpackedScript.match(/["'](\/stream\/[^"']+)["']/); - const hlsLink = streamMatch ? streamMatch[1] : null; - - const baseUrl = url.match(/^(https?:\/\/[^/]+)/)[1]; - - console.log("HLS Link:" + hlsLink); - - return baseUrl + hlsLink; + + const hls2Match = unpackedScript.match(/["']hls2["']\s*:\s*["']([^"']+)["']/); + + if (hls2Match && hls2Match[1]) { + const hlsUrl = hls2Match[1]; + console.log("HLS2 Link:", hlsUrl); + return hlsUrl; + } + + const m3u8Match = unpackedScript.match(/(https?:\/\/[^"'\s]+\.m3u8[^"'\s]*)/); + if (m3u8Match && m3u8Match[1]) { + console.log("Fallback M3U8 Link:", m3u8Match[1]); + return m3u8Match[1]; + } + + return "https://files.catbox.moe/avolvc.mp4"; } catch (err) { console.log(err); return "https://files.catbox.moe/avolvc.mp4";