From arminotto at googlemail.com Thu Aug 9 11:24:18 2007 From: arminotto at googlemail.com (Armin Otto) Date: Thu, 9 Aug 2007 17:24:18 +0200 Subject: [Rbrainz-users] using MusicBrainz::Model::Artist Message-ID: Hi, been playing around with the rbrainz library in rails again. For starters i wanted to get some artist information. so, my controller gets: @query = MusicBrainz::Webservice::Query.new @filter = MusicBrainz::Webservice::ArtistFilter.new(:name => "Michael Jackson") @results = @query.get_artists(@filter) in the matching view i wanted to print out the content of each result. Sinc the MusicBrainz::Model::Artist class isn't really documented I looked the attributes up with .inspect and tried to display them in the view: <% @results.each do |x| %> <%end%>
<%=h x.score %> <%=h x.entity.aliases.count %> <%=h x.entity.aliases.entries %> <%=h x.entity.aliases.offset %> <%=h x.entity.begin_date %> <%=h x.entity.disambiguation %> <%=h x.entity.end_date %> <%=h x.entity.id.entity %> <%=h x.entity.id.uuid %> <%=h x.entity.name %> <%=h x.entity.releases.count %> <%=h x.entity.releases.entries %> <%=h x.entity.releases.offset %> <%=h x.entity.sort_name %> <%=h x.entity.tags.count %> <%=h x.entity.tags.entries %> <%=h x.entity.tags.offset %> <%=h x.entity.type %>
Those work find, however, when I try to access the @relations attribute, i can't. Is that intentional and what is that thing for ? Cheers, Arotto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rbrainz-users/attachments/20070809/fcb4c8e3/attachment-0001.html From nigel at maven-group.org Thu Aug 9 11:33:55 2007 From: nigel at maven-group.org (Nigel Graham) Date: Thu, 09 Aug 2007 17:33:55 +0200 Subject: [Rbrainz-users] using MusicBrainz::Model::Artist In-Reply-To: References: Message-ID: <46BB33E3.1080104@maven-group.org> An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rbrainz-users/attachments/20070809/5108bb90/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: nigel.vcf Type: text/x-vcard Size: 163 bytes Desc: not available Url : http://rubyforge.org/pipermail/rbrainz-users/attachments/20070809/5108bb90/attachment.vcf From phw at rubyforge.org Sat Aug 11 10:33:09 2007 From: phw at rubyforge.org (Philipp Wolfer) Date: Sat, 11 Aug 2007 16:33:09 +0200 Subject: [Rbrainz-users] RBrainz 0.3 released Message-ID: RBrainz 0.3.0 has been released. This release fixes a bug with relation end dates and makes it easier to work with values such as release types or relation attributes with or without namespace. See the changelog at http://rbrainz.rubyforge.org/api/files/CHANGES.html for details. For more information about RBrainz see the following resources: Homepage: http://rbrainz.rubyforge.org API documentation: http://rbrainz.rubyforge.org/api/ Download: http://rubyforge.org/frs/?group_id=3677 -- Philipp Wolfer From arminotto at googlemail.com Fri Aug 17 07:57:16 2007 From: arminotto at googlemail.com (Armin Otto) Date: Fri, 17 Aug 2007 13:57:16 +0200 Subject: [Rbrainz-users] REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) Message-ID: I filled my database some time ago with lots of song titles and artist names. some special characters turned up like the evil german Umlaute. :) I'll tidy that up, of course, however, a program i wrote to scan musicbrainz using the names in the database gave me an unexpected error. To demonstrate, i included two queries. The first one works, the second doesn't. And I have no idea why it doesn't and the other one does, since they don't look that different to me. (both are expected to deliver no usable results, but thats okay ;) ) here's the executable source : -------------------- snip ------------------- require 'rbrainz' def self.get_brainz_tracks(filter, includes = { :artist => true, :releases => true, :puids => true, :artist_rels => true, :release_rels => true, :track_rels => true, :label_rels => true, :url_rels => true, :tags => true }) track_includes = MusicBrainz::Webservice::TrackIncludes.new(includes) query = MusicBrainz::Webservice::Query.new track_filter = MusicBrainz::Webservice::TrackFilter.new(filter) puts track_filter.inspect begin result = query.get_tracks(track_filter) puts "# result size: #{result.size}" rescue puts $! result = nil end result end puts get_brainz_tracks({ :title => "Lil\302\264 Love", :artist => "Little love", :limit => 5 }) puts get_brainz_tracks({ :title => "Christina St\374rmer", :artist => "Mama (Ana Ahabak)", :limit => 5 }) --------------- snip ------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rbrainz-users/attachments/20070817/7bcbd32b/attachment.html From phw at rubyforge.org Fri Aug 17 08:45:52 2007 From: phw at rubyforge.org (Philipp Wolfer) Date: Fri, 17 Aug 2007 14:45:52 +0200 Subject: [Rbrainz-users] REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) In-Reply-To: References: Message-ID: Interesting. I tried to query the MusicBrainz service directly for "Christina St?rmer" with the URL below. MusicBrainz returns a broken XML document with some Apache error page included (which explains the parser error). http://musicbrainz.org/ws/1/track/?type=xml&title=Christina%20St%FCrmer Trying the same search with "Christina St?rmer" works: http://musicbrainz.org/ws/1/track/?type=xml&title=Christina%20St%E4rmer Searching just for "?" doesn't work, however: http://musicbrainz.org/ws/1/track/?type=xml&title=%E4 This does not seem to be an error in RBrainz but a problem with the MusicBrainz server itself. I have opened a bug report for the MusicBrainz web service: http://bugs.musicbrainz.org/ticket/3100 -- Philipp Wolfer From phw at rubyforge.org Fri Aug 17 10:41:16 2007 From: phw at rubyforge.org (Philipp Wolfer) Date: Fri, 17 Aug 2007 16:41:16 +0200 Subject: [Rbrainz-users] REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) In-Reply-To: References: Message-ID: Hello Armin, Ok, some more information: All requests to the MB server must be UTF-8 encoded, the above example uses latin1. This causes the trouble. Try to save the test file with UTF-8 encoding and write "?" instead of "\374" or use the iconv module to convert between the encodings like Iconv.iconv("utf-8", "iso-8859-1", "Christina St\374rmer").to_s By the way: RBrainz will always return UTF-8 strings. If you need to do some string processing with the results you might want to use jcode in your application. Just include it with the following two lines and you can safely use string operations. require 'jcode' $KCODE='UTF8' -- Philipp Wolfer From arminotto at googlemail.com Fri Aug 17 19:41:49 2007 From: arminotto at googlemail.com (Armin Otto) Date: Sat, 18 Aug 2007 01:41:49 +0200 Subject: [Rbrainz-users] REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) In-Reply-To: References: Message-ID: i guess i'll have to, thanks. by the way: Even though I have a rescue block, in case the mentionen error occurs, the program terminates. no rescueing possible. how come ? 2007/8/17, Philipp Wolfer : > > Hello Armin, > > Ok, some more information: > > All requests to the MB server must be UTF-8 encoded, the above example > uses latin1. This causes the trouble. > > Try to save the test file with UTF-8 encoding and write "?" instead of > "\374" or use the iconv module to convert between the encodings like > > Iconv.iconv("utf-8", "iso-8859-1", "Christina St\374rmer").to_s > > By the way: RBrainz will always return UTF-8 strings. If you need to > do some string processing with the results you might want to use jcode > in your application. Just include it with the following two lines and > you can safely use string operations. > > require 'jcode' > $KCODE='UTF8' > > > > -- > Philipp Wolfer > _______________________________________________ > Rbrainz-users mailing list > Rbrainz-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rbrainz-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rbrainz-users/attachments/20070818/09b01a2e/attachment.html From phw at rubyforge.org Sat Aug 18 04:38:05 2007 From: phw at rubyforge.org (Philipp Wolfer) Date: Sat, 18 Aug 2007 10:38:05 +0200 Subject: [Rbrainz-users] Fwd: REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) In-Reply-To: References: Message-ID: 2007/8/18, Armin Otto : > by the way: Even though I have a rescue block, in case the mentionen error > occurs, the program terminates. > no rescueing possible. how come ? I actually don't know, but I often noticed that in Ruby one has to catch an exception (in this case MusicBrainz::Webservice::ResponseError) explicitly in order for it to work. You can as well just write "rescue Exception", but rescue without any type won't work. If somebody knows why exceptions behave that way, please let me know. -- Philipp Wolfer -- Philipp Wolfer From p.eberli at gmx.ch Tue Aug 21 13:35:55 2007 From: p.eberli at gmx.ch (Philippe) Date: Tue, 21 Aug 2007 19:35:55 +0200 Subject: [Rbrainz-users] Tag MP3 with rbrainz Message-ID: <267E613A-9E51-40C9-BA77-DBD58F3D0602@gmx.ch> Hello Everybody I've programmed a script to tag albums of MP3s with rbrainz. I couldn't find a complete, real world example, so I share this one. Feel free to do anything you want with it... Philippe -------------- next part -------------- A non-text attachment was scrubbed... Name: rtag.rb Type: text/x-ruby-script Size: 3213 bytes Desc: not available Url : http://rubyforge.org/pipermail/rbrainz-users/attachments/20070821/60a30aff/attachment-0001.bin From phw at rubyforge.org Mon Aug 27 16:38:13 2007 From: phw at rubyforge.org (Philipp Wolfer) Date: Mon, 27 Aug 2007 22:38:13 +0200 Subject: [Rbrainz-users] REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) In-Reply-To: References: Message-ID: 2007/8/27, Armin Otto : > are you sure that rbrainz SENDS utf-8 strings ? > I tried a query with some evil un-english characters and do not get any > results. RBrainz itself does not take care of the character encoding, you have to pass properly encoded strings. In your example you have to be careful, if you save that file as a UTF-8 encoded file you'll double encode the characters (meaning each of the two bytes of the UTF-8 character '?' is treated as a Latin1 character and get's converted into it's UTF-8 representation. You then end up with four bytes representing two UTF-8 characters. So either you save the file as UTF-8 without the iconv call or you save the file as ISO-8859-1 with the conversion in the code. Both works for me. There are several reasons why RBrainz has no special UTF-8 support: 1. Ruby has currently bad support for UTF-8 (will get better in Ruby 1.9), you only can set the encoding globally. But applications using Rbrainz may use other encodings. 2. You can't automatically convert strings passed to RBrainz to UTF-8, since RBrainz doesn't know anything about the encoding the application uses. 3. RBrainz does not need $KCODE set to UTF-8, since it does not use any critical string operations (e.g. String#size or substring#slice) So the only way is for the application using RBrainz to take care of the encoding. But if you want to display international artists you will most likely end up using UTF-8 in your application anyway :-) I will add some information about that topic to the RBrainz documentaion since it is currently not clear. -- Philipp Wolfer From arminotto at googlemail.com Tue Aug 28 08:50:27 2007 From: arminotto at googlemail.com (Armin Otto) Date: Tue, 28 Aug 2007 14:50:27 +0200 Subject: [Rbrainz-users] REXML::ParseException: Declarations can only occur in the doctype declaration. (MusicBrainz::Webservice::ResponseError) In-Reply-To: References: Message-ID: Hi Phillip, no matter what I try, i can't seem to get a result for queries for "Jos? Gonz?lez". I get the name-strings from a databyse and analysed the name bytewise and it's the same as the Iconv-version: J o s ? (c) G o n z ? ? l e s 74 111 115 195 169 32 71 111 110 122 195 161 108 101 115 I just have to assume that the above is utf-8 encoded, since i get it this ways: Iconv.iconv("utf-8", "iso-8859-1", "Jos? Gonz?les").to_s anyway, no results. so I'd like to ask you if you can get results for Mr Gonz?les using rbrainz with the source saved normally - not in utf-8. thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rbrainz-users/attachments/20070828/1e8bdf44/attachment.html