vkpd 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vkpd/cli.rb CHANGED
@@ -10,6 +10,7 @@ module Vkpd
10
10
  do_play = true
11
11
  params["auto_complete"] = '1'
12
12
  player = :mpd
13
+ random = false
13
14
 
14
15
  if ARGV.empty?
15
16
  ARGV.push "-h"
@@ -24,6 +25,8 @@ module Vkpd
24
25
  exit 0
25
26
  when '-v', '--verbose'
26
27
  @verbose = true
28
+ when '-r', '--random'
29
+ random = true
27
30
  when '-p', '--mplayer'
28
31
  player = :mplayer
29
32
  when '-c', '--count', /^--count=\d+$/
@@ -65,13 +68,16 @@ module Vkpd
65
68
  ARGV.clear
66
69
  end
67
70
  end
68
-
71
+
69
72
  params["access_token"]=Vkpd::config["access_token"]
70
-
73
+
71
74
  response = make_vk_request(method,params)
72
75
  if method.match /search/
73
76
  response.shift
74
77
  end
78
+
79
+ response = response.shuffle if random
80
+
75
81
  case player
76
82
  when :mpd
77
83
  mpd.clear if do_clear
@@ -81,9 +87,20 @@ module Vkpd
81
87
  end
82
88
  mpd.play if do_play
83
89
  when :mplayer
84
- response.each do |song|
85
- puts song if @verbose
86
- system "mplayer --cache=8192 --cache-min=2 #{song['url']}"
90
+ catch :stop do
91
+ response.each do |song|
92
+ ap song
93
+ system "mplayer --cache=8192 --cache-min=2 #{song['url']}"
94
+ begin
95
+ Timeout::timeout 0.25 do
96
+ case key = STDIN.getch
97
+ when 'q' then throw :stop
98
+ end
99
+ end
100
+ rescue Timeout::Error
101
+ # do nothing
102
+ end
103
+ end
87
104
  end
88
105
  end
89
106
  end
data/lib/vkpd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vkpd
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
data/lib/vkpd.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  require 'net/http'
3
3
  require 'net/https'
4
4
  require 'cgi'
5
+ require 'ap'
6
+ require 'io/console'
5
7
  require 'yaml'
6
8
  require 'json'
7
9
  require 'pathname'
data/vkpd.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "launchy"
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "awesome_print"
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vkpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-25 00:00:00.000000000 Z
12
+ date: 2013-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: awesome_print
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
94
110
  description: VKPD searches for music files on russian social network vk.com and adds/plays
95
111
  it with MPD.
96
112
  email: