Top Level Namespace

Defined Under Namespace

Classes: LastFM

Instance Method Summary collapse

Instance Method Details

#creditsObject



410
411
412
413
414
415
# File 'lib/lastfm.rb', line 410

def credits
  message = "lastfm-cli : a last.fm ruby client. by daniel choi / betahouse.org / Apr 2008"
  puts "-" * message.length
  puts message
  puts "-" * message.length
end

#parse_optionsObject



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/lastfm.rb', line 419

def parse_options
  opts = GetoptLong.new(
    [ "--username", "-u", GetoptLong::REQUIRED_ARGUMENT],
    [ "--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
    [ "--help", "-h", GetoptLong::OPTIONAL_ARGUMENT],
    [ "--telnetport", "-t", GetoptLong::OPTIONAL_ARGUMENT]
  )

  username, password, telnetport  = nil, nil, 8004
  print "LastFM Username: "
  username = STDIN.gets.chomp 
  print "LastFM Password (will remain hidden): "
  `stty -echo`
  password = STDIN.gets.chomp ensure `stty echo`
  puts
  print "Telnet port (default is 8004): "
  telnetport = STDIN.gets.chomp  
  telnetport = if telnetport == "" 
    8004
  else
    telnetport.to_i
  end

  if username.nil? || password.nil?
    puts
    puts "* MISSING SOME REQUIRED ARGUMENTS *"
  
    exit
  end
  lastfm = LastFM.new(:username => username, :password => password)
  audio_output = LastFM::AudioOutput::ITunes.new(lastfm.stream_url)
  audio_output.start
  puts "starting iTunes radio..."
  puts "Please be patient.\nIt may take some time to connect to the lastfm stream."
  Thread.new do
    client = LastFM::Client::TelnetClient.new(lastfm, audio_output, telnetport)
    #client = LastFM::Client::TelnetClient.new(lastfm, audio_output, 8004)
    client.start
  end
  client2 = LastFM::Client::CommandLineClient.new(lastfm, audio_output)
  client2.start

end