1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ritero\SDK\TwitchTV\Methods; |
4
|
|
|
|
5
|
|
|
use ritero\SDK\TwitchTV\TwitchRequest; |
6
|
|
|
use ritero\SDK\TwitchTV\TwitchException; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* TwitchTV API SDK for PHP |
10
|
|
|
* |
11
|
|
|
* Videos method class |
12
|
|
|
* |
13
|
|
|
* @author Josef Ohnheiser <[email protected]> |
14
|
|
|
* @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
15
|
|
|
* @homepage https://github.com/jofner/Twitch-SDK |
16
|
|
|
*/ |
17
|
|
|
class Video |
18
|
|
|
{ |
19
|
|
|
/** @var TwitchRequest */ |
20
|
|
|
protected $request; |
21
|
|
|
|
22
|
|
|
const URI_VIDEO = 'videos/'; |
23
|
|
|
const URI_VIDEO_TOP = 'videos/top'; |
24
|
|
|
const URI_VIDEO_CHANNEL = 'channels/%s/videos'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Video constructor |
28
|
|
|
* @param TwitchRequest $request |
29
|
|
|
*/ |
30
|
|
|
public function __construct(TwitchRequest $request) |
31
|
|
|
{ |
32
|
|
|
$this->request = $request; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Returns a video object |
37
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-videosid |
38
|
|
|
* @param string $id |
39
|
|
|
* @return \stdClass |
40
|
|
|
* @throws TwitchException |
41
|
|
|
*/ |
42
|
|
|
public function getVideo($id) |
43
|
|
|
{ |
44
|
|
|
return $this->request->request(self::URI_VIDEO . $id); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Returns a list of videos created in a given time period sorted by number of views, most popular first |
49
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-videostop |
50
|
|
|
* @param string $queryString |
51
|
|
|
* @return \stdClass |
52
|
|
|
* @throws TwitchException |
53
|
|
|
*/ |
54
|
|
|
public function getTop($queryString) |
55
|
|
|
{ |
56
|
|
|
return $this->request->request(self::URI_VIDEO_TOP . $queryString); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Returns a list of videos ordered by time of creation, starting with the most recent from :channel |
61
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-channelschannelvideos |
62
|
|
|
* @param string $channel |
63
|
|
|
* @param string $queryString |
64
|
|
|
* @return \stdClass |
65
|
|
|
* @throws TwitchException |
66
|
|
|
*/ |
67
|
|
|
public function getChannelVideos($channel, $queryString) |
68
|
|
|
{ |
69
|
|
|
return $this->request->request(sprintf(self::URI_VIDEO_CHANNEL, $channel) . $queryString); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|