-
Notifications
You must be signed in to change notification settings - Fork 3
/
gimme_dl_album_count.php
69 lines (43 loc) · 1.28 KB
/
gimme_dl_album_count.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
<?php
error_reporting(0);
require_once('./config.php');
if (file_exists('./d/artists.txt')){
$dl_cnt_artists_file=file_get_contents('./d/artists.txt');
}
else {
$dl_cnt_artists_file=file_get_contents($clewnapiurl.'?listartists=true');
}
if ($dl_cnt_artists_file!==false){
$dl_cnt_artists=explode("\n", trim($dl_cnt_artists_file));
$dl_cnt_querystring='';
foreach ($dl_cnt_artists as $dl_cnt_artist)
{
if (file_exists('./d/artists.txt')){
$dl_cnt_querystring.='l2[]='.urlencode(htmlentities($dl_cnt_artist, ENT_COMPAT)).'&';
}
else {
$dl_cnt_querystring.='l2[]='.urlencode($dl_cnt_artist).'&';
}
}
$dl_cnt_ch = curl_init();
curl_setopt($dl_cnt_ch, CURLOPT_URL,$clewnapiurl.'?l2=true');
curl_setopt($dl_cnt_ch, CURLOPT_POST, 1);
curl_setopt($dl_cnt_ch, CURLOPT_POSTFIELDS, $dl_cnt_querystring);
curl_setopt($dl_cnt_ch, CURLOPT_CONNECTTIMEOUT ,15000);
curl_setopt($dl_cnt_ch, CURLOPT_TIMEOUT, 15000);
curl_setopt($dl_cnt_ch, CURLOPT_RETURNTRANSFER, true);
$dl_cnt_albums_file_json= curl_exec ($dl_cnt_ch);
curl_close ($dl_cnt_ch);
$dl_cnt_albums_file=$dl_cnt_albums_file_json;
$dl_cnt_albums=json_decode($dl_cnt_albums_file_json,true);
if ($dl_cnt_albums===null){
echo '0';
}
else {
echo count($dl_cnt_albums);
}
}
else{
echo '-1';
}
?>