Class: Bilibili::BilibiliBase
- Inherits:
-
Object
- Object
- Bilibili::BilibiliBase
- Defined in:
- lib/bilibili_console/base.rb
Overview
base class
Class Attribute Summary collapse
-
.video_qn ⇒ Object
Returns the value of attribute video_qn.
Instance Attribute Summary collapse
-
#http_client ⇒ Object
Returns the value of attribute http_client.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #clean_cookie ⇒ Object
-
#initialize(http_client) ⇒ BilibiliBase
constructor
A new instance of BilibiliBase.
- #load_cookie ⇒ Object
- #save_cookie ⇒ Object
Constructor Details
#initialize(http_client) ⇒ BilibiliBase
Returns a new instance of BilibiliBase.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bilibili_console/base.rb', line 23 def initialize(http_client) @http_client = http_client create_request_methods @options = { 'config_path' => '~/.bc', 'config_file' => '~/.bc/config.json', 'cookie_file' => '~/.bc/cookie.txt', 'download_path' => '~/.bc/download' } BilibiliBase.video_qn = { '240' => 6, '360' => 16, '480' => 32, '720' => 64, '720P60' => 74, '1080' => 80, '1080+' => 112, '1080P60' => 116, '4K' => 120, 'HDR' => 125 } end |
Class Attribute Details
.video_qn ⇒ Object
Returns the value of attribute video_qn.
20 21 22 |
# File 'lib/bilibili_console/base.rb', line 20 def video_qn @video_qn end |
Instance Attribute Details
#http_client ⇒ Object
Returns the value of attribute http_client.
17 18 19 |
# File 'lib/bilibili_console/base.rb', line 17 def http_client @http_client end |
#options ⇒ Object
Returns the value of attribute options.
17 18 19 |
# File 'lib/bilibili_console/base.rb', line 17 def @options end |
Instance Method Details
#clean_cookie ⇒ Object
53 54 55 56 57 |
# File 'lib/bilibili_console/base.rb', line 53 def File.open(, 'w') do |file| file.write('{}') end end |
#load_cookie ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/bilibili_console/base.rb', line 44 def return {} unless File.exist?() json_str = File.read() return {} if json_str.nil? || json_str.empty? JSON.parse(json_str) end |
#save_cookie ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/bilibili_console/base.rb', line 36 def check_config_path @http_client.api_http. = @http_client.login_http. json_str = @http_client.login_http..to_json (json_str) end |