File: submittrm.rb

package info (click to toggle)
libmusicbrainz-ruby 0.2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 408 kB
  • ctags: 144
  • sloc: ansic: 562; ruby: 286; makefile: 5
file content (32 lines) | stat: -rwxr-xr-x 687 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
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
#!/usr/bin/ruby 

require 'musicbrainz'

# allocate a new MusicBrainz client
mb = MusicBrainz::Client.new
mb.depth = 2

# handle environment variables
mb.server = server if server = ENV['MB_SERVER']
mb.debug = true if ENV['MB_DEBUG']
mb.depth = depth.to_i if depth = ENV['MB_DEPTH']

unless ARGV.size > 3
  $stderr.puts 'Missing authentication and query strings.'
  exit -1
end

auth = [ARGV[0], ARGV[1]]
query = [ARGV[2], ARGV[3]]

if mb.auth *auth
  puts 'Authenticated ok.'

  if mb.query(MusicBrainz::Query::SubmitTrackTRMId, *query)
    puts 'TRM submitted.  Thanks!'
  else
    $stderr.puts 'Error: ' << mb.error
  end
else
  $stderr.puts 'Authentication Failed: ' << mb.error
end