1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace icy2003\php\iapis; |
4
|
|
|
|
5
|
|
|
use icy2003\php\I; |
6
|
|
|
use icy2003\php\ihelpers\Arrays; |
7
|
|
|
use icy2003\php\ihelpers\Http; |
8
|
|
|
use icy2003\php\ihelpers\Json; |
9
|
|
|
use icy2003\php\ihelpers\Strings; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* api 来自“今日影视”,请勿做商业用途,侵删 |
13
|
|
|
*/ |
14
|
|
|
class VideoResource extends Api |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* 按首字母查询视频 |
19
|
|
|
* |
20
|
|
|
* @param string $firsts 首字母字符串,如果是中文,则强制转成首字母 |
21
|
|
|
* @param integer $page |
22
|
|
|
* @param integer $pageSize |
23
|
|
|
* |
24
|
|
|
* @return static |
25
|
|
|
*/ |
26
|
|
|
public function fetchSearchFirst($firsts, $page = 0, $pageSize = 20) |
27
|
|
|
{ |
28
|
|
|
$res = Http::get('http://api.jinsapi.com/yingshi/search', [ |
29
|
|
|
'keys' => Strings::toPinyinFirst($firsts), |
30
|
|
|
'page' => $page, |
31
|
|
|
'pageSize' => $pageSize, |
32
|
|
|
]); |
33
|
|
|
$this->_result = Json::get($res, 'data', []); |
|
|
|
|
34
|
|
|
$this->_toArrayCall = function ($array) { |
35
|
|
|
return Arrays::columns($array, [ |
36
|
|
|
'id' => 'd_id', |
37
|
|
|
'name' => 'd_name', |
38
|
|
|
'picture' => 'd_pic', |
39
|
|
|
'tag' => 'd_remarks', |
40
|
|
|
], 2); |
41
|
|
|
}; |
42
|
|
|
|
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* 按关键字查询视频 |
48
|
|
|
* |
49
|
|
|
* @param string $keywords |
50
|
|
|
* @param integer $page |
51
|
|
|
* @param integer $pageSize |
52
|
|
|
* |
53
|
|
|
* @return static |
54
|
|
|
*/ |
55
|
|
|
public function fetchSearch($keywords, $page = 0, $pageSize = 20) |
56
|
|
|
{ |
57
|
|
|
$res = Http::post('http://api.jinsapi.com/yingshi/searchForHanZi', [ |
58
|
|
|
'keys' => $keywords, |
59
|
|
|
'page' => $page, |
60
|
|
|
'pageSize' => $pageSize, |
61
|
|
|
]); |
62
|
|
|
$this->_result = Json::get($res, 'data', []); |
|
|
|
|
63
|
|
|
$this->_toArrayCall = function ($array) { |
64
|
|
|
return Arrays::columns($array, [ |
65
|
|
|
'id' => 'd_id', |
66
|
|
|
'name' => 'd_name', |
67
|
|
|
'picture' => 'd_pic', |
68
|
|
|
'tag' => 'd_remarks', |
69
|
|
|
], 2); |
70
|
|
|
}; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* 根据视频 ID 获取视频信息 |
77
|
|
|
* |
78
|
|
|
* @param integer $id |
79
|
|
|
* |
80
|
|
|
* @return static |
81
|
|
|
*/ |
82
|
|
|
public function fetchById($id) |
83
|
|
|
{ |
84
|
|
|
$res = Http::get('http://api.jinsapi.com/yingshi/getVodById', [ |
85
|
|
|
'd_id' => $id, |
86
|
|
|
]); |
87
|
|
|
$this->_result = Json::get($res, 'data', []); |
|
|
|
|
88
|
|
|
$this->_toArrayCall = function ($array) { |
89
|
|
|
return Arrays::columns($array, [ |
90
|
|
|
'id' => 'd_id', |
91
|
|
|
'name' => 'd_name', |
92
|
|
|
'picture' => 'd_pic', |
93
|
|
|
'actors' => 'd_starring', |
94
|
|
|
'tag' => 'd_remarks', |
95
|
|
|
'area' => 'd_area', |
96
|
|
|
'lang' => 'd_lang', |
97
|
|
|
'year' => 'd_year', |
98
|
|
|
'description' => 'd_content', |
99
|
|
|
'episodes' => function ($array) { |
100
|
|
|
$episodes = explode('#', I::get($array, 'd_playurl')); |
|
|
|
|
101
|
|
|
return Arrays::explode('$', $episodes); |
102
|
|
|
}, |
103
|
|
|
], 1); |
104
|
|
|
}; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
} |
110
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.