1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-19 06:42:14 +02:00

[core] store parameters values in BridgeAbstract::parameters

This way, any BridgeAbstract method can now have access to these values,
no only collectData

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière
2016-08-25 01:24:53 +02:00
parent dea37c8e34
commit 117031bf0f
131 changed files with 548 additions and 411 deletions

View File

@@ -49,7 +49,8 @@ class TwitchApiBridge extends BridgeAbstract{
);
}
public function collectData(array $param){
public function collectData(){
$param=$this->parameters[$this->queriedContext];
/* In accordance with API description:
* "When specifying a version for a request to the Twitch API, set the Accept HTTP header to the API version you prefer."
@@ -68,19 +69,19 @@ class TwitchApiBridge extends BridgeAbstract{
$broadcasts = TWITCH_BROADCASTS;
$requests = 1;
if(isset($param['channel'])) {
$channel = $param['channel'];
if(isset($param['channel']['value'])) {
$channel = $param['channel']['value'];
} else {
$this->returnClientError('You must specify a valid channel name! Received: &channel=' . $param['channel']);
$this->returnClientError('You must specify a valid channel name! Received: &channel=' . $param['channel']['value']);
}
$this->channel = $channel;
if(isset($param['limit'])) {
if(isset($param['limit']['value'])) {
try {
$limit = (int)$param['limit'];
$limit = (int)$param['limit']['value'];
} catch (Exception $e){
$this->returnClientError('The limit you specified is not valid! Received: &limit=' . $param['limit'] . ' Expected: &limit=<num> where <num> is any integer number.');
$this->returnClientError('The limit you specified is not valid! Received: &limit=' . $param['limit']['value'] . ' Expected: &limit=<num> where <num> is any integer number.');
}
} else {
$limit = TWITCH_LIMIT;
@@ -93,10 +94,10 @@ class TwitchApiBridge extends BridgeAbstract{
if($limit % 100 != 0) { $requests++; }
}
if(isset($param['broadcasts']) && ($param['broadcasts'] == 'true' || $param['broadcasts'] == 'false')) {
$broadcasts = $param['broadcasts'];
if(isset($param['broadcasts']['value']) && ($param['broadcasts']['value'] == 'true' || $param['broadcasts']['value'] == 'false')) {
$broadcasts = $param['broadcasts']['value'];
} else {
$this->returnClientError('The value for broadcasts you specified is not valid! Received: &broadcasts=' . $param['broadcasts'] . ' Expected: &broadcasts=false or &broadcasts=true');
$this->returnClientError('The value for broadcasts you specified is not valid! Received: &broadcasts=' . $param['broadcasts']['value'] . ' Expected: &broadcasts=false or &broadcasts=true');
}
// Build the initial request, see also: https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-channelschannelvideos