3 ms·
Somewhat related but as I've been building a rails project I've been meaning to open source the song parser I've been building alongside it. It scans an mp3 an
by nwienert 14y ago
Somewhat related but as I've been building a rails project I've been meaning to open source the song parser I've been building alongside it. It scans an mp3 and pulls out the artists along with the type of role they played on the song. Here's a quick gist I pulled from my model:
https://gist.github.com/3680949 https://gist.github.com/3680949
Some examples:
Drake - The Motto (Jon Bellion Cover)
=> [["Jon Bellion", :cover], ["Drake", :original]]
David Byrne and Brian Eno - Strange Overtones
=> [["David Byrne", :original], ["Brian Eno", :original]]
Cheri Coke, MELO-X - Free
=> [["Cheri Coke", :original], ["MELO-X", :original]]
Avicii - Street Dancer (Whelan & Discala Remix)
=> [["Whelan", :remixer], ["Discala", :remixer], ["Avicii", :original]]
RAC - Hollywood featuring Penguin Prison (The Magician Remix)
=> [["Penguin Prison", :featured], ["The Magician", :remixer], ["RAC", :original]]
And a ridiculous example:
Eight, Nine & Ten (Eleven cover - Song name feat. One, Two & Three (Prod. by Four) (Five & Six remix) (Seven cover)
=> [["One", :featured], ["Three", :featured], ["Two", :featured], ["Four", :producer], ["Five", :remixer], ["Six", :remixer], ["Seven", :cover], ["Eight", :original], ["Nine", :original], ["Ten", :original], ["Eleven", :cover]]
If there's any interest, I'd love to turn it into a proper github repo and accept some pull requests.. it's far from perfect (both code-wise and generally) but works well for most cases.
- notJim 14y agoThis looks awesome. You should consider sticking it somewhere and giving it a name, so that I might find it 6 months from now when I'm motivated to fix my shitty Python script [1]. Also, a side question: is it normal/considered a best practice in ruby to monkey-patch built-in libraries like that? I know ruby has open classes, but I'm just curious how using them in this way is regarded. [1]: http://news.ycombinator.com/item?id=4494437 http://news.ycombinator.com/item?id=4494437
- nwienert 14y agoI put the link to the gist with the code for now, when I get a couple hours free sometime (soon I promise) I will do just that and put it on my github, so feel free to watch my account there. As for patching string.rb I don't know 100% but I believe thats the point of being full OO is that I can make a patch like that where it makes sense to do it. I was using those functions in multiple places, and given they are meant for strings it made sense. I can see the potential pitfalls when it comes to sharing things like this, but again, Ruby makes it easy for anyone to make the same patch for a reason.
- threedaymonk 14y ago> Also, a side question: is it normal/considered a best practice in ruby to monkey-patch built-in libraries like that? No, it's not considered to be good practice. I think it's generally frowned on by more experienced folk. However, ActiveSupport (which is part of Rails) does a lot of monkey-patching of the basic Ruby classes in this way, and that probably helps to perpetuate monkey-patching among newer developers.