vericast-ifpi 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/vericast-ifpi.rb +33 -0
- data/sample.rb +5 -0
- metadata +66 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: a80aabea4b6d510422c636348cbdf67cbee08dc4
         | 
| 4 | 
            +
              data.tar.gz: 768896e252510790691f7a54a07f9177f362275a
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 930d4d49ccfa2dd77ade80466c96915aa7020781c2ce55fc6d1e8a4705aa5e15b80adc3a7495e9b2c5e7c9ceb17682add563715c16564d809e30d3c4d9949ee4
         | 
| 7 | 
            +
              data.tar.gz: b1ebf623497ae85966c378fa377c890132cfd21a93639d15d92b2d4408eac3310039512902f1af7d52c002f13a3dcfb4282e744b820db87e98a4e0e46686eff0
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'nokogiri'
         | 
| 2 | 
            +
            require 'open-uri'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module VericastIFPI
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              BASE_URL = 'http://vericast.bmat.me/ifpi/search?lang=en'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              class Song
         | 
| 9 | 
            +
                attr_reader :artist_name, :song_title, :label, :isrc
         | 
| 10 | 
            +
                def initialize( artist_name, song_title, label, isrc )
         | 
| 11 | 
            +
                  @artist_name, @song_title, @label, @isrc = artist_name, song_title, label, isrc
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def song_lookup( params )
         | 
| 16 | 
            +
                results, search_url = [], BASE_URL
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                params.each { |p, v| search_url += "&#{p}=#{URI.encode(v)}" }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                page = Nokogiri::HTML( open(search_url).read() )
         | 
| 21 | 
            +
                matches = page.xpath("//div[@class='info_search_head']/text()").inner_text().strip().match(/Found (.+) result/)
         | 
| 22 | 
            +
                if matches
         | 
| 23 | 
            +
                  number_of_results = matches[1].to_i
         | 
| 24 | 
            +
                  page.xpath("//table[contains(@class, 'table table-striped')]/tbody/tr").each do |tr|
         | 
| 25 | 
            +
                    values = tr.xpath(".//td/text()").map { |e| e.inner_text().strip() }
         | 
| 26 | 
            +
                    results << Song.new( values[0], values[1], values[2], values[3] )
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                results
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            end
         | 
    
        data/sample.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: vericast-ifpi
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: '1.0'
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Matias Insaurralde
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-08-28 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: nokogiri
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.6'
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 1.6.1
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - "~>"
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '1.6'
         | 
| 30 | 
            +
                - - ">="
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 1.6.1
         | 
| 33 | 
            +
            description: Vericast is a global music identification service that monitors millons
         | 
| 34 | 
            +
              of songs over 3000 radios and televisions across more than 60 countries worldwide.
         | 
| 35 | 
            +
            email: matias@insaurral.de
         | 
| 36 | 
            +
            executables: []
         | 
| 37 | 
            +
            extensions: []
         | 
| 38 | 
            +
            extra_rdoc_files: []
         | 
| 39 | 
            +
            files:
         | 
| 40 | 
            +
            - lib/vericast-ifpi.rb
         | 
| 41 | 
            +
            - sample.rb
         | 
| 42 | 
            +
            homepage: https://github.com/matiasinsaurralde/vericast-ifpi
         | 
| 43 | 
            +
            licenses:
         | 
| 44 | 
            +
            - MIT
         | 
| 45 | 
            +
            metadata: {}
         | 
| 46 | 
            +
            post_install_message: 
         | 
| 47 | 
            +
            rdoc_options: []
         | 
| 48 | 
            +
            require_paths:
         | 
| 49 | 
            +
            - lib
         | 
| 50 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
              requirements:
         | 
| 52 | 
            +
              - - ">="
         | 
| 53 | 
            +
                - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                  version: '0'
         | 
| 55 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 56 | 
            +
              requirements:
         | 
| 57 | 
            +
              - - ">="
         | 
| 58 | 
            +
                - !ruby/object:Gem::Version
         | 
| 59 | 
            +
                  version: '0'
         | 
| 60 | 
            +
            requirements: []
         | 
| 61 | 
            +
            rubyforge_project: 
         | 
| 62 | 
            +
            rubygems_version: 2.2.2
         | 
| 63 | 
            +
            signing_key: 
         | 
| 64 | 
            +
            specification_version: 4
         | 
| 65 | 
            +
            summary: Gem for retrieving info from Vericast IFPI lookup service
         | 
| 66 | 
            +
            test_files: []
         |