Class: Nv::CLI
Instance Method Summary collapse
Methods included from Niconico::Helper
Instance Method Details
#config(key = nil, value = nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/nv/cli.rb', line 63 def config(key=nil, value=nil) config = Nv::Config.new(Nv::CONFIG_PATH) unless key puts "config:" config.to_h.each do |k, v| puts " #{k}=#{v}" end return end if value config[key] = value config.save end puts "config: #{key}=#{config[key]}" end |
#dl(ptr, output = ".") ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nv/cli.rb', line 7 def dl(ptr, output=".") config = Nv::Config.new(Nv::CONFIG_PATH) config.verify_for_authentication!('dl') nico = Niconico::Base.new.sign_in(config.email, config.password) if mylist?(ptr) mylist = nico.mylist(ptr) puts "Title : #{mylist.title}" puts "Desc : #{mylist.description}" mylist.items.each do |item| dl(item.link, output) end else video = nico.video(ptr) # Inspect puts "Downloading... #{video.title}" # Donwload video.download puts "+ done" end end |
#info(ptr) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nv/cli.rb', line 36 def info(ptr) config = Nv::Config.new(Nv::CONFIG_PATH) config.verify_for_authentication!('info') nico = Niconico::Base.new.sign_in(config.email, config.password) if mylist?(ptr) mylist = nico.mylist(ptr) puts "Title : #{mylist.title}" puts "Desc : #{mylist.description}" mylist.items.each_with_index do |item, i| puts " #{i+1}. #{item.title}" end else video = nico.video(ptr) puts video.title puts "=" * 40 puts video.description puts "=" * 40 puts "URL: #{video.watch_url}" end end |