Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

update_offsets.php 1.5 KiB

il y a 6 ans
il y a 5 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. This script downloads all drives and offsets from Accuraterip's website, and then
  5. applies various bits of normalization to be used within the Logchecker
  6. */
  7. $replacements = [
  8. ['16X DVD- - ROM', '16X DVD-ROM'],
  9. ['HL)DP-ST', 'HL-DP-ST'],
  10. ['FREECOM_', 'FREECOM'],
  11. ['Generic_', 'GENERIC']
  12. ];
  13. $ch = curl_init();
  14. curl_setopt($ch, CURLOPT_URL, 'http://www.accuraterip.com/driveoffsets.htm');
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  16. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  17. $doc = new DOMDocument();
  18. $doc->loadHTML(curl_exec($ch), LIBXML_NOWARNING | LIBXML_NOERROR);
  19. curl_close($ch);
  20. $rows = $doc->getElementsByTagName('table')->item(1)->getElementsByTagName('tr');
  21. $drives = [];
  22. for ($i = 1; $i < $rows->length; $i++) {
  23. $row = $rows->item($i);
  24. if ($row->childNodes->length > 4 && $row->childNodes->item(3)->nodeValue !== '[Purged]') {
  25. $drive = trim($row->childNodes->item(1)->nodeValue, '- ');
  26. foreach ($replacements as $replacement) {
  27. $drive = str_replace($replacement[0], $replacement[1], $drive);
  28. }
  29. $drive = strtolower($drive);
  30. $drive = preg_replace('/ +- +/', ' ', $drive);
  31. $drive = preg_replace('/ +/', ' ', $drive);
  32. $offset = ltrim(trim($row->childNodes->item(3)->nodeValue), '+');
  33. $offsets[] = $drive.','.$offset;
  34. }
  35. }
  36. file_put_contents(__DIR__.'/../src/offsets.txt', implode("\n", $offsets));
  37. print("Updating ".count($offsets)." drives\n");