douban.fm 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_dependency 'ruby-mpd'
20
- gem.add_dependency 'highline'
19
+ gem.add_dependency 'ruby-mpd', '0.1.5'
20
+ gem.add_dependency 'highline', '1.6.15'
21
21
  end
@@ -4,7 +4,7 @@ module DoubanFM
4
4
  require 'ruby-mpd'
5
5
 
6
6
  class DoubanFM
7
- DOUBAN_FM_MPD_PLAYLIST = 'douban.fm'
7
+ # DOUBAN_FM_MPD_PLAYLIST = 'douban.fm'
8
8
  MIN_SONGS_IN_DOUBAN_FM_MPD_PLAYLIST = 10
9
9
 
10
10
  attr_reader :waiting, :channels, :current_playlist
@@ -100,21 +100,34 @@ module DoubanFM
100
100
  mpd = MPD.new(host, port)
101
101
  mpd.connect
102
102
 
103
- begin
104
- songs = mpd.send_command(:listplaylistinfo, DOUBAN_FM_MPD_PLAYLIST)
105
- if songs.is_a? String
106
- total = 1
107
- else
108
- total = songs.length
109
- end
110
- rescue
111
- total = 0
112
- end
103
+ # remove after played
104
+ mpd.consume = 1
105
+
106
+ # unfortunately it is not the same as i thought.
107
+ # i can not create a playlist specially for douban.fm since
108
+ # mpd will not remove song from this playlist anyway which
109
+ # means there is no chance for me to detect the total number
110
+ # of songs in the playlist is below a threshhold.
111
+ # so before i can find any better solution, just make use
112
+ # of the default playlist which is dynamic.
113
+
114
+ # begin
115
+ # songs = mpd.send_command(:listplaylistinfo, DOUBAN_FM_MPD_PLAYLIST)
116
+ # if songs.is_a? String
117
+ # total = 1
118
+ # else
119
+ # total = songs.length
120
+ # end
121
+ # rescue
122
+ # total = 0
123
+ # end
124
+
125
+ total = mpd.status[:playlistlength]
113
126
 
114
127
  @logger.log("current total number of songs in mpd #{total}")
115
128
 
116
129
  if total < MIN_SONGS_IN_DOUBAN_FM_MPD_PLAYLIST
117
- douban_fm_playlist = MPD::Playlist.new(mpd, {:playlist => DOUBAN_FM_MPD_PLAYLIST})
130
+ # douban_fm_playlist = MPD::Playlist.new(mpd, {:playlist => DOUBAN_FM_MPD_PLAYLIST})
118
131
 
119
132
  begin
120
133
  @logger.log('fetch next playlist')
@@ -135,7 +148,8 @@ module DoubanFM
135
148
  @current_playlist['song'].each do |song|
136
149
  @logger.log("send [#{song['url'].gsub('\\', '')}] to mpd")
137
150
 
138
- douban_fm_playlist.add(song['url'].gsub('\\', ''))
151
+ # douban_fm_playlist.add(song['url'].gsub('\\', ''))
152
+ mpd.add(song['url'].gsub('\\', ''))
139
153
  end
140
154
  end
141
155
 
@@ -1,3 +1,3 @@
1
1
  module DoubanFM
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: douban.fm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,26 +13,26 @@ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-mpd
16
- requirement: &70182454448200 !ruby/object:Gem::Requirement
16
+ requirement: &70256513065900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - =
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 0.1.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70182454448200
24
+ version_requirements: *70256513065900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: highline
27
- requirement: &70182454447640 !ruby/object:Gem::Requirement
27
+ requirement: &70256513062600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - =
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 1.6.15
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70182454447640
35
+ version_requirements: *70256513062600
36
36
  description: douban.fm
37
37
  email:
38
38
  - hxliang1982@gmail.com