mb-discid 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -1
- data/README +3 -3
- data/Rakefile +9 -11
- data/examples/discid.rb +3 -1
- data/ext/extconf.rb +7 -4
- data/ext/mb_discid.c +62 -5
- data/lib/mb-discid.rb +9 -3
- data/test/test_discid.rb +1 -1
- metadata +25 -45
data/CHANGES
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
= Changelog
|
2
|
+
== 0.2.0 (2013-02-17)
|
3
|
+
* Support for MCN and ISRC (requires libdiscid >= 0.3)
|
2
4
|
|
3
5
|
== 0.1.5 (2011-07-02)
|
4
6
|
* Added binding for get_webservice_url()
|
@@ -31,4 +33,4 @@
|
|
31
33
|
== 0.1.0 (2007-06-02)
|
32
34
|
* Initial release
|
33
35
|
|
34
|
-
$Id
|
36
|
+
$Id$
|
data/README
CHANGED
@@ -7,7 +7,7 @@ to find the release entry for your CD in the MusicBrainz database.
|
|
7
7
|
|
8
8
|
== Requirements
|
9
9
|
* Ruby >= 1.8.6
|
10
|
-
* libdiscid >= 0.2.2
|
10
|
+
* libdiscid >= 0.2.2 (>= 0.3.0 for MCN and ISRC support)
|
11
11
|
|
12
12
|
== Installation
|
13
13
|
Before installing rdiscid make sure you have libdiscid installed. See
|
@@ -47,8 +47,8 @@ If you find bugs or if you have any feature requests please use the
|
|
47
47
|
RBrainz bug tracker[http://rubyforge.org/tracker/?group_id=3677].
|
48
48
|
|
49
49
|
== License
|
50
|
-
MB-DiscID is Copyright (c) 2007 Philipp Wolfer.
|
50
|
+
MB-DiscID is Copyright (c) 2007-2013 Philipp Wolfer.
|
51
51
|
It is free softare distributed under a BSD style license. See
|
52
52
|
LICENSE[link:files/LICENSE.html] for details.
|
53
53
|
|
54
|
-
$Id
|
54
|
+
$Id$
|
data/Rakefile
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# $Id
|
2
|
-
# Copyright (c) 2007, Philipp Wolfer
|
1
|
+
# $Id$
|
2
|
+
# Copyright (c) 2007-2013, Philipp Wolfer
|
3
3
|
# All rights reserved.
|
4
4
|
# See LICENSE for permissions.
|
5
5
|
|
6
|
-
# Rakefile for
|
6
|
+
# Rakefile for MBDiscID
|
7
7
|
|
8
8
|
require 'rubygems'
|
9
|
-
require '
|
9
|
+
require 'rubygems/package_task'
|
10
10
|
require 'rake/testtask'
|
11
|
-
require '
|
11
|
+
require 'rdoc/task'
|
12
12
|
|
13
13
|
task :default do
|
14
14
|
puts "Please see 'rake --tasks' for an overview of the available tasks."
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
# Packaging tasks: -------------------------------------------------------
|
18
18
|
|
19
19
|
PKG_NAME = 'mb-discid'
|
20
|
-
PKG_VERSION = '0.
|
20
|
+
PKG_VERSION = '0.2.0'
|
21
21
|
PKG_SUMMARY = 'Ruby bindings for libdiscid.'
|
22
22
|
PKG_AUTHOR = 'Philipp Wolfer'
|
23
23
|
PKG_EMAIL = 'phw@rubyforge.org'
|
@@ -50,9 +50,8 @@ spec = Gem::Specification.new do |spec|
|
|
50
50
|
spec.extensions << 'ext/extconf.rb'
|
51
51
|
spec.required_ruby_version = ">= 1.8.6"
|
52
52
|
end
|
53
|
-
spec.requirements << 'libdiscid >= 0.
|
53
|
+
spec.requirements << 'libdiscid >= 0.3.0 (http://musicbrainz.org/doc/libdiscid)'
|
54
54
|
spec.require_paths = ['lib', 'ext']
|
55
|
-
spec.autorequire = spec.name
|
56
55
|
spec.description = PKG_DESCRIPTION
|
57
56
|
spec.author = PKG_AUTHOR
|
58
57
|
spec.email = PKG_EMAIL
|
@@ -62,7 +61,7 @@ spec = Gem::Specification.new do |spec|
|
|
62
61
|
spec.extra_rdoc_files = PKG_EXTRA_RDOC_FILES
|
63
62
|
end
|
64
63
|
|
65
|
-
|
64
|
+
Gem::PackageTask.new(spec) do |pkg|
|
66
65
|
pkg.need_zip = true
|
67
66
|
pkg.need_tar_gz= true
|
68
67
|
end
|
@@ -79,8 +78,7 @@ task :build do
|
|
79
78
|
|
80
79
|
cd 'ext' do
|
81
80
|
unless system("ruby extconf.rb #{extconf_args}")
|
82
|
-
STDERR.puts "ERROR: could not configure extension
|
83
|
-
"\n#{INFO_NOTE}\n"
|
81
|
+
STDERR.puts "ERROR: could not configure extension!"
|
84
82
|
break
|
85
83
|
end
|
86
84
|
|
data/examples/discid.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
# Example:
|
10
10
|
# ./discid.rb /dev/dvd
|
11
11
|
#
|
12
|
-
# $Id
|
12
|
+
# $Id$
|
13
13
|
|
14
14
|
# Just make sure we can run this example from the command
|
15
15
|
# line even if RBrainz is not yet installed properly.
|
@@ -43,6 +43,7 @@ First track : #{disc.first_track_num}
|
|
43
43
|
Last track : #{disc.last_track_num}
|
44
44
|
Total length: #{disc.seconds} seconds
|
45
45
|
Sectors : #{disc.sectors}
|
46
|
+
MCN : #{disc.media_catalog_number}
|
46
47
|
EOF
|
47
48
|
|
48
49
|
# Print information about individual tracks:
|
@@ -54,6 +55,7 @@ disc.track_details do |track_info|
|
|
54
55
|
[track_info.start_time / 60, track_info.start_time % 60, track_info.start_sector]
|
55
56
|
puts " End : %02d:%02d (sector %i)" %
|
56
57
|
[track_info.end_time / 60, track_info.end_time % 60, track_info.end_sector]
|
58
|
+
puts " ISRC : %s" % track_info.isrc
|
57
59
|
end
|
58
60
|
|
59
61
|
# Print a submission URL that can be used to submit
|
data/ext/extconf.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Id
|
2
|
+
# $Id$
|
3
3
|
|
4
4
|
require 'mkmf'
|
5
5
|
|
6
|
-
LIBDIR =
|
7
|
-
INCLUDEDIR =
|
6
|
+
LIBDIR = RbConfig::CONFIG['libdir']
|
7
|
+
INCLUDEDIR = RbConfig::CONFIG['includedir']
|
8
8
|
|
9
9
|
$CFLAGS << " #{ENV["CFLAGS"]}"
|
10
10
|
$LIBS << " #{ENV["LIBS"]}"
|
11
11
|
|
12
12
|
# totally thieved from Nokogiri's extconf.rb
|
13
|
-
if
|
13
|
+
if RbConfig::CONFIG['target_os'] =~ /mswin32/
|
14
14
|
# There's no default include/lib dir on Windows. Let's just add the Ruby ones
|
15
15
|
# and resort on the search path specified by INCLUDE and LIB environment
|
16
16
|
# variables
|
@@ -51,6 +51,9 @@ dir_config('discid', HEADER_DIRS, LIB_DIRS)
|
|
51
51
|
|
52
52
|
if have_library('discid', 'discid_new') or
|
53
53
|
have_library('discid.dll', 'discid_new')
|
54
|
+
headers = ['discid/discid.h']
|
55
|
+
have_func('discid_get_mcn', headers)
|
56
|
+
have_func('discid_get_track_isrc', headers)
|
54
57
|
# Remove -MD from compiler flags on Windows.
|
55
58
|
$CFLAGS.sub!('-MD', '') if RUBY_PLATFORM.include? 'win32'
|
56
59
|
create_makefile('MB_DiscID')
|
data/ext/mb_discid.c
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
/**
|
2
|
-
* $Id
|
2
|
+
* $Id$
|
3
3
|
*
|
4
4
|
* Ruby bindings for libdiscid. See http://musicbrainz.org/doc/libdiscid
|
5
5
|
* for more information on libdiscid and MusicBrainz.
|
6
6
|
*
|
7
7
|
* Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
8
|
-
* Copyright:: Copyright (c) 2007, Philipp Wolfer
|
8
|
+
* Copyright:: Copyright (c) 2007-2013, Philipp Wolfer
|
9
9
|
* License:: MB-DiscID is free software distributed under a BSD style license.
|
10
10
|
* See LICENSE for permissions.
|
11
11
|
*/
|
@@ -110,6 +110,33 @@ static VALUE mb_discid_freedb_id(VALUE self)
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
|
113
|
+
/**
|
114
|
+
* call-seq:
|
115
|
+
* mcn() -> string or nil
|
116
|
+
*
|
117
|
+
* Return the media catalogue number of the release, if present.
|
118
|
+
*
|
119
|
+
* Requires libdiscid >= 0.3. If not supported this method will always return +nil+.
|
120
|
+
*
|
121
|
+
* Returns +nil+ if no ID was yet read.
|
122
|
+
*/
|
123
|
+
static VALUE mb_discid_mcn(VALUE self)
|
124
|
+
{
|
125
|
+
#ifdef HAVE_DISCID_GET_MCN
|
126
|
+
if (rb_iv_get(self, "@read") == Qfalse)
|
127
|
+
return Qnil;
|
128
|
+
else
|
129
|
+
{
|
130
|
+
DiscId *disc;
|
131
|
+
Data_Get_Struct(self, DiscId, disc);
|
132
|
+
|
133
|
+
return rb_str_new2(discid_get_mcn(disc));
|
134
|
+
}
|
135
|
+
#else
|
136
|
+
return Qnil;
|
137
|
+
#endif
|
138
|
+
}
|
139
|
+
|
113
140
|
/**
|
114
141
|
* call-seq:
|
115
142
|
* first_track_num() -> int or nil
|
@@ -225,6 +252,34 @@ static VALUE mb_discid_tracks(VALUE self)
|
|
225
252
|
}
|
226
253
|
}
|
227
254
|
|
255
|
+
/**
|
256
|
+
* call-seq:
|
257
|
+
* isrc(track)
|
258
|
+
*
|
259
|
+
* Returns the International Standard Recording Code (ISRC) for the track.
|
260
|
+
*
|
261
|
+
* Requires libdiscid >= 0.3. If not supported this method will always return +nil+.
|
262
|
+
*
|
263
|
+
* Returns always +nil+ if no ID was yet read.
|
264
|
+
*/
|
265
|
+
static VALUE mb_discid_isrc(VALUE self, VALUE track)
|
266
|
+
{
|
267
|
+
#ifdef HAVE_DISCID_GET_TRACK_ISRC
|
268
|
+
if (rb_iv_get(self, "@read") == Qfalse)
|
269
|
+
return Qnil;
|
270
|
+
else
|
271
|
+
{
|
272
|
+
DiscId *disc; /* Pointer to the disc struct */
|
273
|
+
int ctrack = NUM2INT(track); /* Track number to process. */
|
274
|
+
|
275
|
+
Data_Get_Struct(self, DiscId, disc);
|
276
|
+
return rb_str_new2(discid_get_track_isrc(disc, ctrack));
|
277
|
+
}
|
278
|
+
#else
|
279
|
+
return Qnil;
|
280
|
+
#endif
|
281
|
+
}
|
282
|
+
|
228
283
|
/**
|
229
284
|
* call-seq:
|
230
285
|
* read(device=nil)
|
@@ -263,12 +318,11 @@ static VALUE mb_discid_read(int argc, VALUE *argv, VALUE self)
|
|
263
318
|
|
264
319
|
/* Read the discid */
|
265
320
|
if (discid_read(disc, cdevice) == 0)
|
266
|
-
rb_raise(rb_eException, discid_get_error_msg(disc));
|
321
|
+
rb_raise(rb_eException, "%s", discid_get_error_msg(disc));
|
267
322
|
else /* Remember that we already read the ID. */
|
268
323
|
rb_iv_set(self, "@read", Qtrue);
|
269
324
|
|
270
325
|
return Qnil;
|
271
|
-
|
272
326
|
}
|
273
327
|
|
274
328
|
/**
|
@@ -314,7 +368,7 @@ static VALUE mb_discid_put(VALUE self, VALUE first_track, VALUE sectors,
|
|
314
368
|
|
315
369
|
/* Read the discid */
|
316
370
|
if (discid_put(disc, cfirst, clast, coffsets) == 0)
|
317
|
-
rb_raise(rb_eException, discid_get_error_msg(disc));
|
371
|
+
rb_raise(rb_eException, "%s", discid_get_error_msg(disc));
|
318
372
|
else /* Remember that we already read the ID. */
|
319
373
|
rb_iv_set(self, "@read", Qtrue);
|
320
374
|
|
@@ -378,8 +432,11 @@ void Init_MB_DiscID()
|
|
378
432
|
rb_define_method(cDiscID, "submission_url", mb_discid_submission_url, 0);
|
379
433
|
rb_define_method(cDiscID, "webservice_url", mb_discid_webservice_url, 0);
|
380
434
|
rb_define_method(cDiscID, "freedb_id", mb_discid_freedb_id, 0);
|
435
|
+
rb_define_method(cDiscID, "media_catalog_number", mb_discid_mcn, 0);
|
381
436
|
rb_define_method(cDiscID, "first_track_num", mb_discid_first_track_num, 0);
|
382
437
|
rb_define_method(cDiscID, "last_track_num", mb_discid_last_track_num, 0);
|
383
438
|
rb_define_method(cDiscID, "sectors", mb_discid_sectors, 0);
|
384
439
|
rb_define_method(cDiscID, "tracks", mb_discid_tracks, 0);
|
440
|
+
|
441
|
+
rb_define_method(cDiscID, "isrc", mb_discid_isrc, 1);
|
385
442
|
}
|
data/lib/mb-discid.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id
|
1
|
+
# $Id$
|
2
2
|
#
|
3
3
|
# Just a helper file to allow loading the MB-DiscID library with
|
4
4
|
# <tt>require 'mb-discid'</tt>, which is the only recommended way
|
@@ -122,11 +122,15 @@ module MusicBrainz
|
|
122
122
|
# Start position of the track on the disc in sectors.
|
123
123
|
attr_reader :start_sector
|
124
124
|
|
125
|
+
# ISRC number of the trac
|
126
|
+
attr_reader :isrc
|
127
|
+
|
125
128
|
# Returns a new TrackInfo.
|
126
|
-
def initialize(number, offset, length)
|
129
|
+
def initialize(number, offset, length, isrc)
|
127
130
|
@number = number
|
128
131
|
@start_sector = offset
|
129
132
|
@sectors = length
|
133
|
+
@isrc = isrc
|
130
134
|
end
|
131
135
|
|
132
136
|
# End position of the track on the disc in sectors.
|
@@ -171,6 +175,7 @@ module MusicBrainz
|
|
171
175
|
:seconds => seconds,
|
172
176
|
:start_time => start_time,
|
173
177
|
:end_time => end_time,
|
178
|
+
:isrc => isrc,
|
174
179
|
}
|
175
180
|
end
|
176
181
|
|
@@ -204,7 +209,8 @@ module MusicBrainz
|
|
204
209
|
|
205
210
|
self.tracks do |offset, length|
|
206
211
|
track_number += 1
|
207
|
-
|
212
|
+
isrc = self.isrc(track_number)
|
213
|
+
track_info = TrackInfo.new(track_number, offset, length, isrc)
|
208
214
|
|
209
215
|
if block_given?
|
210
216
|
yield track_info
|
data/test/test_discid.rb
CHANGED
metadata
CHANGED
@@ -1,35 +1,27 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mb-discid
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 5
|
10
|
-
version: 0.1.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Philipp Wolfer
|
14
|
-
autorequire:
|
9
|
+
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-07-02 00:00:00 +02:00
|
19
|
-
default_executable:
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
|
-
|
14
|
+
description: ! " Ruby bindings for libdiscid. See http://musicbrainz.org/doc/libdiscid\n
|
15
|
+
\ for more information on libdiscid and MusicBrainz.\n"
|
23
16
|
email: phw@rubyforge.org
|
24
17
|
executables: []
|
25
|
-
|
26
|
-
extensions:
|
18
|
+
extensions:
|
27
19
|
- ext/extconf.rb
|
28
|
-
extra_rdoc_files:
|
20
|
+
extra_rdoc_files:
|
29
21
|
- README
|
30
22
|
- LICENSE
|
31
23
|
- CHANGES
|
32
|
-
files:
|
24
|
+
files:
|
33
25
|
- Rakefile
|
34
26
|
- LICENSE
|
35
27
|
- README
|
@@ -39,42 +31,30 @@ files:
|
|
39
31
|
- ext/extconf.rb
|
40
32
|
- lib/mb-discid.rb
|
41
33
|
- test/test_discid.rb
|
42
|
-
has_rdoc: true
|
43
34
|
homepage: http://rbrainz.rubyforge.org
|
44
35
|
licenses: []
|
45
|
-
|
46
36
|
post_install_message:
|
47
37
|
rdoc_options: []
|
48
|
-
|
49
|
-
require_paths:
|
38
|
+
require_paths:
|
50
39
|
- lib
|
51
40
|
- ext
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
42
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
hash: 59
|
58
|
-
segments:
|
59
|
-
- 1
|
60
|
-
- 8
|
61
|
-
- 6
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
62
46
|
version: 1.8.6
|
63
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
48
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
version: "0"
|
72
|
-
requirements:
|
73
|
-
- libdiscid >= 0.2.2 (http://musicbrainz.org/doc/libdiscid)
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements:
|
54
|
+
- libdiscid >= 0.3.0 (http://musicbrainz.org/doc/libdiscid)
|
74
55
|
rubyforge_project: rbrainz
|
75
|
-
rubygems_version: 1.
|
56
|
+
rubygems_version: 1.8.23
|
76
57
|
signing_key:
|
77
58
|
specification_version: 3
|
78
59
|
summary: Ruby bindings for libdiscid.
|
79
60
|
test_files: []
|
80
|
-
|