1
0
Sunny 2 rokov pred
rodič
commit
15ce705d93
5 zmenil súbory, kde vykonal 33 pridanie a 3 odobranie
  1. 10 2
      assets/style.css
  2. 9 0
      pages/album.php
  3. 10 0
      pages/audio.php
  4. 2 1
      pages/index.php
  5. 2 0
      utilities/link.php

+ 10 - 2
assets/style.css

@@ -95,8 +95,16 @@ main .wrapper table td {
   vertical-align: top;
 }
 
-main .wrapper table td:first-child,
-main .wrapper table td:last-child {
+main .wrapper table td[colspan] {
+  padding: initial !important;
+}
+
+main .wrapper table td[colspan] audio {
+  width: 100%;
+  padding-top: 4px;
+}
+
+main .wrapper table td:not(:nth-child(2)) {
   width: 0;
   white-space: nowrap;
   text-align: right;

+ 9 - 0
pages/album.php

@@ -41,6 +41,15 @@
     echo "<td><a href=\"" . $link . "\">" . $track->title . "</a></td>";
     echo "<td>" . $duration . "</td>";
     echo "</tr>";
+
+    if ($track->file) {
+      echo "<tr>";
+      echo "<td></td>";
+      echo "<td colspan=\"2\">";
+      echo "<audio src=\"" . convert_link($track->file->{"mp3-128"}) . "\" controls></audio>";
+      echo "</td>";
+      echo "</tr>";
+    };
   };
 
   echo "</table>";

+ 10 - 0
pages/audio.php

@@ -0,0 +1,10 @@
+<?php
+  $audio = "https://t4.bcbits.com/stream/" . urlencode($_GET["directory"]) . "/mp3-128/" . urlencode($_GET["file"]) . "?token=" . urlencode($_GET["token"]);
+  $audio = file_get_contents($audio);
+
+  $mime = new finfo(FILEINFO_MIME_TYPE);
+  $mime = $mime->buffer($audio);
+
+  header("Content-Type: " . $mime);
+  echo $audio;
+?>

+ 2 - 1
pages/index.php

@@ -35,7 +35,8 @@
       "https://$1.bandcamp.com/",
       "https://$1.bandcamp.com/album/$2",
       "https://bandcamp.com/search?q=$1",
-      "https://f4.bcbits.com/img/$1"
+      "https://f4.bcbits.com/img/$1",
+      "https://t4.bcbits.com/stream/$1/mp3-128/$2?token=$3"
     ];
 
     foreach ($rules as $rule) {

+ 2 - 0
utilities/link.php

@@ -18,6 +18,8 @@
       return $base . "album.php?artist=" . explode(".", $host)[0] . "&name=" . explode("/", $path)[1];
     elseif ($host === "f4.bcbits.com")
       return $base . "image.php?file=" . basename($link);
+    elseif ($host === "t4.bcbits.com")
+      return $base . "audio.php?directory=" . explode("/", $path)[1] . "&file=" . explode("/", $path)[3] . "&token=" . $query["token"];
     else
       return $link;
   };