bilibili 0.0.3 → 0.0.4
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 +4 -4
- data/lib/bilibili.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7f7aaf2e4e1ce533a3a5f51f8eb08d3380338e6
|
4
|
+
data.tar.gz: be4f353b585047f1e2122b162c946f6db57aac99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad1bc814a49690b033cbfb2fdf8a929047e73c995bc61ebe30352f9d2d37d98752ea404b4a5bb45430da5f01b51d46c645e4c59ffa1637ef82244bc2d722cf8d
|
7
|
+
data.tar.gz: 4d6ebacb6ba6ba9022028623aff5fb21ac999a0fc0f0dc6d53efd22771f57b8a6f4e5eb993c889888b04fab0162aa52496fa004e9df6d140cc0d2dacef60ddee
|
data/lib/bilibili.rb
CHANGED
@@ -24,6 +24,9 @@ K_BILIBILI_API_VIDEO_SHARE = '/x/share/count?actionKey=appkey&appkey=27eb53fc905
|
|
24
24
|
K_BILIBILI_COMMENT_HOST = 'http://comment.bilibili.com/'
|
25
25
|
K_BILIBILI_API_COMMENT_URL = 'comment.bilibili.com'
|
26
26
|
|
27
|
+
K_BILIBILI_API_INTERFACE_URL = 'interface.bilibili.com'
|
28
|
+
K_BILIBILI_API_VIDEO_DOWNLOAD = '/playurl?otype=json&appkey=0a99fa1d87fdd38c&platform=ios&quality='
|
29
|
+
|
27
30
|
class Member
|
28
31
|
attr_accessor :mid # 用户id
|
29
32
|
attr_accessor :name # 昵称
|
@@ -223,6 +226,17 @@ class Video
|
|
223
226
|
comments
|
224
227
|
end
|
225
228
|
|
229
|
+
# 获取下载链接(aid)
|
230
|
+
def Video.downloadURLWithAID(aid, quality = 5)
|
231
|
+
Video.downloadURLWithCID(Video.avToCID(aid), quality)
|
232
|
+
end
|
233
|
+
|
234
|
+
# 获取下载链接(cid)
|
235
|
+
def Video.downloadURLWithCID(cid, quality = 5)
|
236
|
+
response = Net::HTTP.new(K_BILIBILI_API_INTERFACE_URL).get(K_BILIBILI_API_VIDEO_DOWNLOAD + quality.to_s + '&cid=' + cid.to_s)
|
237
|
+
JSON.parse(response.body)
|
238
|
+
end
|
239
|
+
|
226
240
|
# 视频弹幕
|
227
241
|
def comment
|
228
242
|
Video.commentWithCID(@cid)
|
@@ -241,6 +255,11 @@ class Video
|
|
241
255
|
def refresh
|
242
256
|
return Video.av(@aid)
|
243
257
|
end
|
258
|
+
|
259
|
+
# 获取下载链接
|
260
|
+
def downloadURL(quality = 5)
|
261
|
+
Video.downloadURLWithCID(@cid, quality)
|
262
|
+
end
|
244
263
|
end
|
245
264
|
|
246
265
|
class Bilibili
|