bilibili 0.0.1
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/lib/bilibili.rb +124 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8089e07ca6f560c81e19b9aff405cf6486f32463
|
4
|
+
data.tar.gz: e2da8afec85a92cafac36ab8f68eeab81593d5be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e30afaf59f335bb54252e0314e7d677b2768a351b090933f941f1acdc53b9166ee3730fc3a0ce1d15c01cb2b555060a143321b409f16177469026372f708080
|
7
|
+
data.tar.gz: 5dfc085c32f853f4991e2d7e0caea5ead152534f575cc340ca573dca5eb391bd085f7a909d516e9d105f6bd1f394647c29c31f7170ca2bb3a728417da0b33dc3
|
data/lib/bilibili.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
K_BILIBILI_API_URL = "space.bilibili.com"
|
7
|
+
K_BILIBILI_API_MEMBER_QUERY = "/ajax/member/GetInfo?mid="
|
8
|
+
K_BILIBILI_API_FANS_QUERY = "/ajax/friend/GetFansList?mid="
|
9
|
+
K_BILIBILI_API_COINVIDEO_QUERY = "/ajax/member/getCoinVideos?pagesize=100&mid="
|
10
|
+
K_BILIBILI_API_SUBSCRIBE_QUERY = "/ajax/tags/getList?mid="
|
11
|
+
K_BILIBILI_API_SUBSCRIBE_TAGS_QUERY = "/ajax/tags/getSubList?mid="
|
12
|
+
K_BILIBILI_API_TAGS_QUERY = "/ajax/member/getTags?mids="
|
13
|
+
K_BILIBILI_API_SUBMITVIDEOS = "/ajax/member/getSubmitVideos?mids="
|
14
|
+
K_BILIBILI_API_ATTENTION_LIST = "/ajax/friend/GetAttentionList?mid="
|
15
|
+
K_BILIBILI_API_BOX_LIST = "/ajax/fav/getBoxList?mid="
|
16
|
+
|
17
|
+
class Member
|
18
|
+
attr_accessor :mid # 用户id
|
19
|
+
attr_accessor :name # 昵称
|
20
|
+
attr_accessor :approve # 是否为认证用户
|
21
|
+
attr_accessor :sex # 性别
|
22
|
+
attr_accessor :rank # 排名
|
23
|
+
attr_accessor :face # 头像URL
|
24
|
+
attr_accessor :coins # 硬币数
|
25
|
+
attr_accessor :displayRank # 显示排名
|
26
|
+
attr_accessor :regtime # 注册时间
|
27
|
+
attr_accessor :spacesta # 理解不能
|
28
|
+
attr_accessor :birthday # 生日
|
29
|
+
attr_accessor :place # 地点
|
30
|
+
attr_accessor :description # 描述
|
31
|
+
attr_accessor :article # 理解不能
|
32
|
+
attr_accessor :attentions # TA关注的人
|
33
|
+
attr_accessor :fansCount # 关注TA的人数
|
34
|
+
attr_accessor :friend # TA关注的人数
|
35
|
+
attr_accessor :attention # TA关注的人数
|
36
|
+
attr_accessor :sign # 签名
|
37
|
+
attr_accessor :current_level # 当前级别
|
38
|
+
attr_accessor :current_min # 当前级别起始经验
|
39
|
+
attr_accessor :current_exp # TA的经验
|
40
|
+
attr_accessor :next_exp # 到达下一级需要的经验
|
41
|
+
|
42
|
+
def Member.member_with_JSON(json)
|
43
|
+
data = json['data']
|
44
|
+
user = Member.new
|
45
|
+
user.mid = data['mid']
|
46
|
+
user.name = data['name']
|
47
|
+
user.approve = data['approve']
|
48
|
+
user.sex = data['sex']
|
49
|
+
user.rank = data['rank']
|
50
|
+
user.face = data['face']
|
51
|
+
user.coins = data['coins']
|
52
|
+
user.displayRank = data['displayRank']
|
53
|
+
user.regtime = data['regtime']
|
54
|
+
user.spacesta = data['spacesta']
|
55
|
+
user.birthday = data['birthday']
|
56
|
+
user.place = data['place']
|
57
|
+
user.description = data['description']
|
58
|
+
user.article = data['article']
|
59
|
+
user.attentions = data['attentions']
|
60
|
+
user.fansCount = data['fans']
|
61
|
+
user.friend = data['friend']
|
62
|
+
user.attention = data['attention']
|
63
|
+
user.sign = data['sign']
|
64
|
+
user.current_level = data['level_info']['current_level']
|
65
|
+
user.current_min = data['level_info']['current_min']
|
66
|
+
user.current_exp = data['level_info']['current_exp']
|
67
|
+
user.next_exp = data['level_info']['next_exp']
|
68
|
+
user
|
69
|
+
end
|
70
|
+
|
71
|
+
# 投稿视频
|
72
|
+
def submitVideos(tid = 0)
|
73
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_SUBMITVIDEOS + @mid + "&tid=" + tid.to_s)
|
74
|
+
JSON.parse(response.body)
|
75
|
+
end
|
76
|
+
|
77
|
+
# 我的收藏
|
78
|
+
def subscribeList
|
79
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_BOX_LIST + @mid)
|
80
|
+
JSON.parse(response.body)
|
81
|
+
end
|
82
|
+
|
83
|
+
# 订阅番剧
|
84
|
+
def subscribeList
|
85
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_SUBSCRIBE_QUERY + @mid)
|
86
|
+
JSON.parse(response.body)
|
87
|
+
end
|
88
|
+
|
89
|
+
# 订阅标签
|
90
|
+
def tags
|
91
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_SUBSCRIBE_TAGS_QUERY + @mid)
|
92
|
+
JSON.parse(response.body)
|
93
|
+
end
|
94
|
+
|
95
|
+
# 投过币的视频
|
96
|
+
def coinVideos
|
97
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_COINVIDEO_QUERY + @mid)
|
98
|
+
JSON.parse(response.body)
|
99
|
+
end
|
100
|
+
|
101
|
+
# 关注列表
|
102
|
+
def attentionList
|
103
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_ATTENTION_LIST + @mid)
|
104
|
+
JSON.parse(response.body)
|
105
|
+
end
|
106
|
+
|
107
|
+
# 粉丝
|
108
|
+
def fans
|
109
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_FANS_QUERY + @mid)
|
110
|
+
JSON.parse(response.body)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class Bilibili
|
115
|
+
def Bilibili.hi
|
116
|
+
puts '- ( ゜- ゜)つロ 乾杯~ -'
|
117
|
+
end
|
118
|
+
|
119
|
+
# 通过uid获取用户
|
120
|
+
def Bilibili.member(mid)
|
121
|
+
response = Net::HTTP.new(K_BILIBILI_API_URL).get(K_BILIBILI_API_MEMBER_QUERY + mid.to_s)
|
122
|
+
Member.member_with_JSON(JSON.parse(response.body))
|
123
|
+
end
|
124
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bilibili
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- BlueCocoa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Collections of Bilibili API
|
14
|
+
email: 0xbbc@0xbbc.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/bilibili.rb
|
20
|
+
homepage: https://blog.0xbbc.com/bilibili-ruby
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.14
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Non-official Bilibili API
|
44
|
+
test_files: []
|