/* Decoded by unphp.net */ $matches[1], 'total_pages' => $matches[2]]; } else { return ['error' => 'Page information not found']; } } function fetchHtmlContent($url, $customHeaders = []) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_REFERER, 'https://bhojpuriplanet.net/'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'); if (!empty($customHeaders) && is_array($customHeaders)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $customHeaders); } $html = curl_exec($ch); if (curl_errno($ch)) { echo "Error fetching content from $url: " . curl_error($ch); curl_close($ch); return false; } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpCode != 200) { echo "HTTP error: $httpCode"; curl_close($ch); return false; } curl_close($ch); return $html; } function getAllFiles($html, $dlMatch) { $pattern = '/href=[\'"](.*?' . preg_quote($dlMatch, '/') . '.*?)[\'"]/i'; if (preg_match_all($pattern, $html, $matches)) { $fileUrls = array_map(function($relativeUrl) { return resolveUrl($GLOBALS['baseUrl'], $relativeUrl); }, $matches[1]); return $fileUrls; } return false; } function resolveUrl($baseUrl, $relativeUrl) { $baseParts = parse_url($baseUrl); $baseUrlPath = isset($baseParts['path']) ? $baseParts['path'] : ''; if (strpos($relativeUrl, '://') !== false) { return $relativeUrl; } elseif (strpos($relativeUrl, '/') === 0) { return $baseParts['scheme'] . '://' . $baseParts['host'] . $relativeUrl; } else { $basePath = $baseParts['scheme'] . '://' . $baseParts['host'] . dirname($baseUrlPath); return rtrim($basePath, '/') . '/' . ltrim($relativeUrl, '/'); } } function getArtistAndThumb($html) { $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->loadHTML($html); libxml_clear_errors(); $xpath = new DOMXPath($doc); $artistNames = []; $thumbUrl = ''; $albumTitle = ''; $artistLabel = $xpath->query('//b[contains(text(), "Artist :")]')->item(0); if ($artistLabel) { $artistText = trim(str_replace('Artist :', '', $artistLabel->nodeValue), ", "); $artistNames = explode(', ', $artistText); } $thumbNode = $xpath->query('//img[contains(@src, "siteuploads/thumb/c/")]')->item(0); if ($thumbNode) { $thumbUrl = $thumbNode->getAttribute('src'); } $h1Node = $xpath->query('//h1[@class="heading"]')->item(0); //$h1Node = $xpath->query('//h2')->item(0); if ($h1Node) { $albumTitle = trim($h1Node->nodeValue); if (preg_match('/(.*?)(\([^)]+\))/', $albumTitle, $matches)) { $albumTitle = trim($matches[0]); } } return ['artist' => $artistNames, 'thumb' => $thumbUrl, 'albumTitle' => $albumTitle]; } function pagingAndCollectFiles($start, $limit, $dlMatch) { $allFileUrls = []; for ($currentPage = $start; $currentPage <= $limit; $currentPage++) { $pageUrl = $GLOBALS['baseUrl'] . $currentPage . '.html'; $html = fetchHtmlContent($pageUrl); if ($html !== false) { $pageFileUrls = getAllFiles($html, $dlMatch); if ($pageFileUrls !== false) { $pageFileUrls = array_filter($pageFileUrls, function($url) use ($dlMatch) { return strpos($url, $dlMatch) !== false; }); $allFileUrls = array_merge($allFileUrls, $pageFileUrls); } else { } } } return $allFileUrls; } function getAlbumId($baseUrl) { $pattern = '/\/(?:album|tracklist|fl|albumlist|filelist)\/(\d+)\//'; if (preg_match($pattern, $baseUrl, $matches)) { return $matches[1]; } else { return null; } } function getBaseUrl($url) { $parts = parse_url($url); return $parts['scheme'] . '://' . $parts['host']; } function OgImage($baseUrl, $url) { $url = preg_replace('/(_[1-5]\.)/', '_0.', $url); if (strpos($url, '/siteuploads/thumb/sft') !== false) { $url = str_replace(['/sft', '/thumb/'], ['/sfd', '/files/'], $url); $url = preg_replace('/_.*?\.(jpg|webp)$/', '', $url); $url .= '/thumb-' . basename($url) . '.jpg'; } elseif (strpos($url, '/siteuploads/thumb/c') !== false) { $url = preg_replace('/(_[1-5]\.)/', '_0.', $url); } elseif (strpos($url, '/thumb/sft') !== false) { $url = str_replace(['/sft', '/thumb/'], ['/sfd', '/files/'], $url); $url = preg_replace('/_.*?\.(jpg|webp)$/', '', $url); $url .= '/thumb-' . basename($url) . '.jpg'; } elseif (strpos($url, '/thumb/c') !== false) { $url = preg_replace('/(_[1-5]\.)/', '_0.', $url); } return $url; } function resolveDownloadLink($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_exec($ch); $resolvedUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); curl_close($ch); return $resolvedUrl; } function extractTitleFromDownloadLink($downloadLink) { $title = preg_replace('/.*\//', '', $downloadLink); $title = urldecode($title); return $title; } function sitenameHide($rep, $str) { $str = str_replace('=', ' ', $str); preg_match_all('#[-a-zA-Z0-9@:%_\+.~\#?&//=]{2,256}\.[a-z]{2,4}(\/[-a-zA-Z0-9@:%_\+.~\#?&//=]*)?#si', $str, $result); $host = array_reverse($result[0])[0]; if ($host) { $repArr = ["-[$host]", "[$host]", "-($host)", "($host)", "-{".$host."}", "{".$host."}", "- $host", "-$host", " $host", "$host"]; $str = str_ireplace($repArr, '', $str); } $str = str_ireplace(explode(',', $rep), '', $str); $str = preg_replace('/^[^A-Za-z0-9]$/', '', $str); if (count(explode('-', $str)) > 2) $str = str_replace('-', ' ', $str); $str = str_replace('[128 Kbps]', ' ', $str); if (ctype_lower(preg_replace('/[^A-Za-z]/', '', $str))) $str = ucwords($str); $str = preg_replace('/\s+/', ' ', $str); $str = preg_replace('/\s+\./', '.', $str); $str = str_replace(' 128 Kbps', '', $str); $str = str_replace('"', '', $str); $str = str_replace('.mp3', '', $str); $str = trim($str); return $str; } function scrapeDataV($baseUrl) { //fileshow singer $html = file_get_contents($baseUrl); $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); libxml_clear_errors(); $artistMatches = array(); $labels = $dom->getElementsByTagName('font'); foreach ($labels as $label) { if ($label->textContent === 'Singer : ') { $singerParagraph = $label->parentNode; $singerLinks = $singerParagraph->getElementsByTagName('a'); foreach ($singerLinks as $singerLink) { $artistMatches[] = $singerLink->textContent; } } } return $artistMatches; } function scrapeData($baseUrl, $html) { //fileshow data //preg_match('/(?:Artist|Singer)\s*:\s*(.*?)<\/a>/', $html, $artistMatch); // $artist = isset($artistMatch[1]) ? $artistMatch[1] : null; if (preg_match('/