wah.moe/resources/views/components/lastfm.blade.php

22 lines
892 B
PHP
Raw Normal View History

2023-06-14 21:05:01 +00:00
@php
2023-06-13 22:07:20 +00:00
2023-06-14 21:05:01 +00:00
$cfg = app('config')->get('services')['lastfm'];
$api_root = app('config')->get('app')['api_root'];
2023-06-13 22:07:20 +00:00
$current_track = json_decode(file_get_contents($api_root.'/lastfm/current'));
$toptracks = json_decode(file_get_contents($api_root.'/lastfm/top'));
2023-06-13 22:07:20 +00:00
$count = 0;
2023-06-14 21:05:01 +00:00
@endphp
2023-06-13 22:07:20 +00:00
<h1>Last.fm <small>(<a href="https://www.last.fm/user/{{ $cfg['user']}}">Profile</a>)</small></h1>
<b>Last/Current Track:</b> <a href="{{ $current_track->url }}">{{ $current_track->name }} {{ $current_track->artist }}</a>
2023-06-14 21:05:01 +00:00
<h2>Top {{ $cfg['toptracks'] }} Tracks (Last 7 days)</h2>
@foreach ($toptracks as $track)
2023-06-14 21:05:01 +00:00
@if ($count >= $cfg['toptracks'])
2023-06-13 22:07:20 +00:00
@break
@endif
2023-07-04 00:14:17 +00:00
{{ str_pad($count+1, 2, '0', STR_PAD_LEFT) }}] <a href="{{ $track->url }}">{{ $track->name }} {{ $track->artist }}</a>
2023-07-25 23:08:58 +00:00
<small>({{ $track->plays }} plays)</small><br>
2023-06-14 21:05:01 +00:00
@php $count++ @endphp
2023-06-13 22:07:20 +00:00
@endforeach