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'];
|
2023-06-13 22:07:20 +00:00
|
|
|
|
2023-06-14 21:05:01 +00:00
|
|
|
$current_response = json_decode(file_get_contents("https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=".$cfg['user']."&nowplaying=true&format=json&api_key=".$cfg['key']));
|
|
|
|
$nowplaying = $current_response->recenttracks->track[0];
|
|
|
|
$toptracks = json_decode(file_get_contents("https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=".$cfg['user']."&format=json&period=7day&api_key=".$cfg['key']));
|
|
|
|
$tracks = $toptracks->toptracks->track;
|
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>
|
2023-06-14 21:05:01 +00:00
|
|
|
<b>Last/Current Track:</b> <a href="{{ $nowplaying->url }}">{{ $nowplaying->name }} • {{ $nowplaying->artist->{"#text"} }}</a>
|
|
|
|
<h2>Top {{ $cfg['toptracks'] }} Tracks (Last 7 days)</h2>
|
2023-06-13 22:07:20 +00:00
|
|
|
<ol>
|
|
|
|
@foreach ($tracks as $track)
|
2023-06-14 21:05:01 +00:00
|
|
|
@if ($count >= $cfg['toptracks'])
|
2023-06-13 22:07:20 +00:00
|
|
|
</ol>
|
|
|
|
@break
|
|
|
|
@endif
|
|
|
|
<li>
|
2023-06-14 21:05:01 +00:00
|
|
|
<a href="{{ $track->url }}">{{ $track->name }} • {{ $track->artist->name }}</a>
|
|
|
|
<small>({{ $track->playcount }} plays)</small>
|
2023-06-13 22:07:20 +00:00
|
|
|
</li>
|
2023-06-14 21:05:01 +00:00
|
|
|
@php $count++ @endphp
|
2023-06-13 22:07:20 +00:00
|
|
|
@endforeach
|