xiami 0.0.6 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ed958b15c9b475d6f98252dbecac68459cabbac
4
- data.tar.gz: 558e09fbf8dae4ab755908d3b8e0b769c6ef936c
3
+ metadata.gz: c2a1ea656102e669a7254fe9bca8051c42012eeb
4
+ data.tar.gz: 664f17e6b51050429bb6ac846444b0c587acd7e4
5
5
  SHA512:
6
- metadata.gz: 91704ab7d25a73a5215188564e597b0d6d45466be0c0b1f82a4f211706e7a961d9a655a0f9860bcf71e8eb40f2b63f42fe56c85cec2f90c49470dbbc08de99f1
7
- data.tar.gz: 6c4d62437775c9b913a201bc6f83db21cdcfe6499445b6505ea401ce5f1ffd03ad5e48c145bc7a8f98813cb9644071f781aed73ca06e3ea1927a5bd9ab4d8bd1
6
+ metadata.gz: 6b3d1c916fdf87e0d0c63f6db7b4792f77c3ddfd48332a4d15136c2de9c62f31b200f8fd2a57e73cfc649dcffeec9f3e2f4d0b4dbbbaa06ec5edcde15d92f323
7
+ data.tar.gz: 472ab7a53b73629678210fb8d617e15a5578ca09b10a5b64b6f37850e80b3a85c3a4e4e0aa6295f5da52c217c8b45509f889fefa20528ea19f2a2f3c06123c44
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
+ - jruby-1.7.16
4
5
  script: bundle exec rspec
6
+ gemfile: Gemfile.ci
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake'
7
+ gem 'nokogiri'
8
+ gem 'rspec', '~> 2.12.0'
9
+ gem 'webmock'
10
+ gem 'simplecov', require: false
11
+ gem 'coveralls', require: false
12
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Forrest Ye
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,5 +4,48 @@
4
4
  [![Code Climate](https://codeclimate.com/github/forresty/xiami/badges/gpa.svg)](https://codeclimate.com/github/forresty/xiami)
5
5
  [![Coverage Status](https://coveralls.io/repos/forresty/xiami/badge.png)](https://coveralls.io/r/forresty/xiami)
6
6
  [![Gem Version](https://badge.fury.io/rb/xiami.svg)](http://badge.fury.io/rb/xiami)
7
+ [![Dependency Status](https://www.versioneye.com/user/projects/5471d5e19dcf6df5ea000ee9/badge.svg?style=flat)](https://www.versioneye.com/user/projects/5471d5e19dcf6df5ea000ee9)
7
8
 
8
9
  retrieve songs from xiami.com
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'xiami'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install xiami
26
+
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ Xiami::Song.new 42951
32
+ => #<Xiami::Song:0x007f8f35c43b48 @id="42951", @name="我爱台妹", @album=#<Xiami::Album:0x007f8f35c63560 @id="3488", @name="Wake Up", @cover_url="http://img.xiami.net/images/album/img24/724/34881343112513_3.jpg">, @artist=#<Xiami::Artist:0x007f8f35c79cc0 @id="724", @name="MC HotDog;张震岳">, @temporary_url="http://m5.file.xiami.com/724/724/3488/42951_28196_l.mp3?auth_key=77abde259cd6566a5c4222b4cca7331c-1416441600-0-null">
33
+ ```
34
+
35
+ ## Credits
36
+
37
+ - [xiami_sauce gem](https://github.com/ranmocy/xiami_sauce)
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/forresty/xiami/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
46
+
47
+ ## Changelog
48
+
49
+ ### 0.1.0 / 2014-12-17
50
+
51
+ - new `Song.fetch` method, will return nil when failed
@@ -1,6 +1,6 @@
1
1
  # originally from xiami_sauce gem
2
+ require "httpclient"
2
3
  require "cgi"
3
- require 'net/http'
4
4
  require 'nokogiri'
5
5
 
6
6
  module Xiami
@@ -10,6 +10,14 @@ module Xiami
10
10
 
11
11
  attr_accessor :local_file_path
12
12
 
13
+ class << self
14
+ def fetch(song_url = nil)
15
+ new(song_url)
16
+ rescue
17
+ nil
18
+ end
19
+ end
20
+
13
21
  def initialize(song_url = nil)
14
22
  if song_url
15
23
  @id = song_url.match(/song\/([0-9]+)/)[1] rescue song_url
@@ -59,11 +67,7 @@ module Xiami
59
67
  private
60
68
 
61
69
  def info_xml
62
- uri = URI.parse("http://www.xiami.com/widget/xml-single/uid/0/sid/#{id}")
63
-
64
- headers = { 'accept' => 'text/html', 'user-agent' => 'Mozilla/5.0' }
65
-
66
- Net::HTTP.new(uri.host, uri.port).get2(uri.path, headers).body
70
+ HTTPClient.new.get("http://www.xiami.com/widget/xml-single/uid/0/sid/#{id}").body
67
71
  end
68
72
 
69
73
  def sospa(location)
@@ -1,3 +1,3 @@
1
1
  module Xiami
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
 
23
23
  spec.add_runtime_dependency 'nokogiri'
24
+ spec.add_runtime_dependency 'httpclient'
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xiami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Forrest Ye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-15 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httpclient
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description:
56
70
  email:
57
71
  - afu@forresty.com
@@ -62,6 +76,8 @@ files:
62
76
  - .gitignore
63
77
  - .travis.yml
64
78
  - Gemfile
79
+ - Gemfile.ci
80
+ - LICENSE.txt
65
81
  - README.md
66
82
  - Rakefile
67
83
  - lib/xiami.rb
@@ -96,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
112
  version: '0'
97
113
  requirements: []
98
114
  rubyforge_project:
99
- rubygems_version: 2.0.2
115
+ rubygems_version: 2.4.4
100
116
  signing_key:
101
117
  specification_version: 4
102
118
  summary: retrieve songs from http://xiami.com