aboutsummaryrefslogtreecommitdiff
path: root/resources/views/pages/music.blade.php
blob: cba45c22702e74bbc4f47e8dcb951957fbb97d14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@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'];

        $current_track = json_decode(file_get_contents($api_root . '/lastfm/current'));
        $toptracks = json_decode(file_get_contents($api_root . '/lastfm/top'));
        $count = 0;
    @endphp
    <table class="infotable">
        <tr>
            <td colspan="4">
                <h2>Last/Current Track:</h2>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <a href="{{ $current_track->url }}">{{ $current_track->name }}  {{ $current_track->artist }}</a><br>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <hr>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <h2>Top {{ $cfg['toptracks'] }} Tracks (Last 7 days)</h2>
            </td>
        </tr>
        <tr">
            <td style="text-align: right"><b>#</b></td>
            <td><b>Track</b></td>
            <td><b>Artist</b></td>
            <td><b>Plays</b></td>
        </tr>
        @foreach ($toptracks as $track)
            @php $count++ @endphp
            @if ($count >= $cfg['toptracks'])
                @break
            @endif
            <tr>
                <td style="text-align: right">{{ $count+1 }}</td>
                <td>{{ $track->name }}</td>
                <td>{{ $track->artist }}</td>
                <td>{{ $track->plays }}</td>
            </tr>
        @endforeach
    </table>
    <hr>
@stop