xiami_sauce 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca6f3d6701281dfc430d2fd2f17bdb58dc622c92
4
- data.tar.gz: 97b99e4e6a7d83017b026415bf0ed1641cf6db5f
3
+ metadata.gz: 3423795b0d768a407e7f25c4a94275247e62345a
4
+ data.tar.gz: 40ecbda12d6b5728d566f7317daf00323a7b5f7f
5
5
  SHA512:
6
- metadata.gz: 0831a00e09656a48b0d1b5619889c3c1f48e9a5960c994d8a337ee7307aeba267100ee2cabc8ee84b6e051aaeb67ffd6f0237bb1890d985b0903cd5f743f376b
7
- data.tar.gz: 92ee592a6ecd6256f04d9907d760c5cf1f7f2bef11299467338deaaa4d0da58fde895c79d005dac83ca7d61db6129196f06d1d69094659462f32b2676324f48e
6
+ metadata.gz: 1d7340440be6543d4ccfda5f78b007853a10079ed59d739837ac7fcee3d1a91a1c896978829a8866c6414df8500e422f1715fe54a414b87a547440e6c496ac7c
7
+ data.tar.gz: 20d983ff820b645a9e501647fe066a6319d5035d059752a6e3fc2fcd82acfefc7e350f8f34596499a46be12f2f589a7d2ed06e26b30bd635eb7f420774127d14
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
4
3
  - 2.0.0
5
4
  - jruby
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
- source 'http://ruby.taobao.org'
2
- # source 'https://rubygems.org'
1
+ source 'https://rubygems.org'
3
2
 
4
3
  gemspec
5
4
 
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ xiami_sauce (0.0.3)
5
+ nokogiri (~> 1.6)
6
+ rainbow (~> 2.0)
7
+ thor (~> 0.17)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ coderay (1.1.0)
13
+ diff-lcs (1.2.5)
14
+ ffi (1.9.10)
15
+ formatador (0.2.5)
16
+ guard (2.13.0)
17
+ formatador (>= 0.2.4)
18
+ listen (>= 2.7, <= 4.0)
19
+ lumberjack (~> 1.0)
20
+ nenv (~> 0.1)
21
+ notiffany (~> 0.0)
22
+ pry (>= 0.9.12)
23
+ shellany (~> 0.0)
24
+ thor (>= 0.18.1)
25
+ guard-bundler (2.1.0)
26
+ bundler (~> 1.0)
27
+ guard (~> 2.2)
28
+ guard-compat (~> 1.1)
29
+ guard-compat (1.2.1)
30
+ guard-rspec (4.6.4)
31
+ guard (~> 2.1)
32
+ guard-compat (~> 1.1)
33
+ rspec (>= 2.99.0, < 4.0)
34
+ libnotify (0.9.1)
35
+ ffi (>= 1.0.11)
36
+ listen (3.0.5)
37
+ rb-fsevent (>= 0.9.3)
38
+ rb-inotify (>= 0.9)
39
+ lumberjack (1.0.9)
40
+ metaclass (0.0.4)
41
+ method_source (0.8.2)
42
+ mini_portile2 (2.0.0)
43
+ mocha (0.13.3)
44
+ metaclass (~> 0.0.1)
45
+ nenv (0.2.0)
46
+ nokogiri (1.6.7.1)
47
+ mini_portile2 (~> 2.0.0.rc2)
48
+ notiffany (0.0.8)
49
+ nenv (~> 0.1)
50
+ shellany (~> 0.0)
51
+ pry (0.10.3)
52
+ coderay (~> 1.1.0)
53
+ method_source (~> 0.8.1)
54
+ slop (~> 3.4)
55
+ rainbow (2.0.0)
56
+ rake (10.4.2)
57
+ rb-fsevent (0.9.6)
58
+ rb-inotify (0.9.5)
59
+ ffi (>= 0.5.0)
60
+ rspec (3.4.0)
61
+ rspec-core (~> 3.4.0)
62
+ rspec-expectations (~> 3.4.0)
63
+ rspec-mocks (~> 3.4.0)
64
+ rspec-core (3.4.1)
65
+ rspec-support (~> 3.4.0)
66
+ rspec-expectations (3.4.0)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.4.0)
69
+ rspec-mocks (3.4.0)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.4.0)
72
+ rspec-support (3.4.1)
73
+ shellany (0.0.1)
74
+ slop (3.6.0)
75
+ terminal-notifier-guard (1.6.4)
76
+ thor (0.19.1)
77
+ version (1.0.0)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ bundler (~> 1.3)
84
+ guard
85
+ guard-bundler
86
+ guard-rspec
87
+ libnotify
88
+ mocha (~> 0.13.0)
89
+ rake
90
+ rb-fsevent (>= 0.3.9)
91
+ rb-inotify (>= 0.5.1)
92
+ rspec
93
+ terminal-notifier-guard
94
+ version
95
+ xiami_sauce!
96
+
97
+ BUNDLED WITH
98
+ 1.11.2
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ Rake::VersionTask.new
10
10
 
11
11
  # include Rake::DSL if defined?(Rake::DSL)
12
12
 
13
- RVM_PREFIX = "rvm 1.8.7,1.9.3-p327,2.0.0 do"
13
+ RVM_PREFIX = "rvm 1.9.3-p327,2.0.0 do"
14
14
 
15
15
 
16
16
  namespace :spec do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -38,10 +38,10 @@ module XiamiSauce
38
38
  private
39
39
 
40
40
  def parse_info
41
- url_str = URI.parse(info_src)
42
- site = Net::HTTP.new(url_str.host, url_str.port)
43
- xml = site.get2(url_str.path,{'accept'=>'text/html'}).body
44
- doc = Nokogiri::XML(xml)
41
+ uri = URI.parse(info_src)
42
+ site = Net::HTTP.new(uri.host, uri.port)
43
+ xml = site.get2(uri.path,{'accept' => 'text/html', 'user-agent' => 'Mozilla/5.0'}).body
44
+ doc = Nokogiri::XML(xml)
45
45
 
46
46
  doc.css('track *').each do |element|
47
47
  instance_variable_set("@#{element.name}", element.content)
@@ -50,56 +50,25 @@ module XiamiSauce
50
50
  @url = sospa(@location)
51
51
  end
52
52
 
53
+ # Rewrite the algorithm, much much more better.
53
54
  def sospa(location)
54
- totle = location.to_i
55
- new_str = location[1..-1]
56
- chu = (new_str.length.to_f / totle).floor
57
- yu = new_str.length % totle
58
- stor = []
59
-
60
- i = 0
61
- while i < yu do
62
- index = (chu+1)*i
63
- length = chu+1
64
- stor[i] = new_str[index...index+length]
65
-
66
- i+=1
67
- end
68
-
69
-
70
- i = yu
71
- while i < totle do
72
- index = chu*(i-yu)+(chu+1)*yu
73
- length = chu
74
-
75
- stor[i] = new_str[index...index+length]
76
-
77
- i+=1
78
- end
79
-
80
- pin_str = ""
81
- 0.upto(stor[0].length-1) do |ii|
82
- 0.upto(stor.length-1) do |jj|
83
- pin_str += stor[jj][ii...ii+1]
84
- end
85
- end
86
-
87
- pin_str = rtan(pin_str)
88
- return_str = ""
89
-
90
- 0.upto(pin_str.length-1) do |iii|
91
- if pin_str[iii...iii+1]=='^'
92
- return_str<<"0"
93
- else
94
- return_str<<pin_str[iii...iii+1]
95
- end
96
- end
97
-
98
- return_str
55
+ string = location[1..-1]
56
+ col = location[0].to_i
57
+ row = (string.length.to_f / col).floor
58
+ remainder = string.length % col
59
+ address = [[nil]*col]*(row+1)
60
+
61
+ sizes = [row+1] * remainder + [row] * (col - remainder)
62
+ pos = 0
63
+ sizes.each_with_index { |size, i|
64
+ size.times { |index| address[col * index + i] = string[pos + index] }
65
+ pos += size
66
+ }
67
+
68
+ address = CGI::unescape(address.join).gsub('^', '0')
69
+ rescue
70
+ raise location
99
71
  end
100
72
 
101
- def rtan(str)
102
- CGI::unescape(str)
103
- end
104
73
  end
105
74
  end
@@ -33,8 +33,8 @@ describe XiamiSauce::TrackList do
33
33
 
34
34
  it "should parse url" do
35
35
  uri, type = subject.send(:parse_url, url)
36
- uri.path.should == '/song/1770450682'
37
- type.should == :song
36
+ expect(uri.path).to be == '/song/1770450682'
37
+ expect(type).to be == :song
38
38
  end
39
39
 
40
40
  it "should parse doc" do
@@ -43,7 +43,7 @@ describe XiamiSauce::TrackList do
43
43
  subject.instance_variable_set("@type", type)
44
44
  doc = subject.send(:parse_doc, uri)
45
45
  subject.instance_variable_set("@doc", doc)
46
- subject.instance_variable_get("@doc").should be_kind_of Nokogiri::HTML::Document
46
+ expect(subject.instance_variable_get("@doc")).to be_kind_of Nokogiri::HTML::Document
47
47
  end
48
48
  end
49
49
 
@@ -76,7 +76,7 @@ describe XiamiSauce::TrackList do
76
76
  let(:b_list) { XiamiSauce::TrackList.new(b_url) }
77
77
 
78
78
  it "should be able to add" do
79
- (a_list << b_list).list.should be == (a_list.list << b_list.list)
79
+ expect((a_list << b_list).list).to be == (a_list.list << b_list.list)
80
80
  end
81
81
  end
82
82
  end
@@ -6,15 +6,16 @@ describe XiamiSauce::Track do
6
6
 
7
7
  subject { XiamiSauce::Track.new(song_url, index) }
8
8
 
9
- its('id') { should == '1770361274' }
10
- its('index') { should == '9' }
11
- its('name') { should == 'Kids (Unedited Version)' }
12
- its('url') { should == 'http://f1.xiami.net/11768/454588/02_1770361274_2491919.mp3' }
13
- its('album_id') { should == '454588' }
14
- its('album_cover') { should == 'http://img.xiami.com/./images/album/img68/11768/4545881311563810_3.jpg' }
15
- its('album_name') { should == 'The Way I Am' }
16
- its('artist_id') { should == '11768' }
17
- its('artist_name') { should == 'Eminem' }
9
+ it { expect(subject.id).to be == '1770361274' }
10
+ it { expect(subject.index).to be == '9' }
11
+ it { expect(subject.name).to be == 'Kids (Unedited Version)' }
12
+ it { expect(subject.album_id).to be == '454588' }
13
+ it { expect(subject.album_cover).to be == 'http://img.xiami.com/./images/album/img68/11768/4545881311563810_3.jpg' }
14
+ it { expect(subject.album_name).to be == 'The Way I Am' }
15
+ it { expect(subject.artist_id).to be == '11768' }
16
+ it { expect(subject.artist_name).to be == 'Eminem' }
18
17
 
19
- its('file_name') { should == '[Eminem-The Way I Am]09.Kids (Unedited Version).mp3' }
18
+ it { expect(subject.file_name).to be == '[Eminem-The Way I Am]09.Kids (Unedited Version).mp3' }
19
+
20
+ it { expect(subject.url).to be == 'http://f1.xiami.net/11768/454588/02_1770361274_2491919.mp3' }
20
21
  end
@@ -16,9 +16,9 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency 'thor', '~> 0.17.0'
20
- spec.add_dependency 'nokogiri', '~> 1.5.0'
21
- spec.add_dependency 'rainbow', '~> 1.1.0'
19
+ spec.add_dependency 'thor', '~> 0.17'
20
+ spec.add_dependency 'nokogiri', '~> 1.6'
21
+ spec.add_dependency 'rainbow', '~> 2.0'
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xiami_sauce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wanzhang Sheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-17 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.17.0
19
+ version: '0.17'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.17.0
26
+ version: '0.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.5.0
33
+ version: '1.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.5.0
40
+ version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rainbow
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.1.0
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.0
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: version
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: mocha
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.13.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.13.0
125
125
  description: A Xiami Downloader.
@@ -130,9 +130,10 @@ executables:
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
- - .gitignore
134
- - .travis.yml
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
135
  - Gemfile
136
+ - Gemfile.lock
136
137
  - Guardfile
137
138
  - LICENSE.txt
138
139
  - README.md
@@ -159,17 +160,17 @@ require_paths:
159
160
  - lib
160
161
  required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - '>='
163
+ - - ">="
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
- - - '>='
168
+ - - ">="
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubyforge_project:
172
- rubygems_version: 2.0.0
173
+ rubygems_version: 2.4.6
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: A Xiami Downloader.