diskfloppy.me/resources/views/pages/music.blade.php

67 lines
2.1 KiB
PHP
Raw Normal View History

2023-07-28 22:42:17 +00:00
@extends('layouts.default')
@section('title', 'Music')
@section('description', '')
@section('content')
@php
$cfg = app('config')->get('services')['lastfm'];
$api_root = app('config')->get('app')['api_root'];
$api_alive = true;
try {
$data = file_get_contents($api_root.'/lastfm/current');
} catch (Exception $e) {
$api_alive = false;
}
@endphp
@if (!$api_alive)
@include('components.errors.api-error')
@else
@php
2023-07-28 22:42:17 +00:00
$current_track = json_decode(file_get_contents($api_root . '/lastfm/current'));
2023-08-14 22:45:31 +00:00
$top_tracks = json_decode(file_get_contents($api_root . '/lastfm/top'));
2023-07-28 22:42:17 +00:00
$count = 0;
@endphp
2024-01-05 22:18:52 +00:00
<table class="info-table" role="presentation" width="100%">
2023-07-28 22:42:17 +00:00
<tr>
<td colspan="4">
<h2>Last/Current Track:</h2>
</td>
</tr>
<tr>
<td colspan="4">
2024-01-05 22:18:52 +00:00
<a href="{{ $current_track->url }}">{{ $current_track->title }} {{ $current_track->artist }}</a><br>
2023-07-28 22:42:17 +00:00
</td>
</tr>
2024-02-08 22:40:36 +00:00
</table>
<hr>
<table class="music-top10">
2023-07-28 22:42:17 +00:00
<tr>
<td colspan="4">
2024-02-08 22:40:36 +00:00
<h2 style="margin-bottom: 5px">Top {{ $cfg['toptracks'] }} Tracks (Last 7 days)</h2>
2023-07-28 22:42:17 +00:00
</td>
</tr>
2023-08-16 13:10:19 +00:00
<tr>
2023-08-14 22:45:31 +00:00
<td style="text-align: right"><b>#</b></td>
<td><b>Track</b></td>
<td><b>Artist</b></td>
<td><b>Plays</b></td>
2023-07-28 22:42:17 +00:00
</tr>
2023-08-14 22:45:31 +00:00
@foreach ($top_tracks as $track)
2023-07-28 22:42:17 +00:00
@php $count++ @endphp
2023-08-14 22:45:31 +00:00
@if ($count >= $cfg['toptracks']+1)
2023-07-28 22:42:17 +00:00
@break
@endif
<tr>
2023-08-14 22:45:31 +00:00
<td style="text-align: right">{{ $count }}</td>
2024-02-08 22:40:36 +00:00
<td style="white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:1px;" width="50%"><a href="{{ $track->url }}">{{ $track->title }}</a></td>
2024-01-05 22:18:52 +00:00
<td style="white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:1px;" width="50%">{{ $track->artist }}</td>
<td>{{ $track->playcount }}</td>
2023-07-28 22:42:17 +00:00
</tr>
@endforeach
</table>
@endif
2023-07-28 22:42:17 +00:00
@stop