Sha256: 87c162e7e8860db9bb004a13dea69bc5b592012f8035c15d4e18d0cf978784da

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

#!/usr/bin/env ruby

require 'douban.fm'

unless ARGV.length == 2
  p "douban_fm.rb <email> <password>"
  exit
end

email = ARGV[0]
password = ARGV[1]
douban_fm = DoubanFM::DoubanFM.new(email, password)
douban_fm.login
douban_fm.get_channels
douban_fm.select_channel(0)

# stop = false
# go_on = true
# while not stop
#   if go_on
#     p "================="
#     go_on = false
#     douban_fm.get_next_playlist
#     douban_fm.play_current_playlist do |waiting|
#       unless waiting
#         stop = true
#         break
#       else
#         go_on = true
#       end
#     end
#   else
#     sleep 10
#   end
# end

play_proc = proc do |waiting|
  if waiting
    begin
      douban_fm.get_next_playlist
    rescue
      douban_fm.login
    end
    
    douban_fm.play_current_playlist do |waiting|
      play_proc.call(waiting)
    end
  end
end

play_proc.call(true)

sleep

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
douban.fm-0.0.2 bin/douban.fm