Skip to content

Commit

Permalink
Fixed Twitch Embed Chat (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbruni authored Oct 23, 2019
1 parent 354b455 commit 3657380
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Plugin extends PluginBase
public function pluginDetails()
{
return [
'name' => 'digitalronin.twitch::lang.plugin.name',
'name' => 'Twitch',
'description' => 'digitalronin.twitch::lang.plugin.description',
'author' => 'Daniel-Bruni Ziermann',
'author' => 'DigitalRonin',
'icon' => 'icon-video-camera',
'homepage' => 'https://github.com/digital-ronin/twitch-plugin/'
];
Expand Down
19 changes: 8 additions & 11 deletions classes/TwitchAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TwitchAPI
/**
* @var string Twitch API Base URL
*/
var $baseUrl = "https://api.twitch.tv/kraken";
private $baseUrl = 'https://api.twitch.tv/kraken';

/**
* @var string Rest URL based on Toplist Type
Expand All @@ -17,8 +17,6 @@ class TwitchAPI
*/
private $typePrefix;



/**
* Do API Request with given url
*
Expand All @@ -42,8 +40,8 @@ public function getTopList($type, $limit = 10, $offset = 0, $client_id)
{
$this->setListTypeSettings($type);

$json = $this->apiRequest($this->typeUrl."?limit=".$limit."&offset=".$offset."&client_id=".$client_id);
$object = json_decode($json, true);
$json = $this->apiRequest( $this->typeUrl."?limit=".$limit."&offset=".$offset."&client_id=".$client_id );
$object = json_decode( $json, true );

return $object[$this->typePrefix];
}
Expand All @@ -57,14 +55,14 @@ public function getTopList($type, $limit = 10, $offset = 0, $client_id)
public function isChannelLive($channel)
{
$callAPI = $this->apiRequest("/streams/".$channel);
$dataArray = json_decode($callAPI, true);
$dataArray = json_decode( $callAPI, true );

return ( !is_null( $dataArray["stream"] ) ) ? TRUE : FALSE;
return ( !is_null($dataArray[ "stream" ]) ) ? true : false;
}

/**
* @param $type
* @return string
* @return void
*/
private function setListTypeSettings($type)
{
Expand All @@ -79,8 +77,7 @@ private function setListTypeSettings($type)
break;
default:
$this->typeUrl= '';
$this->typePrefix = NULL;
$this->typePrefix = null;
}
}

}
}
7 changes: 3 additions & 4 deletions components/stream/default.htm
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<!-- Twitch Stream/Video -->
<div class="twitch-stream-wrap">
<div class="twitch-stream" id="twitch-stream-{{__SELF__.alias}}"></div>

{% if __SELF__.property('chat') == 1 %}
<iframe class="twitch-chat"
frameborder="0"
scrolling="no"
id="chat_embed"
src="http://www.twitch.tv/{{__SELF__.property('twitchId')}}/chat"
src="https://www.twitch.tv/embed/{{__SELF__.property('twitchId')}}/chat"
height="{{__SELF__.property('height')}}"
width="{{__SELF__.property('chat-width')}}">
</iframe>
{% endif %}
</div>


<script src= "http://player.twitch.tv/js/embed/v1.js"></script>
<script src= "https://player.twitch.tv/js/embed/v1.js"></script>
<script type="text/javascript">
var options = {
width: {{__SELF__.property('width')}},
Expand All @@ -29,4 +28,4 @@
};
var player = new Twitch.Player("twitch-stream-{{__SELF__.alias}}", options);
player.setVolume({{__SELF__.property('volume')}});
</script>
</script>
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"authors": [
{
"name": "Daniel-Bruni Ziermann",
"email": "[email protected]",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5.9",
"php": ">=7.0",
"composer/installers": "~1.0"
},
"minimum-stability": "dev"
Expand Down
1 change: 1 addition & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
1.2.0: Fixed Twitch Chat, Added Chat Width Option, Added German Translation, Replace npmcdn.com with unpkg.com
1.2.1: Client_Id is now required for each and every API call per Twitch - so hannylicious added that field to all appropriate spots for Toplist, Check and Feed.
1.2.2: Integrated the user provided limit for Feeds (posts) and minor fixes
1.2.3: Fixed Embed Chat

0 comments on commit 3657380

Please sign in to comment.