-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathController.php
143 lines (122 loc) · 3.43 KB
/
Controller.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
132
133
134
135
136
137
138
139
140
141
142
143
<?php
require_once("Lib/API.php");
/*require("Lib/MV.php");
require("Lib/Lyric.php");*/
error_reporting(E_ALL);
ini_set("display_errors", "on");
/*$Lyric = new Lyric();
$API = new API();
$lrcx = !!@$_REQUEST['lrcx'];
$name = $_REQUEST['name'];
$music_rid = $API->getMusicRid($name);
$lyric = $API->getLyricRid($music_rid, $lrcx);
$str_lrc = $API->getLyric($lyric['lyric_rid']);
$str_lrc = $Lyric->decodeLyric($str_lrc, $lrcx);
echo("<pre>$str_lrc</pre>");
$img = $API->getArtistImg($music_rid);
echo("<br>" . "<img src='{$img[0]}'>");
echo("<br>" . "<img src='{$img[1]}'>");
$aac = $API->getPlayUrl($music_rid);
echo("<br><audio autoplay='autoplay' controls='controls' src='{$aac}'></audio>");
echo("{$music_rid}\n");
$MV = new MV();
$mv = $MV->getMV("MUSIC_4224167")['url'];
$mv = $MV->getMV("MUSIC_751532")['url'];
echo("<video controls='controls' autoplay='autoplay' src='{$mv}'></video>");*/
class Controller
{
/**
* @var API API
*/
var $API;
/**
* @var ReflectionObject
*/
private $Reflection;
/**
* @var ReflectionMethod[]
*/
private $Methods;
function __construct()
{
$this->API = new API();
$this->Reflection = new ReflectionObject($this->API);
$this->Methods = $this->Reflection->getMethods();
}
public function getArtistImg($music_rid)
{
$return = $this->$this->API->getArtistImg($music_rid);
$this->success($return);
}
public function getLyric($music_rid, $lrcx = true)
{
$l_rid = $this->API->getLyricRid($music_rid, !!$lrcx);
$lrc = $this->API->getLyric($l_rid);
if ($lrc) $this->error("Error load lrc");
$this->success($lrc);
}
public function getMv($music_rid)
{
$music = $this->API->getMusic($music_rid);
$url = $this->API->getSongUrl($music, true);
if ($url)
$this->success($url);
else
$this->error("Error getting MV url");
}
public function getSong($music_rid)
{
$music = $this->API->getMusic($music_rid);
var_dump($music);
$url = $this->API->getSongUrl($music, false);
if ($url)
$this->success($url);
else
$this->error("Error getting Song url");
}
public function getMusicRid($name)
{
$music = $this->API->getMusicRid($name);
if ($music)
$this->success($music);
else
$this->error("Error getting music info");
}
public function getMusicList($name)
{
$list = $this->API->getMusicList($name);
$this->success($list);
}
public function success($data = "", $url = "")
{
$status = 1;
$return = compact("status", "data", "url");
$this->ajaxReturn($return);
}
public function error($data = "", $url = "")
{
$status = 0;
$return = compact("status", "data", "url");
$this->ajaxReturn($return);
}
private function ajaxReturn($data)
{
header("Content-Type:text/html;charset=utf-8");
echo(json_encode($data));
exit();
}
function __call($name, $arguments)
{
$this->error("Call an undefined method {$name}.");
}
}
ob_start();
$controller = new Controller();
$action = "get" . ($_REQUEST['action']);
$param = $_REQUEST;
array_shift($param);
try {
call_user_func_array([$controller, $action], $param);
} catch (Exception $e) {
$controller->error($e->getMessage());
}