release.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. require_once "../config/config.php";
  3. require_once "../utilities/dom.php";
  4. require_once "../modules/querypath/src/qp.php";
  5. $ch = curl_init("https://" . urlencode($_GET["artist"]) . ".bandcamp.com/" . urlencode($_GET["type"]) . "/" . urlencode($_GET["name"]));
  6. if (isset($config["identity"]))
  7. curl_setopt($ch, CURLOPT_COOKIE, "identity=" . $config["identity"]);
  8. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  9. $document = htmlqp(encode_document(curl_exec($ch)));
  10. $json = json_decode($document->find("script[data-tralbum]")->attr("data-tralbum"));
  11. $title = $json->current->title;
  12. ?>
  13. <?php require_once "../elements/header.php" ?>
  14. <?php require_once "../elements/sidebar.php" ?>
  15. <?php require_once "../utilities/link.php" ?>
  16. <?php
  17. if ($json) {
  18. echo "<h1>";
  19. echo htmlspecialchars($json->artist) . ": ";
  20. echo htmlspecialchars($json->current->title);
  21. echo "</h1>";
  22. echo "<div class=\"subpage\">";
  23. $image = "https://f4.bcbits.com/img/" . $json->art_id . "_10.jpg";
  24. $text = $json->current->about;
  25. echo_sidebar($image, $text);
  26. echo "<div class=\"tracks\">";
  27. echo "<table>";
  28. foreach ($json->trackinfo as $track) {
  29. $link = $track->title_link;
  30. $link = prefix_link($link, "artist");
  31. $link = convert_link($link);
  32. $duration = round($track->duration);
  33. $duration = floor($duration / 60) . ":" . sprintf("%02d", $duration % 60);
  34. echo "<tr>";
  35. echo "<td>" . ($track->track_num ?? 1) . ".</td>";
  36. echo "<td><a href=\"" . $link . "\">" . $track->title . "</a></td>";
  37. echo "<td>" . $duration . "</td>";
  38. echo "</tr>";
  39. if ($track->file) {
  40. $file = $track->file;
  41. $file = get_mangled_object_vars($file);
  42. $file = end($file);
  43. echo "<tr>";
  44. echo "<td></td>";
  45. echo "<td colspan=\"2\">";
  46. echo "<audio src=\"" . convert_link($file) . "\" controls preload=\"none\"></audio>";
  47. echo "</td>";
  48. echo "</tr>";
  49. };
  50. };
  51. echo "</table>";
  52. echo "</div>";
  53. $image = $document->find(".bio-pic a")->attr("href");
  54. $text = json_decode($document->find("script[type=\"application/ld+json\"]")->text())->publisher->description;
  55. $links = $document->find("#band-links li a");
  56. echo_sidebar($image, $text, $links);
  57. echo "</div>";
  58. } else {
  59. echo "<span>No results.</span>";
  60. };
  61. ?>
  62. <?php require_once "../elements/footer.php" ?>