-
Notifications
You must be signed in to change notification settings - Fork 0
/
listening.php
64 lines (56 loc) · 2.17 KB
/
listening.php
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
56
57
58
59
60
61
62
63
64
<?php
function getMusicData() {
$apiKey = 'nebUpQgNtlQBfQeXW0ex3XTGMnsgs0FN';
$url = "https://api.voidem.com/v1/listening/?api_key=" . $apiKey;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_TIMEOUT => 5
]);
$response = curl_exec($curl);
if (curl_errno($curl)) {
error_log('Curl error: ' . curl_error($curl));
curl_close($curl);
return null;
}
curl_close($curl);
return json_decode($response, true);
}
$musicData = getMusicData();
$listeningData = $musicData['listeningData'] ?? null;
if ($listeningData): ?>
<div class="music-status">
<div class="music-header">
<div class="status-indicator">
<div class="status-dot <?php echo $listeningData['nowPlaying'] ? 'active' : 'inactive'; ?>"></div>
<span class="status-text"><?php echo $listeningData['nowPlaying'] ? 'Now Playing' : 'Last Played'; ?></span>
</div>
</div>
<div class="music-container">
<div class="album-art-container">
<img src="<?php echo htmlspecialchars($listeningData['image']); ?>"
alt="Album Art"
class="album-art">
</div>
<div class="music-info">
<a href="<?php echo htmlspecialchars($listeningData['url']); ?>"
target="_blank"
class="song-link">
<span class="song-name"><?php echo htmlspecialchars($listeningData['song']); ?></span>
</a>
<span class="artist-name"><?php echo htmlspecialchars($listeningData['artist']); ?></span>
<?php if (isset($listeningData['album'])): ?>
<span class="album-name"><?php echo htmlspecialchars($listeningData['album']); ?></span>
<?php endif; ?>
</div>
</div>
</div>
<link rel="stylesheet" href="assets/listenStyle.css">
<script>
setTimeout(function() {
window.location.reload();
}, 30000);
</script>
<?php endif; ?>