cathodic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +60 -0
- data/cathodic.gemspec +1 -1
- data/lib/cathodic.rb +3 -2
- data/lib/cathodic/version.rb +1 -1
- metadata +3 -2
data/Readme.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
Cathodic
|
2
|
+
================================
|
3
|
+
|
4
|
+
Cathodic was at first a module created for one of the websites I worked on.
|
5
|
+
I needed a way to easily access the data tied to a twitch.tv stream, such as the state of the stream (online or offine, thus the boolean), the number of viewers, the stream's status, etc.
|
6
|
+
|
7
|
+
Cathodic is now a standalone gem, and it's pretty easy to use, as you can see below.
|
8
|
+
|
9
|
+
Installing Cathodic
|
10
|
+
-----------------------------
|
11
|
+
|
12
|
+
If you're working on a ruby project, you just have to run the following command :
|
13
|
+
```ruby
|
14
|
+
gem install cathodic
|
15
|
+
```
|
16
|
+
|
17
|
+
However, if you're using rails, you might want to use bundler (if you don't, you should, it's awesome), therefore add the following line to your Gemfile
|
18
|
+
```ruby
|
19
|
+
gem cathodic
|
20
|
+
```
|
21
|
+
|
22
|
+
And run the following command :
|
23
|
+
```console
|
24
|
+
bundle install
|
25
|
+
```
|
26
|
+
|
27
|
+
To install the gem, and correctly add it to your rails project.
|
28
|
+
|
29
|
+
Using Cathodic
|
30
|
+
------------------------------
|
31
|
+
|
32
|
+
Cathodic is a very easy to use gem. Once you've installed it, you only need to instanciate a TwitchData object (contained in the Cathodic module) by calling the following constructor :
|
33
|
+
```ruby
|
34
|
+
Cathodic::TwitchData.new(url)
|
35
|
+
```
|
36
|
+
Where url is the url of the twitch.tv channel (http://twitch.tv/kustomgames/ for example). This url can be provided by one of your users, or fetched from the twitch.tv api.
|
37
|
+
|
38
|
+
The data tied to the stream can now be accessed by using the accessors : if you want to retreive the number of viewers on the stream and put it on the console output you just have to call the viewers accessor :
|
39
|
+
```ruby
|
40
|
+
data = Cathodic::TwitchData.new(url)
|
41
|
+
puts data.viewers
|
42
|
+
```
|
43
|
+
Here are all the data you can access at the moment :
|
44
|
+
|
45
|
+
* online : boolean - True if the stream is online, false otherwise
|
46
|
+
* account_name : string - Contains the account name from the provided url
|
47
|
+
* thumbnail_address : string - Contains the url of the stream's preview thumbnail (will soon change to a new thumbnail object)
|
48
|
+
* embed : string - Contains the html embed code for the twitch tv player which will play the stream's livestream
|
49
|
+
* viewers : integer - Contains the number of people currently watching the stream (when the TwitchData object was created!)
|
50
|
+
* entry_point : string - Contains the entry point to the api (for future upgrades of the gem, to support multiple providers)
|
51
|
+
* url : string - Contains the url to the twitch.tv stream page
|
52
|
+
* game : string - Contains the game currently played on the stream (updated by the streamer, might not be accurate)
|
53
|
+
* status : string - Contains the status of the stream, a title displayed on top of the embed which describes the current activity on screen (updated by the streamer, might not be accurate)
|
54
|
+
* logo : string - Contains the url of the stream's logo
|
55
|
+
* banner : string - Contains the url of the stream's banner
|
56
|
+
* stream_name : string - The casse sensitive stream name (example : account_name is kustomgames and stream_name is KustomGames)
|
57
|
+
* chat_embed : string - Conatains the html code used to pop out the stream's chat (incoming)
|
58
|
+
|
59
|
+
|
60
|
+
|
data/cathodic.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Cathodic::VERSION
|
8
8
|
s.authors = ["Paul Forti"]
|
9
9
|
s.email = ["paul@itsbi.fr"]
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "https://github.com/kustom666/cathodic"
|
11
11
|
s.summary = "Gets a twitch.tv stream's info from the api"
|
12
12
|
s.description = "Cathodic helps users retreiving the data from a twitch tv stream, such as the number of viewers,
|
13
13
|
a preview thumbnail, the embed code, the status etc from the twitch channel's url"
|
data/lib/cathodic.rb
CHANGED
@@ -5,7 +5,7 @@ require 'openssl'
|
|
5
5
|
|
6
6
|
module Cathodic
|
7
7
|
class TwitchData
|
8
|
-
attr_accessor :account_name, :online, :thumbnail_address, :embed, :viewers, :entry_point, :url, :game, :status, :logo, :banner, :stream_name
|
8
|
+
attr_accessor :account_name, :online, :thumbnail_address, :embed, :viewers, :entry_point, :url, :game, :status, :logo, :banner, :stream_name, :chat_embed
|
9
9
|
|
10
10
|
def initialize(url)
|
11
11
|
@entry_point = "https://api.twitch.tv/kraken"
|
@@ -48,7 +48,8 @@ module Cathodic
|
|
48
48
|
@stream_name = channel["display_name"]
|
49
49
|
|
50
50
|
@embed = "<object type=\"application/x-shockwave-flash\" height=\"360\" width=\"640\" id=\"live_embed_player_flash\" data=\"http://en.twitch.tv/widgets/live_embed_player.swf?channel="+@account_name+"\" bgcolor=\"#000000\"><param name=\"allowFullScreen\" value=\"true\" /><param name=\"allowScriptAccess\" value=\"always\" /><param name=\"allowNetworking\" value=\"all\" /><param name=\"movie\" value=\"http://en.twitch.tv/widgets/live_embed_player.swf\" /><param name=\"flashvars\" value=\"hostname=en.twitch.tv&channel="+@account_name+"&auto_play=true&start_volume=25\" /></object>"
|
51
|
-
|
51
|
+
@chat_embed = "http://twitch.tv/chat/embed?channel="+@account_name+"&popout_chat=true"
|
52
|
+
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
data/lib/cathodic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cathodic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -39,10 +39,11 @@ files:
|
|
39
39
|
- .gitignore
|
40
40
|
- Gemfile
|
41
41
|
- Rakefile
|
42
|
+
- Readme.md
|
42
43
|
- cathodic.gemspec
|
43
44
|
- lib/cathodic.rb
|
44
45
|
- lib/cathodic/version.rb
|
45
|
-
homepage:
|
46
|
+
homepage: https://github.com/kustom666/cathodic
|
46
47
|
licenses: []
|
47
48
|
post_install_message:
|
48
49
|
rdoc_options: []
|