xiami_radio 1.1.4 → 1.1.5

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: 2945c7bf31a3da8dab44bef8baeec1cc0e43d95f
4
- data.tar.gz: 2777d8c81551c09bd2fd1a7f2a6f5105cc737acb
3
+ metadata.gz: ad5acb7b2b85bf3651375b099f3cd44df6c30ab0
4
+ data.tar.gz: 35e41bb6a31064ff8d60f1d4981058811da27c66
5
5
  SHA512:
6
- metadata.gz: 8a851c417c5d7d3d161c58bd0faf5b74422c7f1656e0464749a22b41d15c7ad820f2c409749ee586a6421dd7a6de44735ba2cad6e8207dc8125a2267fd74afdb
7
- data.tar.gz: 78a312b7a549331b07d01d7a0a0471a2d5583addf9f66e1cbd2cef50f85504d2d8146cde07824cd7fb0e916f82af15a5a680924c96971fb982b9c884afc2fc38
6
+ metadata.gz: 731587bb2b51bb5b1c9ca00ba83fe1c35a946a7525cb5221db1fbc124f5aaddafaa3bbe518fd00a7d7c8be959bc64b4cd1bd8fdfdcbc01f72f6426d2290388b9
7
+ data.tar.gz: a47b38e7bf6d0cf1867934ae99910b2d552e0ead89a5f122fd454c39e6943e9dce17005de444560957a0a9b4bae55a6dbb0af5d1c3f90665608100296610f0db
@@ -50,7 +50,7 @@ module XiamiRadio
50
50
  def request(uri, format, headers, &block)
51
51
  _headers = @headers.merge headers
52
52
  _headers.merge! 'Cookie' => HTTP::Cookie.cookie_value(user.cookie_jar.cookies uri)
53
- _headers.merge! 'X-Requested-With' => 'XMLHttpRequest' if %i(json xml).include? format
53
+ _headers.merge! 'X-Requested-With' => 'XMLHttpRequest' if %i(json xml xhtml).include? format
54
54
 
55
55
  res = block.call _headers
56
56
 
@@ -25,8 +25,7 @@ module XiamiRadio
25
25
  end
26
26
 
27
27
  def start
28
- @thread = Thread.start { request URI(@track.location) }
29
- sleep 0.1 until @progress.to_i > 0
28
+ @thread ||= Thread.start { request URI(@track.location) }
30
29
  end
31
30
 
32
31
  def stop
@@ -52,17 +52,19 @@ module XiamiRadio
52
52
  def position_change(position)
53
53
  @view.refresh @track, position
54
54
 
55
+ @track.record position.to_i if (120.0..120.1).include? position
56
+
55
57
  if !preload? && position / @track.duration > 0.7
56
58
  @preloader = Thread.start do
57
59
  @next_track = @radio.next_track
58
60
  @player.queue @next_track.file_path
59
- @track.record
60
61
  end
61
62
  end
62
63
  end
63
64
 
64
65
  def complete
65
66
  @track, @next_track = @next_track, nil
67
+ @track.record
66
68
  end
67
69
 
68
70
  def preload?
@@ -9,7 +9,7 @@ module XiamiRadio
9
9
  @client = Client.new user: User.instance
10
10
  end
11
11
 
12
- def location(hd: false)
12
+ def location(hd: true)
13
13
  hd ? decode_location(hd_location) : decode_location(@info[:location])
14
14
  end
15
15
 
@@ -36,20 +36,23 @@ module XiamiRadio
36
36
 
37
37
  def file_path
38
38
  @info[:file_path] ||= begin
39
- downloader.start if downloader.file.nil?
39
+ downloader.start
40
+ sleep 0.1 while downloader.file.nil? || File.empty?(downloader.file)
40
41
  downloader.file.path
41
42
  end
42
43
  end
43
44
 
44
- def record
45
- uri = client.uri path: '/count/playrecord',
46
- query: URI.encode_www_form(sid: song_id, type: 1, ishq: 1)
47
- client.get(uri, headers: radio.headers_referer, format: :js)
45
+ def record(point = 1)
46
+ uri = client.uri path: '/count/playrecord', query: URI.encode_www_form(
47
+ sid: song_id, type:10, start_point: point, _xiamitoken: client.user.xiami_token
48
+ )
49
+ client.get(uri, headers: radio.headers_referer, format: :xhtml)
48
50
  end
49
51
 
50
52
  def fav
51
- uri = client.uri path: '/song/fav',
52
- query: URI.encode_www_form(ids: song_id, _xiamitoken: client.user.xiami_token)
53
+ uri = client.uri path: '/song/fav', query: URI.encode_www_form(
54
+ ids: song_id, _xiamitoken: client.user.xiami_token
55
+ )
53
56
  res = client.get(uri, headers: radio.headers_referer, format: :js)
54
57
 
55
58
  return '操作失败 (╯‵□′)╯︵┻━┻' unless res.code == '200'
@@ -1,5 +1,5 @@
1
1
  module XiamiRadio
2
2
 
3
- VERSION = '1.1.4'
3
+ VERSION = '1.1.5'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xiami_radio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Chou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2018-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: audite