diff --git a/id3-album.rb b/id3-album.rb index 7dd205f..feeebc0 100755 --- a/id3-album.rb +++ b/id3-album.rb @@ -17,14 +17,24 @@ unless File.exist?("albumart.jpg") exit 1 end -$stdout.write("Artist: ") -artist = gets.chomp +unless File.exist?("info.txt") + $stderr.puts "info.txt not found" + exit 1 +end -$stdout.write("Album: ") -album = gets.chomp +info = File.read("info.txt") +info =~ /^artist: (.*)$/ +artist = $1 +info =~ /^album: (.*)$/ +album = $1 +info =~ /^year: (.*)$/ +date = $1 + +unless artist && album && date + $stderr.puts "invalid info.txt format" + exit 1 +end -$stdout.write("Release year: ") -date = gets.chomp #$stdout.write("Release date (YYYY-MM-DD): ") #date = gets.chomp #unless date =~ /^\d{4}-\d{2}-\d{2}$/