bilibili_console 0.0.1 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5524a52ac2c2f6286d1ff24e51d16658eee029b0da65f79655e0ca8a1f99c820
4
- data.tar.gz: 965192950c893a795039c810fa623c8c7081f78ff90bd5b7537f26737616ca5b
3
+ metadata.gz: 3659a8072f4464f548705cf3e73fbc43cd63e1fc8e1bb842ed8c5dfd080cdfe4
4
+ data.tar.gz: a36d10099d20ed05b8e701dd76b21b2b40b359d929732b46ac4fa31d81e45f3c
5
5
  SHA512:
6
- metadata.gz: 92699ed8ca0499d5ca0aa6f2def15b0a8707727d1e33a3f9465a79dd317d970f7a4e2d7eaad9da681c9d8e9983fb1809f129518dc0d954d790994001ec4b18b7
7
- data.tar.gz: 3565ae71ae71ec48818e0107735674ac1d87c42fd86e913fbe3eb2bc1c21309be83890a570324cbba25af26c581bdaf655216961d188e5e3849971d61e00066d
6
+ metadata.gz: 378adf197108bf168f2bbe31a95f039ad9f2c9845121d1b1a1c5d3f05173879f328bd63cc6b96aed7bbb8d22deea97c25d18a5626f6e59b589e05eb80b3e57a8
7
+ data.tar.gz: eeaaa69880ccca7378031f029ef299fc78f3d36f40c36b4473677edeb4d063684335fe32b5fbb6b4681b17063743b8331ad20a597bef3a4ab1eb9edac67f5f59
data/.bundle/config CHANGED
@@ -1,2 +1,2 @@
1
- ---
2
- BUNDLE_WITHOUT: "production"
1
+ ---
2
+ BUNDLE_WITHOUT: "production"
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
- *.log
2
- *.gem
3
- .idea
1
+ *.log
2
+ *.gem
3
+ .idea
4
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
- source 'https://gems.ruby-china.com'
2
-
3
- gemspec
4
-
5
- gem "rake", "~> 13.0"
6
-
7
- gem "rspec", "~> 3.0"
8
-
9
- gem "rubocop", "~> 1.7"
10
-
1
+ source 'https://gems.ruby-china.com'
2
+
3
+ gemspec
4
+
5
+ gem "rake", "~> 13.0"
6
+
7
+ gem "rspec", "~> 3.0"
8
+
9
+ gem "rubocop", "~> 1.7"
10
+
data/Gemfile.lock CHANGED
@@ -1,23 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bilibili_console (0.0.1)
5
- down (~> 5.0)
4
+ bilibili_console (0.0.3)
6
5
  nice_http (~> 1.8.9)
7
6
  rqrcode (~> 2.0)
8
- ruby-progressbar (~> 1.11.0)
9
7
  thor (~> 1.1.0)
10
8
 
11
9
  GEM
12
10
  remote: https://gems.ruby-china.com/
13
11
  specs:
14
- addressable (2.8.0)
15
- public_suffix (>= 2.0.2, < 5.0)
16
12
  ast (2.4.2)
17
13
  chunky_png (1.4.0)
18
14
  diff-lcs (1.4.4)
19
- down (5.2.2)
20
- addressable (~> 2.5)
21
15
  nice_hash (1.17.2)
22
16
  string_pattern (~> 2.2, >= 2.2.2)
23
17
  nice_http (1.8.9)
@@ -25,7 +19,6 @@ GEM
25
19
  parallel (1.20.1)
26
20
  parser (3.0.1.1)
27
21
  ast (~> 2.4.1)
28
- public_suffix (4.0.6)
29
22
  rainbow (3.0.0)
30
23
  rake (13.0.3)
31
24
  regexp_parser (1.8.2)
@@ -66,6 +59,7 @@ GEM
66
59
 
67
60
  PLATFORMS
68
61
  x64-mingw32
62
+ x86_64-linux
69
63
 
70
64
  DEPENDENCIES
71
65
  bilibili_console!
@@ -74,4 +68,4 @@ DEPENDENCIES
74
68
  rubocop (~> 1.7)
75
69
 
76
70
  BUNDLED WITH
77
- 2.2.24
71
+ 2.2.31
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 leejoker
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2021 leejoker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
data/README.md CHANGED
@@ -1,75 +1,106 @@
1
- # bilibili_console
2
-
3
- #### 介绍
4
-
5
- B站命令行客户端Ruby版
6
-
7
- #### 软件结构
8
-
9
- 基于ruby开发,ruby version >= 2.7
10
-
11
- #### 安装教程
12
-
13
- 1. 安装ruby环境,使用[rvm](https://ruby-china.org/wiki/rvm-guide)或[rbenv](https://ruby-china.org/wiki/rbenv-guide)均可
14
- 2. 替换gem源
15
- 3. 进入代码根目录,执行一下操作:
16
- ```shell
17
- $ gem build bilibili_console.gemspec
18
- $ gem install bilibili_console-0.0.1.gem
19
- ```
20
-
21
- ### 使用方法
22
-
23
- gem安装完成后即可使用**bili-console**命令
24
-
25
- #### 帮助信息
26
-
27
- ```shell
28
- $ bili-console help
29
- ```
30
-
31
- #### 登录
32
-
33
- ```shell
34
- # 执行二维码登录
35
- $ bili-console login
36
- ```
37
-
38
- #### 用户基本信息
39
-
40
- ```shell
41
- $ bili-console user
42
- ```
43
-
44
- #### bilibili漫画签到
45
-
46
- ```shell
47
- # 目前只提供漫画签到的功能
48
- $ bili-console manga
49
- ```
50
-
51
- #### 功能清单
52
-
53
- * [x] bilibili漫画签到
54
- * [x] B站二维码登录
55
- * [x] 查看个人信息
56
- * [x] 根据bv下载视频
57
- * [ ] 合并下载的视频
58
- * [ ] 查看个人收藏夹
59
- * [ ] 视频检索
60
-
61
-
62
- #### 相关项目
63
-
64
- ##### Gem依赖
65
-
66
- * [down](https://github.com/janko/down/)
67
- * [nice_http](https://github.com/MarioRuiz/nice_http)
68
- * [rqrcode](https://github.com/whomwah/rqrcode/)
69
- * [ruby-progressbar](https://github.com/jfelchner/ruby-progressbar/)
70
- * [thor](https://github.com/rails/thor)
71
-
72
- ##### 接口文档
73
-
74
- * [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect) 感谢易姐的文档支持!
75
- * [Bilibili-Manga](https://github.com/xkk2333/Bilibili-Manga) 参考了B站漫画的签到接口
1
+ # bilibili_console
2
+
3
+ #### 1 介绍
4
+
5
+ B站命令行客户端Ruby版
6
+
7
+ #### 2 软件结构
8
+
9
+ 基于ruby开发,ruby version >= 2.7
10
+
11
+ #### 3 安装教程
12
+
13
+ 1. 安装ruby环境,使用[rvm](https://ruby-china.org/wiki/rvm-guide)或[rbenv](https://ruby-china.org/wiki/rbenv-guide)均可
14
+ 2. 替换gem源
15
+ 3. 进入代码根目录,执行一下操作:
16
+
17
+ ```shell
18
+ $ gem build bilibili_console.gemspec
19
+ $ gem install bilibili_console-0.0.3.gem
20
+ ```
21
+
22
+ ### 4 使用方法
23
+
24
+ gem安装完成后即可使用**bili-console**命令
25
+
26
+ #### 4.1 帮助信息
27
+
28
+ ```shell
29
+ $ bilic help
30
+ ```
31
+
32
+ #### 4.2 登录
33
+
34
+ ```shell
35
+ # 执行二维码登录
36
+ $ bilic login
37
+ ```
38
+
39
+ #### 4.3 用户基本信息
40
+
41
+ ```shell
42
+ $ bilic user
43
+ ```
44
+
45
+ #### 4.4 下载指定BV视频
46
+
47
+ ```shell
48
+ # 下载全部分P
49
+ $ bilic down bv_id
50
+
51
+ # 从指定分P开始下载
52
+ $ bilic down -s 1 bv_id
53
+
54
+ # 从指定分P结束
55
+ $ bilic down -e 10 bv_id
56
+
57
+ # 下载指定分P
58
+ $ bilic down -p 2 bv_id
59
+ ```
60
+
61
+ #### 4.5 查询收藏
62
+
63
+ ```shell
64
+ # 查询所有收藏
65
+ $ bilic fav
66
+
67
+ # 从收藏检索
68
+ $ bilic fav --search 检索关键词
69
+
70
+ # 检索指定收藏夹
71
+ $ bilic fav --page_size 20 --page_num 1 --fav 收藏夹id --all {0 从当前收藏夹检索, 1 从全局检索}
72
+ ```
73
+
74
+ #### 4.6 bilibili漫画签到
75
+
76
+ ```shell
77
+ # 目前只提供漫画签到的功能
78
+ $ bilic manga
79
+ ```
80
+
81
+ #### 5 功能清单
82
+
83
+ * [x] bilibili漫画签到
84
+ * [x] B站二维码登录
85
+ * [x] 查看个人信息
86
+ * [x] 根据bv下载视频
87
+ * [x] 合并下载的视频
88
+ * [x] 查看个人收藏夹
89
+ * [x] 搜索个人收藏夹
90
+ * [x] 指定分p下载
91
+ * [x] 从指定分p开始下载
92
+ * [x] 下载到指定分P结束
93
+ * [ ] 全局视频检索
94
+
95
+ #### 6 相关项目
96
+
97
+ ##### Gem依赖
98
+
99
+ * [nice_http](https://github.com/MarioRuiz/nice_http)
100
+ * [rqrcode](https://github.com/whomwah/rqrcode/)
101
+ * [thor](https://github.com/rails/thor)
102
+
103
+ ##### 接口文档
104
+
105
+ * [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect) 感谢易姐的文档支持!
106
+ * [Bilibili-Manga](https://github.com/xkk2333/Bilibili-Manga) 参考了B站漫画的签到接口
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- require "bilibili_console"
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
-
9
- require "rubocop/rake_task"
10
-
11
- RuboCop::RakeTask.new
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "bilibili_console"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ require "rubocop/rake_task"
10
+
11
+ RuboCop::RakeTask.new
@@ -1,21 +1,21 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'bilibili_console'
3
- s.version = '0.0.1'
4
- s.executables << 'bili-console'
5
- s.summary = 'bilibili console'
6
- s.description = 'a console tool for bilibili'
7
- s.authors = ['leejoker']
8
- s.email = '1056650571@qq.com'
9
- s.files = `git ls-files -z`.split("\x0").reject do |f|
10
- f.match(%r{^(test|spec|features)/})
11
- end
12
- s.extra_rdoc_files = ['README.md', 'LICENSE']
13
- s.homepage = 'https://github.com/leejoker/bilibili-console'
14
- s.license = 'MIT'
15
- s.required_ruby_version = ['>= 2.7']
16
- s.add_dependency 'down', '~> 5.0'
17
- s.add_dependency 'nice_http', '~> 1.8.9'
18
- s.add_dependency 'rqrcode', '~> 2.0'
19
- s.add_dependency 'ruby-progressbar', '~> 1.11.0'
20
- s.add_dependency 'thor', '~> 1.1.0'
21
- end
1
+ require_relative 'lib/bilibili_console/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'bilibili_console'
5
+ s.version = Bilibili::VERSION
6
+ s.executables << 'bilic'
7
+ s.summary = 'bilibili console'
8
+ s.description = 'a console tool for bilibili'
9
+ s.authors = ['leejoker']
10
+ s.email = '1056650571@qq.com'
11
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
12
+ f.match(%r{^(test|spec|features)/})
13
+ end
14
+ s.extra_rdoc_files = %w[README.md LICENSE]
15
+ s.homepage = 'https://github.com/leejoker/bilibili-console'
16
+ s.license = 'MIT'
17
+ s.required_ruby_version = ['>= 2.7']
18
+ s.add_dependency 'nice_http', '~> 1.8.9'
19
+ s.add_dependency 'rqrcode', '~> 2.0'
20
+ s.add_dependency 'thor', '~> 1.1.0'
21
+ end
data/bin/banner.txt CHANGED
@@ -1,10 +1,10 @@
1
- ###################################################################################
2
- # ,-----. ,-----. ,--.
3
- # | |) /_ ,-----.' .--./ ,---. ,--,--, ,---. ,---. | | ,---.
4
- # | .-. \'-----'| | | .-. || \( .-' | .-. || || .-. :
5
- # | '--' / ' '--'\' '-' '| || |.-' `)' '-' '| |\ --.
6
- # `------' `-----' `---' `--''--'`----' `---' `--' `----'
7
- #
8
- # 欢迎使用 Bilibili-Console
9
- # Github: https://github.com/leejoker/bilibili-console
1
+ ###################################################################################
2
+ # ,-----. ,-----. ,--.
3
+ # | |) /_ ,-----.' .--./ ,---. ,--,--, ,---. ,---. | | ,---.
4
+ # | .-. \'-----'| | | .-. || \( .-' | .-. || || .-. :
5
+ # | '--' / ' '--'\' '-' '| || |.-' `)' '-' '| |\ --.
6
+ # `------' `-----' `---' `--''--'`----' `---' `--' `----'
7
+ #
8
+ # 欢迎使用 Bilibili-Console
9
+ # Github: https://github.com/leejoker/bilibili-console
10
10
  ####################################################################################
data/bin/bilic ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'bilibili_console'
5
+
6
+ # bilibili-console command line
7
+ class BiliConsole < Thor
8
+ def self.exit_on_failure?
9
+ true
10
+ end
11
+
12
+ desc 'info', 'help content'
13
+
14
+ def info
15
+ banner = File.read(File.expand_path('banner.txt', __dir__))
16
+ puts <<~HELP
17
+ #{banner}
18
+
19
+ Usage: bilic [arguments]
20
+ help [command] help messages
21
+ login qrcode login
22
+ user user info
23
+ manga bilibili manga checkin
24
+ down [-s e p q] download video
25
+ fav [-s m a ps pn] show user video collections
26
+ HELP
27
+ end
28
+
29
+ desc 'login', 'login with qrcode'
30
+
31
+ def login
32
+ bc = BilibiliConsole.new
33
+ puts bc.login
34
+ end
35
+
36
+ desc 'user', 'get user info'
37
+
38
+ def user
39
+ bc = BilibiliConsole.new
40
+ user = bc.login_user_info
41
+ puts <<~USER
42
+ uid: #{user.uid}
43
+ uname: #{user.uname}
44
+ level: #{user.level_info[:current_level]}
45
+ USER
46
+ end
47
+
48
+ desc 'manga', 'checkin bilibili manga'
49
+
50
+ def manga_checkin
51
+ bc = BilibiliConsole.new
52
+ bc.manga.load_cookie
53
+ body = bc.manga_checkin
54
+ if body.code == 'invalid_argument'
55
+ puts '您已经签到了'
56
+ else
57
+ puts '签到成功'
58
+ end
59
+ end
60
+
61
+ desc 'down', 'download video by bv code'
62
+ method_option :start, aliases: '-s', desc: 'start page'
63
+ method_option :end, aliases: '-e', desc: 'end page'
64
+ method_option :page, aliases: '-p', desc: 'order one page'
65
+ method_option :qn, aliases: '-q', desc: 'video resolution ratio'
66
+
67
+ def download_video(bv_id)
68
+ bc = BilibiliConsole.new
69
+ bc.video.load_cookie
70
+ options_dup = options.dup
71
+ options_dup[:start] = 1 if options[:start].nil?
72
+ options_dup[:qn] = '720' if options[:qn].nil?
73
+ bc.download_video(bv_id, options_dup)
74
+ end
75
+
76
+ desc 'fav', 'show user fav info'
77
+ method_option :search, aliases: '-s', desc: 'search in fav'
78
+ method_option :fav, aliases: '-m', desc: 'ordered a fav to do some operations'
79
+ method_option :page_size, aliases: '-ps', desc: 'page size'
80
+ method_option :page_num, aliases: '-pn', desc: 'page number'
81
+ method_option :all, aliases: '-a', desc: 'usr 1 for searching in all fav and 2 for searching in the ordered fav'
82
+
83
+ def fav_info
84
+ if options[:search].nil? && options[:fav].nil?
85
+ fav_list
86
+ else
87
+ options_dup = options.dup
88
+ fav_search(options_dup)
89
+ end
90
+ end
91
+
92
+ private
93
+
94
+ def fav_list
95
+ bc = BilibiliConsole.new
96
+ bc.user_fav_list.list.each do |fav|
97
+ puts <<~FAV
98
+ fav_id: #{fav.fid}
99
+ fav_name: #{fav.title}
100
+ media count: #{fav.media_count}
101
+ -----------------------------------------------------------------------
102
+ FAV
103
+ end
104
+ end
105
+
106
+ def fav_search(options)
107
+ bc = BilibiliConsole.new
108
+ fav = bc.user_fav_list.list[0]
109
+ user = bc.login_user_info
110
+ options[:fav] = fav.fid if options[:fav].nil?
111
+ options[:fav] += user.uid.to_s.slice(-2, 2)
112
+ bc.list_fav_video(options)&.medias&.each do |media|
113
+ puts <<~MEDIA
114
+ title: #{media.title}
115
+ intro: #{media.intro}
116
+ bv: #{media.bv_id}
117
+ -----------------------------------------------------------------------
118
+ MEDIA
119
+ end
120
+ end
121
+ end
122
+
123
+ BiliConsole.start
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2021 leejoker
4
+ #
5
+ # This software is released under the MIT License.
6
+ # https://opensource.org/licenses/MIT
7
+
8
+ module Bilibili
9
+ module Api
10
+ module Login
11
+ QRCODE = 'https://passport.bilibili.com/qrcode/getLoginUrl'
12
+ INFO = 'https://passport.bilibili.com/qrcode/getLoginInfo'
13
+ USERINFO = 'https://api.bilibili.com/nav'
14
+ end
15
+
16
+ module Fav
17
+ USER_FAV_LIST = 'https://api.bilibili.com/x/v3/fav/folder/created/list-all'
18
+ FAV_VIDEO_LIST = 'https://api.bilibili.com/x/v3/fav/resource/list'
19
+ end
20
+
21
+ module Video
22
+ PAGE_LIST = 'https://api.bilibili.com/x/player/pagelist'
23
+ PLAY_URL = 'https://api.bilibili.com/x/player/playurl'
24
+ end
25
+
26
+ module Manga
27
+ CHECK_IN = 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn?platform=android'
28
+ end
29
+ end
30
+ end