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.start
end
client2 = LastFM::Client::CommandLineClient.new(lastfm, audio_output)
client2.start
end
|