1
0

artist.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. require_once "../utilities/dom.php";
  3. require_once "../modules/querypath/src/qp.php";
  4. $document = htmlqp(encode_document(file_get_contents("https://" . urlencode($_GET["name"]) . ".bandcamp.com/music")));
  5. $title = $document->find("#band-name-location .title")->text();
  6. ?>
  7. <?php require_once "../elements/header.php" ?>
  8. <?php require_once "../elements/item.php" ?>
  9. <?php require_once "../elements/sidebar.php" ?>
  10. <?php require_once "../utilities/link.php" ?>
  11. <?php
  12. if ($document->find("#band-name-location .title")->length)
  13. echo "<h1>" . htmlspecialchars($document->find("#band-name-location .title")->text()) . "</h1>";
  14. echo "<div class=\"page\">";
  15. echo "<div class=\"results\">";
  16. $releases = $document->find("#music-grid li");
  17. foreach ($releases as $release) {
  18. $title = preg_split("/\n[\n\s]+/", trim($release->find(".title")->text()));
  19. unset($text);
  20. if (array_key_exists(1, $title)) $text = "by " . htmlspecialchars($title[1]);
  21. $image = $release->find("img");
  22. $image = $image->hasAttr("data-original") ? $image->attr("data-original") : $image->attr("src");
  23. $image = resize_link($image, 3);
  24. $image = convert_link($image);
  25. $link = $release->find("a")->attr("href");
  26. $link = prefix_link($link, "name");
  27. $link = convert_link($link);
  28. echo_item($link, $image, htmlspecialchars($title[0]), $text ?? null);
  29. };
  30. if (!$releases->length)
  31. echo "<span>No results.</span>";
  32. echo "</div>";
  33. $image = $document->find(".bio-pic a")->attr("href");
  34. $image = resize_link($image, 4);
  35. $description = $document->find("meta[property=\"og:description\"]")->attr("content");
  36. $links = $document->find("#band-links li a");
  37. echo_sidebar($image, $description, $links);
  38. echo "</div>";
  39. ?>
  40. <?php require_once "../elements/footer.php" ?>