twicas_stream 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +296 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/get_categories.rb +38 -0
- data/examples/get_comments.rb +41 -0
- data/examples/get_movie_info.rb +38 -0
- data/examples/get_user_info.rb +34 -0
- data/examples/search_live_movies.rb +44 -0
- data/examples/search_users.rb +43 -0
- data/examples/verify_credentials.rb +50 -0
- data/lib/twicas_stream/category.rb +54 -0
- data/lib/twicas_stream/comment.rb +76 -0
- data/lib/twicas_stream/live_thumbnail.rb +9 -0
- data/lib/twicas_stream/movie.rb +69 -0
- data/lib/twicas_stream/request_header.rb +35 -0
- data/lib/twicas_stream/search.rb +178 -0
- data/lib/twicas_stream/supporter.rb +24 -0
- data/lib/twicas_stream/twicas_api_object/app.rb +18 -0
- data/lib/twicas_stream/twicas_api_object/category.rb +31 -0
- data/lib/twicas_stream/twicas_api_object/comment.rb +23 -0
- data/lib/twicas_stream/twicas_api_object/error.rb +18 -0
- data/lib/twicas_stream/twicas_api_object/movie.rb +36 -0
- data/lib/twicas_stream/twicas_api_object/sub_category.rb +24 -0
- data/lib/twicas_stream/twicas_api_object/supporter_user.rb +9 -0
- data/lib/twicas_stream/twicas_api_object/user.rb +26 -0
- data/lib/twicas_stream/user.rb +39 -0
- data/lib/twicas_stream/version.rb +6 -0
- data/lib/twicas_stream.rb +122 -0
- data/twicas_stream.gemspec +40 -0
- metadata +163 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/category')
|
5
|
+
|
6
|
+
module TwicasStream
|
7
|
+
module Category
|
8
|
+
class GetCategories
|
9
|
+
attr_reader :response
|
10
|
+
# => {
|
11
|
+
# :categories => [
|
12
|
+
# {
|
13
|
+
# :id => "_channel",
|
14
|
+
# :name => "チャンネル",
|
15
|
+
# :sub_categories => [
|
16
|
+
# {:id => "_system_channel_5", :name => "ミュージックch", :count => 100},
|
17
|
+
# {:id => "_system_channel_6", :name => "ママch", :count => 49},
|
18
|
+
# {:id => "_system_channel_7", :name => "アニメch", :count => 42}
|
19
|
+
# ]
|
20
|
+
# },
|
21
|
+
# {
|
22
|
+
# :id => "girls_jp",
|
23
|
+
# :name => "女子CAS",
|
24
|
+
# :sub_categories => [
|
25
|
+
# {:id => "girls_face_jp", :name => "女子:顔出し", :count => 66},
|
26
|
+
# {:id => "girls_jcjk_jp", :name => "女子:JCJK", :count => 17},
|
27
|
+
# {:id => "girls_ljk_jp", :name => "女子:LJK", :count => 89}
|
28
|
+
# ]
|
29
|
+
# }
|
30
|
+
# ]
|
31
|
+
# }
|
32
|
+
|
33
|
+
PREFIX_URL = 'categories'
|
34
|
+
|
35
|
+
LANG_LIMITATION = ['ja', 'en']
|
36
|
+
|
37
|
+
def initialize lang
|
38
|
+
@response = Hash.new
|
39
|
+
param = Hash.new
|
40
|
+
|
41
|
+
unless LANG_LIMITATION.include?(lang)
|
42
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. currently support language are '#{LANG_LIMITATION.join("' or '")}'."
|
43
|
+
end
|
44
|
+
|
45
|
+
param['lang'] = lang
|
46
|
+
|
47
|
+
url = BASE_URL + '/' + PREFIX_URL + TwicasStream.make_query_string(param)
|
48
|
+
# => 'https://apiv2.twitcasting.tv/categories?lang=ja'
|
49
|
+
|
50
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/comment')
|
5
|
+
|
6
|
+
module TwicasStream
|
7
|
+
module Comment
|
8
|
+
class GetComments
|
9
|
+
attr_reader :response
|
10
|
+
# => {
|
11
|
+
# :movie_id => "189037369",
|
12
|
+
# :all_count => 2124,
|
13
|
+
# :comments => [
|
14
|
+
# {
|
15
|
+
# :id => "7134775954",
|
16
|
+
# :message => "モイ!",
|
17
|
+
# :from_user => {
|
18
|
+
# :id => "182224938",
|
19
|
+
# :screen_id => "twitcasting_jp",
|
20
|
+
# :name => "ツイキャス公式",
|
21
|
+
# :image => "http://202-234-44-53.moi.st/image3s/pbs.twimg.com/profile_images/613625726512705536/GLlBoXcS_normal.png",
|
22
|
+
# :profile => "ツイキャスの公式アカウントです。ツイキャスに関するお知らせなどを投稿します。なお、お問い合わせは https://t.co/4gCf7XVm7N までお願いします。公式Facebookページhttps://t.co/bxYVwpzTJB\n公式Instagram\nhttps://t.co/Bm2O2J2Kfs",
|
23
|
+
# :level => 24,
|
24
|
+
# :last_movie_id => "189037369",
|
25
|
+
# :is_live => false,
|
26
|
+
# :supporter_count => 10,
|
27
|
+
# :supporting_count => 24,
|
28
|
+
# :created => 1282620640
|
29
|
+
# },
|
30
|
+
# :created => 1479579471
|
31
|
+
# },
|
32
|
+
# :
|
33
|
+
# :
|
34
|
+
# ]
|
35
|
+
# }
|
36
|
+
|
37
|
+
PREFIX_URL = 'movies'
|
38
|
+
|
39
|
+
SUFFIX_URL = 'comments'
|
40
|
+
|
41
|
+
DEFAULT_OFFSET = 0
|
42
|
+
|
43
|
+
DEFAULT_LIMIT = 10
|
44
|
+
|
45
|
+
LOWER_LIMIT = 1
|
46
|
+
|
47
|
+
UPPER_LIMIT = 50
|
48
|
+
|
49
|
+
DEFAULT_SLICE_ID = 'none'
|
50
|
+
|
51
|
+
def initialize movie_id, offset = DEFAULT_OFFSET, limit = DEFAULT_LIMIT, slice_id = DEFAULT_SLICE_ID
|
52
|
+
@response = Hash.new
|
53
|
+
param = Hash.new
|
54
|
+
|
55
|
+
unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
|
56
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
|
57
|
+
end
|
58
|
+
|
59
|
+
param['offset'] = offset
|
60
|
+
param['limit'] = limit
|
61
|
+
param['slice_id'] = slice_id unless slice_id == DEFAULT_SLICE_ID
|
62
|
+
|
63
|
+
url = BASE_URL + '/' + PREFIX_URL + '/' + movie_id + '/' + SUFFIX_URL + TwicasStream.make_query_string(param)
|
64
|
+
# => 'https://apiv2.twitcasting.tv/movies/:movie_id/comments?offset=0&limit=10'
|
65
|
+
|
66
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class PostComment
|
71
|
+
end
|
72
|
+
|
73
|
+
class DeleteComment
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/movie')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/user')
|
6
|
+
|
7
|
+
module TwicasStream
|
8
|
+
module Movie
|
9
|
+
class GetMovieInfo
|
10
|
+
attr_reader :response
|
11
|
+
# => {
|
12
|
+
# :movie => {
|
13
|
+
# :id => "189037369",
|
14
|
+
# :user_id => "182224938",
|
15
|
+
# :title => "ライブ #189037369",
|
16
|
+
# :subtitle => "ライブ配信中!",
|
17
|
+
# :last_owner_comment => "もいもい",
|
18
|
+
# :category => "girls_jcjk_jp",
|
19
|
+
# :link => "http://twitcasting.tv/twitcasting_jp/movie/189037369",
|
20
|
+
# :is_live => false,
|
21
|
+
# :is_recorded => false,
|
22
|
+
# :comment_count => 2124,
|
23
|
+
# :large_thumbnail => "http://202-230-12-92.twitcasting.tv/image3/image.twitcasting.tv/image55_1/39/7b/0b447b39-1.jpg",
|
24
|
+
# :small_thumbnail => "http://202-230-12-92.twitcasting.tv/image3/image.twitcasting.tv/image55_1/39/7b/0b447b39-1-s.jpg",
|
25
|
+
# :country => "jp",
|
26
|
+
# :duration => 1186,
|
27
|
+
# :created => 1438500282,
|
28
|
+
# :is_collabo => false,
|
29
|
+
# :is_protected => false,
|
30
|
+
# :max_view_count => 1675,
|
31
|
+
# :current_view_count => 20848,
|
32
|
+
# :total_view_count => 20848,
|
33
|
+
# :hls_url => "http://twitcasting.tv/twitcasting_jp/metastream.m3u8/?video=1"
|
34
|
+
# },
|
35
|
+
# :broadcaster => {
|
36
|
+
# :id => "182224938",
|
37
|
+
# :screen_id => "twitcasting_jp",
|
38
|
+
# :name => "ツイキャス公式",
|
39
|
+
# :image => "http://202-234-44-53.moi.st/image3s/pbs.twimg.com/profile_images/613625726512705536/GLlBoXcS_normal.png",
|
40
|
+
# :profile => "ツイキャスの公式アカウントです。ツイキャスに関するお知らせなどを投稿します。なお、お問い合わせは https://t.co/4gCf7XVm7N までお願いします。公式Facebookページ:ttps://t.co/bxYVwpzTJB\n公式Instagram\nhttps://t.co/Bm2O2J2Kfs",
|
41
|
+
# :level => 24,
|
42
|
+
# :last_movie_id => "189037369",
|
43
|
+
# :is_live => true,
|
44
|
+
# :supporter_count => 10,
|
45
|
+
# :supporting_count => 24,
|
46
|
+
# :created => 1282620640
|
47
|
+
# },
|
48
|
+
# :tags => ["人気", "コンティニュー中", "レベル40+", "初見さん大歓迎", "まったり", "雑談"]
|
49
|
+
# }
|
50
|
+
|
51
|
+
PREFIX_URL = 'movies'
|
52
|
+
|
53
|
+
def initialize movie_id
|
54
|
+
@response = Hash.new
|
55
|
+
|
56
|
+
url = BASE_URL + '/' + PREFIX_URL + '/' + movie_id
|
57
|
+
# => 'https://apiv2.twitcasting.tv/movies/:movie_id'
|
58
|
+
|
59
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class GetMoviesbyUser
|
64
|
+
end
|
65
|
+
|
66
|
+
class GetCurrentLive
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module TwicasStream
|
5
|
+
module RequestHeader
|
6
|
+
REQUEST_HEADER = [
|
7
|
+
:accept_encoding,
|
8
|
+
:api_version,
|
9
|
+
:access_token
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
DEFAULT_API_VERSION = '2.0'
|
13
|
+
|
14
|
+
DEFAULT_ACCEPT_ENCODING = 'application/json'
|
15
|
+
|
16
|
+
DEFAULT_ACCESS_TOKEN = ''
|
17
|
+
|
18
|
+
attr_accessor(*REQUEST_HEADER)
|
19
|
+
|
20
|
+
def self.extended(base)
|
21
|
+
base.reset
|
22
|
+
end
|
23
|
+
|
24
|
+
def configure
|
25
|
+
yield self
|
26
|
+
end
|
27
|
+
|
28
|
+
def reset
|
29
|
+
self.api_version = DEFAULT_ACCEPT_ENCODING
|
30
|
+
self.accept_encoding = DEFAULT_API_VERSION
|
31
|
+
self.access_token = DEFAULT_ACCESS_TOKEN
|
32
|
+
self
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/user')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/movie')
|
6
|
+
|
7
|
+
module TwicasStream
|
8
|
+
module Search
|
9
|
+
class SearchUsers
|
10
|
+
attr_reader :response
|
11
|
+
# => {
|
12
|
+
# :users => [
|
13
|
+
# {
|
14
|
+
# :id => "182224938",
|
15
|
+
# :screen_id => "twitcasting_jp",
|
16
|
+
# :name => "ツイキャス公式",
|
17
|
+
# :image => "http://202-234-44-53.moi.st/image3s/pbs.twimg.com/profile_images/613625726512705536/GLlBoXcS_normal.png",
|
18
|
+
# :profile => "ツイキャスの公式アカウントです。ツイキャスに関するお知らせなどを投稿します。なお、お問い合わせは https://t.co/4gCf7XVm7N までお願いします。公式Facebookページhttps://t.co/bxYVwpzTJB\n公式Instagram\nhttps://t.co/Bm2O2J2Kfs",
|
19
|
+
# :level => 24,
|
20
|
+
# :last_movie_id => "189037369",
|
21
|
+
# :is_live => true,
|
22
|
+
# :supporter_count => 10,
|
23
|
+
# :supporting_count => 24,
|
24
|
+
# :created => 1282620640
|
25
|
+
# },
|
26
|
+
# {
|
27
|
+
# :id => "2880417757",
|
28
|
+
# :screen_id => "twitcasting_pr",
|
29
|
+
# :name => "ツイキャス運営事務局",
|
30
|
+
# :image => "http://202-234-44-61.moi.st/image3s/pbs.twimg.com/profile_images/740857980137050112/4sIEkzV8_normal.jpg",
|
31
|
+
# :profile => "モイ! ツイキャスを運営しているモイ株式会社広報担当のアカウントです。公式アカウントはこちら! @twitcasting_jp",
|
32
|
+
# :level => 24,
|
33
|
+
# :last_movie_id => "323387579",
|
34
|
+
# :is_live => false,
|
35
|
+
# :supporter_count => 10,
|
36
|
+
# :supporting_count => 24,
|
37
|
+
# :created => 1414474646
|
38
|
+
# },
|
39
|
+
# :
|
40
|
+
# :
|
41
|
+
# ]
|
42
|
+
# }
|
43
|
+
|
44
|
+
PREFIX_URL = 'search'
|
45
|
+
|
46
|
+
SUFFIX_URL = 'users'
|
47
|
+
|
48
|
+
DEFAULT_LIMIT = 10
|
49
|
+
|
50
|
+
LOWER_LIMIT = 1
|
51
|
+
|
52
|
+
UPPER_LIMIT = 50
|
53
|
+
|
54
|
+
LANG_LIMITATION = ['ja']
|
55
|
+
|
56
|
+
def initialize words, limit = DEFAULT_LIMIT, lang
|
57
|
+
@response = Hash.new
|
58
|
+
param = Hash.new
|
59
|
+
|
60
|
+
if words.empty?
|
61
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: no word."
|
62
|
+
end
|
63
|
+
|
64
|
+
unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
|
65
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}."
|
66
|
+
end
|
67
|
+
|
68
|
+
unless LANG_LIMITATION.include?(lang)
|
69
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. currently support language is '#{LANG_LIMITATION.join("', '")}' only."
|
70
|
+
end
|
71
|
+
|
72
|
+
param['words'] = words.split(' ').join('+')
|
73
|
+
param['limit'] = limit
|
74
|
+
param['lang'] = lang
|
75
|
+
|
76
|
+
url = BASE_URL + '/' + PREFIX_URL + '/' + SUFFIX_URL + TwicasStream.make_query_string(param)
|
77
|
+
# => 'https://apiv2.twitcasting.tv/search/users?words=ツイキャス+公式&limit=10&lang=ja'
|
78
|
+
|
79
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class SearchLiveMovies
|
84
|
+
attr_reader :response
|
85
|
+
# => {
|
86
|
+
# :movies => [
|
87
|
+
# {
|
88
|
+
# :movie => {
|
89
|
+
# :id => "189037369",
|
90
|
+
# :user_id => "182224938",
|
91
|
+
# :title => "ライブ #189037369",
|
92
|
+
# :
|
93
|
+
# :
|
94
|
+
# },
|
95
|
+
# :broadcaster => {
|
96
|
+
# :id => "182224938",
|
97
|
+
# :screen_id => "twitcasting_jp",
|
98
|
+
# :name => "ツイキャス公式",
|
99
|
+
# :
|
100
|
+
# :
|
101
|
+
# },
|
102
|
+
# :tags => ["人気", "コンティニュー中", "レベル40+", "初見さん大歓迎", "まったり", "雑談"]
|
103
|
+
# },
|
104
|
+
# {
|
105
|
+
# :movie => {
|
106
|
+
# :id => "323387579",
|
107
|
+
# :user_id => "2880417757",
|
108
|
+
# :title => "ライブ #323387579",
|
109
|
+
# :
|
110
|
+
# :
|
111
|
+
# },
|
112
|
+
# :broadcaster => {
|
113
|
+
# :id => "2880417757",
|
114
|
+
# :screen_id => "twitcasting_pr",
|
115
|
+
# :name => "ツイキャス運営事務局",
|
116
|
+
# :
|
117
|
+
# :
|
118
|
+
# },
|
119
|
+
# :tags => ["人気", "コンティニュー中", "レベル40+", "初見さん大歓迎", "まったり", "雑談"]
|
120
|
+
# },
|
121
|
+
# :
|
122
|
+
# :
|
123
|
+
# ]
|
124
|
+
# }
|
125
|
+
|
126
|
+
PREFIX_URL = 'search'
|
127
|
+
|
128
|
+
SUFFIX_URL = 'lives'
|
129
|
+
|
130
|
+
DEFAULT_LIMIT = 10
|
131
|
+
|
132
|
+
LOWER_LIMIT = 1
|
133
|
+
|
134
|
+
UPPER_LIMIT = 100
|
135
|
+
|
136
|
+
#TYPE_LIMITATION = ['tag', 'word', 'category', 'new', 'recommend']
|
137
|
+
TYPE_LIMITATION = ['recommend']
|
138
|
+
|
139
|
+
LANG_LIMITATION = ['ja']
|
140
|
+
|
141
|
+
def initialize limit = DEFAULT_LIMIT, type, context, lang
|
142
|
+
@response = Hash.new
|
143
|
+
|
144
|
+
param = Hash.new
|
145
|
+
|
146
|
+
unless limit >= LOWER_LIMIT and limit <= UPPER_LIMIT
|
147
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. limitation range is #{LOWER_LIMIT} ~ #{UPPER_LIMIT}"
|
148
|
+
end
|
149
|
+
|
150
|
+
unless TYPE_LIMITATION.include?(type)
|
151
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. support types is '#{TYPE_LIMITATION.join("', '")}' only."
|
152
|
+
end
|
153
|
+
|
154
|
+
unless LANG_LIMITATION.include?(lang)
|
155
|
+
STDERR.puts "#{__FILE__}:#{__LINE__}:Warning: out of limitation. currently support language is '#{LANG_LIMITATION.join("', '")}' only."
|
156
|
+
end
|
157
|
+
|
158
|
+
param['limit'] = limit
|
159
|
+
param['type'] = type
|
160
|
+
=begin
|
161
|
+
if type == 'tag' or type == 'word'
|
162
|
+
param['context'] = context.split(' ').join('+')
|
163
|
+
elsif type == 'category'
|
164
|
+
param['context'] = context
|
165
|
+
#else
|
166
|
+
# => tag is 'new' or 'recommend', then don't need 'context'
|
167
|
+
end
|
168
|
+
=end
|
169
|
+
param['lang'] = lang
|
170
|
+
|
171
|
+
url = BASE_URL + '/' + PREFIX_URL + '/' + SUFFIX_URL + TwicasStream.make_query_string(param)
|
172
|
+
# => 'https://apiv2.twitcasting.tv/search/lives?limit=10&type=recommend&lang=ja'
|
173
|
+
|
174
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/user')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/supporter_user')
|
6
|
+
|
7
|
+
module TwicasStream
|
8
|
+
module Supporter
|
9
|
+
class GetSupportingStatus
|
10
|
+
end
|
11
|
+
|
12
|
+
class SupportUser
|
13
|
+
end
|
14
|
+
|
15
|
+
class UnsupportUser
|
16
|
+
end
|
17
|
+
|
18
|
+
class SupportingList
|
19
|
+
end
|
20
|
+
|
21
|
+
class SupporterList
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module TwicasStream
|
5
|
+
module TwicasApiObject
|
6
|
+
class App
|
7
|
+
attr_reader :object
|
8
|
+
|
9
|
+
def initialize elements = {}
|
10
|
+
@object = {
|
11
|
+
:client_id => elements['client_id'],
|
12
|
+
:name => elements['name'],
|
13
|
+
:owner_user_id => elements['owner_user_id']
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/sub_category')
|
5
|
+
|
6
|
+
module TwicasStream
|
7
|
+
module TwicasApiObject
|
8
|
+
class Category
|
9
|
+
attr_reader :object
|
10
|
+
# => {
|
11
|
+
# :id => "_channel",
|
12
|
+
# :name => "チャンネル",
|
13
|
+
# :sub_categories => [
|
14
|
+
# {:id => "_system_channel_5", :name => "ミュージックch", :count => 100},
|
15
|
+
# {:id => "_system_channel_6", :name => "ママch", :count => 49},
|
16
|
+
# {:id => "_system_channel_7", :name => "アニメch", :count => 42}
|
17
|
+
# ]
|
18
|
+
# }
|
19
|
+
|
20
|
+
def initialize elements = {}
|
21
|
+
sub_categories = SubCategory.new(elements['sub_categories'])
|
22
|
+
|
23
|
+
@object = {
|
24
|
+
:id => elements['id'],
|
25
|
+
:name => elements['name'],
|
26
|
+
:sub_categories => sub_categories.objects
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/user')
|
5
|
+
|
6
|
+
module TwicasStream
|
7
|
+
module TwicasApiObject
|
8
|
+
class Comment
|
9
|
+
attr_reader :object
|
10
|
+
|
11
|
+
def initialize elements = {}
|
12
|
+
from_user = User.new(elements['from_user'])
|
13
|
+
|
14
|
+
@object = {
|
15
|
+
:id => elements['id'],
|
16
|
+
:message => elements['message'],
|
17
|
+
:from_user => from_user.object,
|
18
|
+
:created => elements['created']
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module TwicasStream
|
5
|
+
module TwicasApiObject
|
6
|
+
class Error
|
7
|
+
attr_reader :object
|
8
|
+
|
9
|
+
def initialize elements = {}
|
10
|
+
@object = {
|
11
|
+
:code => elements['code'],
|
12
|
+
:message => elements['message'],
|
13
|
+
:details => elements['details']
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module TwicasStream
|
5
|
+
module TwicasApiObject
|
6
|
+
class Movie
|
7
|
+
attr_reader :object
|
8
|
+
|
9
|
+
def initialize elements = {}
|
10
|
+
@object = {
|
11
|
+
:id => elements['id'],
|
12
|
+
:user_id => elements['user_id'],
|
13
|
+
:title => elements['title'],
|
14
|
+
:subtitle => elements['subtitle'],
|
15
|
+
:last_owner_comment => elements['last_owner_comment'],
|
16
|
+
:category => elements['category'],
|
17
|
+
:link => elements['link'],
|
18
|
+
:is_live => elements['is_live'],
|
19
|
+
:is_recorded => elements['is_recorded'],
|
20
|
+
:comment_count => elements['comment_count'],
|
21
|
+
:large_thumbnail => elements['large_thumbnail'],
|
22
|
+
:small_thumbnail => elements['small_thumbnail'],
|
23
|
+
:country => elements['country'],
|
24
|
+
:duration => elements['duration'],
|
25
|
+
:created => elements['created'],
|
26
|
+
:is_collabo => elements['is_collabo'],
|
27
|
+
:is_protected => elements['is_protected'],
|
28
|
+
:max_view_count => elements['max_view_count'],
|
29
|
+
:current_view_count => elements['current_view_count'],
|
30
|
+
:total_view_count => elements['total_view_count'],
|
31
|
+
:hls_url => elements['hls_url']
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module TwicasStream
|
5
|
+
module TwicasApiObject
|
6
|
+
class SubCategory
|
7
|
+
attr_reader :objects
|
8
|
+
|
9
|
+
def initialize elements = []
|
10
|
+
@objects = Array.new
|
11
|
+
|
12
|
+
elements.each{ |element|
|
13
|
+
object = {
|
14
|
+
:id => element['id'],
|
15
|
+
:name => element['name'],
|
16
|
+
:count => element['count']
|
17
|
+
}
|
18
|
+
|
19
|
+
@objects.push object
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module TwicasStream
|
5
|
+
module TwicasApiObject
|
6
|
+
class User
|
7
|
+
attr_reader :object
|
8
|
+
|
9
|
+
def initialize elements = {}
|
10
|
+
@object = {
|
11
|
+
:id => elements['id'],
|
12
|
+
:screen_id => elements['screen_id'],
|
13
|
+
:name => elements['name'],
|
14
|
+
:image => elements['image'],
|
15
|
+
:profile => elements['profile'],
|
16
|
+
:level => elements['level'],
|
17
|
+
:last_movie_id => elements['last_movie_id'],
|
18
|
+
:is_live => elements['is_live'],
|
19
|
+
:supporter_count => elements['supporter_count'],
|
20
|
+
:supporting_count => elements['supporting_count'],
|
21
|
+
:created => elements['created']
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/app')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/twicas_api_object/user')
|
6
|
+
|
7
|
+
module TwicasStream
|
8
|
+
module User
|
9
|
+
class GetUserInfo
|
10
|
+
attr_reader :response
|
11
|
+
|
12
|
+
PREFIX_URL = 'users'
|
13
|
+
|
14
|
+
def initialize user_id
|
15
|
+
@response = Hash.new
|
16
|
+
|
17
|
+
url = BASE_URL + '/' + PREFIX_URL + '/' + user_id
|
18
|
+
# => 'https://apiv2.twitcasting.tv/users/:user_id'
|
19
|
+
|
20
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class VerifyCredentials
|
25
|
+
attr_reader :response
|
26
|
+
|
27
|
+
PREFIX_URL = 'verify_credentials'
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@response = Hash.new
|
31
|
+
|
32
|
+
url = BASE_URL + '/' + PREFIX_URL
|
33
|
+
# => 'https://apiv2.twitcasting.tv/verify_credentials'
|
34
|
+
|
35
|
+
@response = TwicasStream.parse(TwicasStream.get(url))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|