fork download
  1. <?php
  2. $urlSite = 'https://s...content-available-to-author-only...o.site/download?url=';
  3. $idSite = "https://w...content-available-to-author-only...e.com/watch?v=HsR8vw19IEg";
  4.  
  5. if (!$idSite) {
  6. exit(json_encode(['error' => "Paramètre 'id' manquant."]));
  7. }
  8.  
  9. $url = $urlSite . $idSite;
  10.  
  11. $ch = curl_init($url);
  12. CURLOPT_RETURNTRANSFER => true,
  13. CURLOPT_FOLLOWLOCATION => true,
  14. CURLOPT_SSL_VERIFYPEER => true,
  15. CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
  16. CURLOPT_REFERER => 'https://www.google.com/',
  17. CURLOPT_ENCODING => '',
  18. CURLOPT_HTTPHEADER => [
  19. 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
  20. 'Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3',
  21. 'Connection: keep-alive'
  22. ]
  23. ]);
  24.  
  25. $html = curl_exec($ch);
  26. $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  27. $curl_error = curl_error($ch);
  28.  
  29. if ($http_code !== 200 || $html === false) {
  30. echo json_encode([
  31. 'error' => "Erreur HTTP: $http_code",
  32. 'curl_error' => $curl_error
  33. ]);
  34. }
  35.  
  36. $dom = new DOMDocument();
  37. $dom->loadHTML($html);
  38.  
  39. $xpath = new DOMXPath($dom);
  40.  
  41. // ✅ Extraction du tableau "data"
  42. $rows = [];
  43. $trs = $xpath->query("//div[contains(@class, 'mks_toggle')]//table[contains(@class, 'download-table')]//tbody/tr");
  44.  
  45. foreach ($trs as $tr) {
  46. $cols = [];
  47. $tds = $tr->getElementsByTagName('td');
  48. foreach ($tds as $index => $td) {
  49. if ($index === 3) {
  50. $a = $td->getElementsByTagName('a')->item(0);
  51. $link = $a ? $a->getAttribute('href') : null;
  52. $cols[] = $link;
  53. } else {
  54. $cols[] = trim($td->textContent);
  55. }
  56. }
  57. if (!empty($cols)) {
  58. $rows[] = $cols;
  59. }
  60. }
  61.  
  62. // ✅ Extraction des infos depuis /html/body/div[3]/div/div
  63. $base = $xpath->query("/html/body/div[3]/div/div")->item(0);
  64. $info = [
  65. 'title' => null,
  66. 'image' => null,
  67. 'duration' => null,
  68. 'uploader' => null,
  69. 'description' => null
  70. ];
  71.  
  72. if ($base) {
  73. // Titre dans <h3>
  74. $h3 = $xpath->query(".//h3", $base)->item(0);
  75. $info['title'] = $h3 ? trim($h3->textContent) : null;
  76.  
  77. // Image dans <img>
  78. $img = $xpath->query(".//img", $base)->item(0);
  79. $info['image'] = $img ? $img->getAttribute('src') : null;
  80.  
  81. // Duration
  82. $duration = $xpath->query(".//li[span[text()='Duration']]/strong", $base)->item(0);
  83. $info['duration'] = $duration ? trim($duration->textContent) : null;
  84.  
  85. // Uploader
  86. $uploader = $xpath->query(".//li[span[text()='Uploader']]/strong", $base)->item(0);
  87. $info['uploader'] = $uploader ? trim($uploader->textContent) : null;
  88.  
  89. // Description
  90. $desc = $xpath->query(".//li[span[text()='Description']]/b", $base)->item(0);
  91. if ($desc) {
  92. $htmlDesc = '';
  93. foreach ($desc->childNodes as $node) {
  94. if ($node->nodeName === 'br') {
  95. $htmlDesc .= "\n";
  96. } else {
  97. $htmlDesc .= $node->textContent;
  98. }
  99. }
  100. $info['description'] = trim($htmlDesc);
  101. }
  102. }
  103.  
  104. // ✅ Résultat JSON
  105. header('Content-Type: application/json; charset=UTF-8');
  106. 'status' => 'success',
  107. 'info' => $info,
  108. 'data' => $rows
  109. ], JSON_PRETTY_PRINT);
  110. ?>
  111.  
Success #stdin #stdout 0.04s 26540KB
stdin
Standard input is empty
stdout
{"error":"Erreur HTTP: 0","curl_error":"Could not resolve host: savedeo.site"}