-
Notifications
You must be signed in to change notification settings - Fork 13
/
ajax-last-played.php
97 lines (87 loc) · 3.53 KB
/
ajax-last-played.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
// +------------------------------------------------------------------------+
// | O!MPD, Copyright © 2015-2020 Artur Sierzant |
// | http://www.ompd.pl |
// | |
// | |
// | This program is free software: you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation, either version 3 of the License, or |
// | (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program. If not, see <http://www.gnu.org/licenses/>. |
// +------------------------------------------------------------------------+
require_once('include/initialize.inc.php');
require_once('include/library.inc.php');
global $cfg, $db;
$size = $_POST["tileSize"];
authenticate('access_media');
$query = mysqli_query($db, '
SELECT * FROM
(SELECT album_id, time FROM counter
ORDER BY time DESC
LIMIT 20) c
GROUP BY c.album_id
ORDER BY c.time DESC' );
$hra_session = false;
$c = 0;
while ( $album = mysqli_fetch_assoc ($query)) {
$c++;
if ($c > 7) break; //7 is max number of tile displayed on page width
$albums = array();
$a_id = $album['album_id'];
$albums['album_id'] = $a_id;
$tidal_cover = '';
if (isTidal($a_id)){
$query1 = mysqli_query($db, "SELECT album, cover, artist_alphabetic, audio_quality FROM tidal_album
WHERE album_id='" . getTidalId($a_id) . "' LIMIT 1");
$a = mysqli_fetch_assoc ( $query1 );
$albums['album'] = $a['album'];
$tidal_cover = $a['cover'];
$albums['artist_alphabetic'] = $a['artist_alphabetic'];
$albums['audio_quality'] = $a['audio_quality'];
}
elseif (isHra($a_id)){
if (!$hra_session) {
$h = new HraAPI;
$h->username = $cfg["hra_username"];
$h->password = $cfg["hra_password"];
if (NJB_WINDOWS) $t->fixSSLcertificate();
$conn = $h->connect();
if ($conn === true) $hra_session = true;
}
if ($hra_session === true){
$results = $h->getAlbum(getHraId($a_id));
if ($results['data']['results']){
$albums['album'] = $results['data']['results']['title'];
$albums['cover'] = 'https://' . $results['data']['results']['cover']['master']['file_url'];
$albums['artist_alphabetic'] = $results['data']['results']['artist'];
if ($cfg['show_album_format']) {
$albums['audio_quality'] = $results['data']['results']['tracks'][0]['format'];
}
}
else {
$albums = null;
}
}
else {
$albums = null;
}
}
else {
$query1 = mysqli_query($db, "SELECT album, image_id, artist_alphabetic FROM album
WHERE album_id='" . $a_id . "' LIMIT 1");
$a = mysqli_fetch_assoc ( $query1 );
$albums['album'] = $a['album'];
$albums['image_id'] = $a['image_id'];
$albums['artist_alphabetic'] = $a['artist_alphabetic'];
}
if ($albums) draw_tile ( $size, $albums, '', 'echo', $tidal_cover );
}
?>