-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax-favorite-arrange-Tidal.php
131 lines (113 loc) · 5.5 KB
/
ajax-favorite-arrange-Tidal.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
// +------------------------------------------------------------------------+
// | O!MPD, Copyright © 2015-2019 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');
require_once('include/play.inc.php');
global $cfg, $db;
authenticate('access_favorite');
$action = $_POST['action'];
$favorite_id = $_POST['favorite_id'];
$data = array();
$query1=mysqli_query($db,'SELECT player.player_name as pl, player_host, player_port, player_pass FROM player, session WHERE (sid = BINARY "' . cookie('netjukebox_sid') . '") and player.player_id=session.player_id');
$session1 = mysqli_fetch_assoc($query1);
$cfg['player_host'] = $session1['player_host'];
$cfg['player_port'] = $session1['player_port'];
$cfg['player_pass'] = $session1['player_pass'];
$t = new TidalAPI;
$t->username = $cfg["tidal_username"];
$t->password = $cfg["tidal_password"];
$t->token = $cfg["tidal_token"];
if (NJB_WINDOWS) $t->fixSSLcertificate();
$conn = $t->connect();
if ($conn === true){
$trackList = $t->getUserPlaylistTracks($favorite_id);
?>
<script type="text/javascript">
$('[id^="add_"]').click(function(){
addClick();
});
</script>
<table width="100%" cellspacing="0" cellpadding="0" class="border">
<tr class="header">
<td class="icon"></td><!-- optional play -->
<td<?php if ($cfg['access_play']) echo' class="space"'; ?>></td>
<td>Artist</td>
<td class="textspace"></td>
<td>Title/file</td>
<td></td><!-- delete -->
</tr>
<?php
$i = 0;
for ($i = 0; $i < $trackList['totalNumberOfItems']; $i++) {
$artist = $trackList['items'][$i]['artist']['name'];
$title = $trackList['items'][$i]['title'];
$id = $trackList['items'][$i]['id'];
$volumeNumber = $trackList['items'][$i]['volumeNumber'];
$duration = $trackList['items'][$i]['duration'];
$trackNumber = $trackList['items'][$i]['trackNumber'];
$album_id = $trackList['items'][$i]['album']['id'];
$album = $trackList['items'][$i]['album']['title'];
$cover = $trackList['items'][$i]['album']['cover'];
$releaseDate = $trackList['items'][$i]['album']['releaseDate'];
$sql = "SELECT album_id FROM tidal_album WHERE album_id = '" . $album_id . "'";
$rows = mysqli_num_rows($sql);
if ($rows == 0) {
$sql = "INSERT INTO tidal_album
(album_id, artist, artist_alphabetic, artist_id, album, album_date, genre_id, discs, seconds, last_update_time, cover, type)
VALUES (
'" . $album_id . "', '', '', '', '" . mysqli_real_escape_string($db,$album) . "', '" . $releaseDate . "', '', 1, '','" . time() . "','" . $cover . "','playlist')";
$query2=mysqli_query($db,$sql);
}
$sql = "REPLACE INTO tidal_track
(track_id, title, artist, artist_alphabetic, genre_id, disc, seconds, number, album_id)
VALUES (
'" . $id . "', '" . mysqli_real_escape_string($db,$title) . "', '" . mysqli_real_escape_string($db,$artist) . "', '" . mysqli_real_escape_string($db,$artist) . "', '', '" . $volumeNumber . "', '" . $duration . "', '" . $trackNumber . "', '" . $album_id . "')";
mysqli_query($db, $sql);
?>
<tr class="<?php echo ($i & 1) ? 'even' : 'odd'; ?> mouseover" id="track<?php echo $i; ?>" style="display:table-row;">
<td><?php if ($cfg['access_play']) {
echo '<a href="javascript:ajaxRequest(\'play.php?action=addSelect&track_id=tidal_' . $id . '\',evaluateAdd);" onMouseOver="return overlib(\'Add track\');" onMouseOut="return nd();"><i id="add_tidal_' . $id . '" class="fa fa-plus-circle fa-fw icon-small"></i></a>';
}
?></td>
<td><?php // echo $artist; ?></td>
<?php
$artist_array = explode(" ", $artist);
$lengths = array_map('strlen', $artist_array);
if (max($lengths) > 30) {
$break_method = 'break-all';
}
else {
$break_method = 'break-word';
}
?>
<td class="<?php echo $break_method;?>"><?php echo html($artist); ?></td>
<td></td>
<td><?php
if ($cfg['access_play']) {
echo '<a href="javascript:ajaxRequest(\'play.php?action=insertSelect&playAfterInsert=yes&track_id=tidal_' . $id . '\',evaluateAdd);" onMouseOver="return overlib(\'play track\');" onMouseOut="return nd();">' . html($title) . '</a>';
}
else echo html($title); ?></td>
<td align="right" class="iconDel" style="position: relative">
</td>
</tr>
<?php
}
}?>
</table>