aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfloppydiskette <floppydisk@hyprcat.net>2024-12-25 22:41:17 +0000
committerfloppydiskette <floppydisk@hyprcat.net>2024-12-25 22:48:19 +0000
commit6c126bc20fce92c78acfefaa6672c1ed41becfe2 (patch)
treec1bb51bcf1a89c3ebb265ba4dca8a41c7c7590b1
parent80f46016700171da76e1b4223ba011b9333fafad (diff)
Update last/current track displayv2024.12.25
-rw-r--r--app/Http/Controllers/MusicController.php8
-rw-r--r--config/app.php2
-rw-r--r--public/css/master.css2
-rw-r--r--resources/views/components/current-track.blade.php5
4 files changed, 13 insertions, 4 deletions
diff --git a/app/Http/Controllers/MusicController.php b/app/Http/Controllers/MusicController.php
index 08a01f6..71ab1cc 100644
--- a/app/Http/Controllers/MusicController.php
+++ b/app/Http/Controllers/MusicController.php
@@ -25,12 +25,18 @@ class MusicController extends Controller
$data = $response->json();
error_log($response->body());
$track_data = $data["recenttracks"]["track"][0];
- $image = array_column($track_data["image"], null, 'size')['large'] ?? false;
+ // $image = array_column($track_data["image"], null, 'size')['large'] ?? false;
+ $image = $track_data["image"][(array_key_last($track_data["image"]))] ?? false;
+ $now_playing = false;
+ if (array_key_exists("@attr", $track_data)) {
+ $now_playing = $track_data["@attr"]["nowplaying"] == "true" ?? ["url"=>null];
+ }
$current_track = [
'title' => $track_data["name"],
'artist' => $track_data["artist"]["#text"],
'url' => $track_data["url"],
'image' => $image["#text"],
+ 'header' => $now_playing ? "Now Playing" : "Last Track",
];
Cache::put('current_track', $current_track, now()->addSeconds(15));
return $current_track;
diff --git a/config/app.php b/config/app.php
index 5386866..7a3c2bb 100644
--- a/config/app.php
+++ b/config/app.php
@@ -5,7 +5,7 @@ use Illuminate\Support\ServiceProvider;
return [
'name' => env('APP_NAME', 'diskfloppy.me'),
- 'version' => '2024.12.21',
+ 'version' => '2024.12.25',
'env' => env('APP_ENV', 'production'),
'debug' => (bool) env('APP_DEBUG', false),
'url' => env('APP_URL', 'http://localhost'),
diff --git a/public/css/master.css b/public/css/master.css
index 90e5e9d..3733d79 100644
--- a/public/css/master.css
+++ b/public/css/master.css
@@ -264,6 +264,8 @@ div.current-track img {
float: left;
filter: var(--shadow-small);
border: var(--border);
+ width: 174px;
+ height: 174px;
}
/** Bookmarks **/
diff --git a/resources/views/components/current-track.blade.php b/resources/views/components/current-track.blade.php
index 45479d8..d5777cb 100644
--- a/resources/views/components/current-track.blade.php
+++ b/resources/views/components/current-track.blade.php
@@ -3,7 +3,8 @@
<img src="{{ $track["image"] }}" alt="Album cover for {{ $track["title"] }} by {{ $track["artist"] }}">
</div>
<div>
- <h2>Last/Current Track:</h2>
- <a href="{{ $track["url"] }}">{{ $track["title"] }} • {{ $track["artist"] }}</a><br>
+ <h2>{{ $track["header"] }}:</h2>
+ <a href="{{ $track["url"] }}">{{ $track["title"] }}</a><br>
+ by {{ $track["artist"] }}<br>
</div>
</div>