-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from rightsup/fix-recording
Adds Recording::find & moves Track::search into Recording::search
- Loading branch information
Showing
42 changed files
with
168 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
||
group :test do | ||
gem "debugger" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# -*- encoding : utf-8 -*- | ||
require "musicbrainz" | ||
MB = MusicBrainz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# encoding: UTF-8 | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module Artist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module ArtistReleaseGroups | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# encoding: UTF-8 | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module ArtistSearch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module Recording | ||
def parse(xml) | ||
xml = xml.xpath('./recording') unless xml.xpath('./recording').empty? | ||
{ | ||
id: (xml.attribute('id').value rescue nil), | ||
mbid: (xml.attribute('id').value rescue nil), # Old shit | ||
title: (xml.xpath('./title').text.gsub(/[`’]/, "'") rescue nil), | ||
artist: (xml.xpath('./artist-credit/name-credit/artist/name').text rescue nil), | ||
releases: (xml.xpath('./release-list/release/title').map{ |xml| xml.text } rescue []), | ||
score: (xml.attribute('score').value.to_i rescue nil) | ||
} | ||
end | ||
|
||
extend self | ||
end | ||
end | ||
end |
4 changes: 2 additions & 2 deletions
4
lib/musicbrainz/bindings/track_search.rb → lib/musicbrainz/bindings/recording_search.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module Release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module ReleaseGroup | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module ReleaseGroupReleases | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# encoding: UTF-8 | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module ReleaseGroupSearch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module ReleaseTracks | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Bindings | ||
module Track | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
class Client | ||
include ClientModules::TransparentProxy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module ClientModules | ||
module CachingProxy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module ClientModules | ||
module FailsafeProxy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module ClientModules | ||
module TransparentProxy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
module Deprecated | ||
module ProxyConfig | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
class Middleware < Faraday::Middleware | ||
def call(env) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
class Artist < BaseModel | ||
field :id, String | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module MusicBrainz | ||
class Recording < BaseModel | ||
field :id, String | ||
field :mbid, String | ||
field :title, String | ||
field :artist, String | ||
field :releases, String | ||
field :score, Integer | ||
|
||
class << self | ||
def find(id) | ||
super({ id: id }) | ||
end | ||
|
||
def search(track_name, artist_name) | ||
super({recording: track_name, artist: artist_name}) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
class Release < BaseModel | ||
field :id, String | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
class ReleaseGroup < BaseModel | ||
field :id, String | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- encoding : utf-8 -*- | ||
module MusicBrainz | ||
VERSION = "0.7.7" | ||
end |
6 changes: 3 additions & 3 deletions
6
spec/bindings/track_search_spec.rb → spec/bindings/recording_search_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# encoding: utf-8 | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "ostruct" | ||
require "spec_helper" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
describe MusicBrainz::Recording do | ||
describe '.find' do | ||
it "gets no exception while loading release info" do | ||
expect { | ||
MusicBrainz::Recording.find("b3015bab-1540-4d4e-9f30-14872a1525f7") | ||
}.to_not raise_error(Exception) | ||
end | ||
|
||
it "gets correct instance" do | ||
track = MusicBrainz::Recording.find("b3015bab-1540-4d4e-9f30-14872a1525f7") | ||
expect(track).to be_an_instance_of(MusicBrainz::Recording) | ||
end | ||
|
||
it "gets correct track data" do | ||
track = MusicBrainz::Recording.find("b3015bab-1540-4d4e-9f30-14872a1525f7") | ||
expect(track.title).to eq "Empire" | ||
end | ||
end | ||
|
||
describe '.search' do | ||
it "searches tracks (aka recordings) by artist name and title" do | ||
matches = MusicBrainz::Recording.search('Bound for the floor', 'Local H') | ||
expect(matches.length).to be > 0 | ||
expect(matches.first[:title]).to eq "Bound for the Floor" | ||
expect(matches.first[:artist]).to eq "Local H" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
# -*- encoding : utf-8 -*- | ||
|
||
require "spec_helper" | ||
|
||
|
Oops, something went wrong.