airplayer 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airplayer (0.0.5)
4
+ airplayer (0.0.6)
5
5
  airplay
6
6
  mime-types
7
+ nokogiri
7
8
  rack
8
9
  ruby-progressbar
9
10
  thor
@@ -15,29 +16,40 @@ GEM
15
16
  dnssd (~> 2.0)
16
17
  net-http-digest_auth (~> 1.2)
17
18
  net-http-persistent (>= 2.6)
19
+ coderay (1.0.8)
18
20
  diff-lcs (1.1.3)
19
21
  dnssd (2.0)
20
- guard (1.4.0)
22
+ guard (1.5.4)
21
23
  listen (>= 0.4.2)
24
+ lumberjack (>= 1.0.2)
25
+ pry (>= 0.9.10)
22
26
  thor (>= 0.14.6)
23
- guard-rspec (2.0.0)
27
+ guard-rspec (2.3.0)
24
28
  guard (>= 1.1)
25
29
  rspec (~> 2.11)
26
- listen (0.5.3)
30
+ listen (0.6.0)
31
+ lumberjack (1.0.2)
32
+ method_source (0.8.1)
27
33
  mime-types (1.19)
28
34
  net-http-digest_auth (1.2.1)
29
- net-http-persistent (2.7)
35
+ net-http-persistent (2.8)
36
+ nokogiri (1.5.5)
37
+ pry (0.9.10)
38
+ coderay (~> 1.0.5)
39
+ method_source (~> 0.8)
40
+ slop (~> 3.3.1)
30
41
  rack (1.4.1)
31
- rake (0.9.2.2)
32
- rspec (2.11.0)
33
- rspec-core (~> 2.11.0)
34
- rspec-expectations (~> 2.11.0)
35
- rspec-mocks (~> 2.11.0)
36
- rspec-core (2.11.1)
37
- rspec-expectations (2.11.3)
42
+ rake (10.0.2)
43
+ rspec (2.12.0)
44
+ rspec-core (~> 2.12.0)
45
+ rspec-expectations (~> 2.12.0)
46
+ rspec-mocks (~> 2.12.0)
47
+ rspec-core (2.12.1)
48
+ rspec-expectations (2.12.0)
38
49
  diff-lcs (~> 1.1.3)
39
- rspec-mocks (2.11.3)
40
- ruby-progressbar (1.0.1)
50
+ rspec-mocks (2.12.0)
51
+ ruby-progressbar (1.0.2)
52
+ slop (3.3.3)
41
53
  thor (0.16.0)
42
54
 
43
55
  PLATFORMS
@@ -16,7 +16,7 @@ Requirements
16
16
  -------------------------------------------------------------------------------
17
17
 
18
18
  - OSX or Ubuntu
19
- - Ruby 1.9.2 or later
19
+ - Ruby 1.9.3 or later
20
20
  - AppleTV 2G or later
21
21
 
22
22
 
@@ -91,12 +91,41 @@ $ airplayer play ~/Movies/Trailers
91
91
  Time: 00:02:36 |==============================================| 100% Complete
92
92
  ```
93
93
 
94
+ ### Play video podcast()
95
+
96
+ Example: CNN video podcast
97
+
98
+ ```sh
99
+ $ airplayer play http://rss.cnn.com/services/podcasting/cnnnewsroom/rss.xml
100
+
101
+ Source: http://rss.cnn.com/~r/services/podcasting/cnnnewsroom/rss/~5/z7DirHubdP0/exp-travel-insider-hilton-head-island.cnn.m4v
102
+ Title: exp-travel-insider-hilton-head-island.cnn.m4v
103
+ Device: Apple TV (10.0.1.2)
104
+ Time: 00:00:44 |============ | 39% Streaming
105
+ ```
106
+
107
+
94
108
  ### Repeat play
95
109
 
110
+ Repeat one
111
+
96
112
  ```sh
97
113
  $ airplayer play '~/Movies/Trailers/007 SKYFALL.mp4' --repeat
98
114
  ```
99
115
 
116
+ Repeat all
117
+
118
+ ```sh
119
+ $ airplayer play '~/Movies/Trailers' --repeat
120
+ ```
121
+
122
+
123
+ ### Shuffle play
124
+
125
+ ```sh
126
+ $ airplayer play '~/Movies/Trailers' --shuffle
127
+ ```
128
+
100
129
 
101
130
  Supported MIME types
102
131
  --------------------------------------------------------------------------------
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_runtime_dependency 'airplay'
21
21
  gem.add_runtime_dependency 'rack'
22
22
  gem.add_runtime_dependency 'mime-types'
23
+ gem.add_runtime_dependency 'nokogiri'
23
24
 
24
25
  gem.add_development_dependency 'rake'
25
26
  gem.add_development_dependency 'rspec'
@@ -2,7 +2,7 @@ require 'thor'
2
2
 
3
3
  module AirPlayer
4
4
  class App < Thor
5
- desc 'play <URI|FILE|DIR> [-r|--repeat] [-s|--shuffle]', 'Play video(URI or local video file path or video directory)'
5
+ desc 'play <URI|Podcast XML|FILE|DIR> [-r|--repeat] [-s|--shuffle]', 'Play video(URI or Podcast XML URI or local video file path or video directory)'
6
6
  method_option :repeat, :aliases => '-r', :desc => 'Repeat play', :type => :boolean
7
7
  method_option :shuffle, :aliases => '-s', :desc => 'Shuffle play', :type => :boolean
8
8
  def play(target)
@@ -20,7 +20,7 @@ module AirPlayer
20
20
  end
21
21
 
22
22
  def play(media)
23
- raise TypeError unless media.kind_of? Media
23
+ raise TypeError unless media.is_a? Media
24
24
 
25
25
  display_information(media)
26
26
  @player = @airplay.send_video(media.open)
@@ -35,6 +35,8 @@ module AirPlayer
35
35
  abort '[ERROR] Buffering timeout'
36
36
  rescue TypeError
37
37
  abort '[ERROR] Not media class'
38
+ rescue
39
+ abort "Play stopped"
38
40
  end
39
41
 
40
42
  def pause
@@ -44,7 +44,7 @@ module AirPlayer
44
44
  end
45
45
 
46
46
  def open
47
- Thread.start { @video_server.start } if file?
47
+ @video_server.start if file?
48
48
  @path
49
49
  end
50
50
 
@@ -1,3 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rss'
4
+ require 'nokogiri'
5
+
1
6
  module AirPlayer
2
7
  class Playlist < Array
3
8
  def initialize(options = {})
@@ -6,8 +11,14 @@ module AirPlayer
6
11
  end
7
12
 
8
13
  def add(item)
9
- path = File.expand_path(item)
10
- Dir.exists?(path) ? concat(media_in(path)) : push(Media.new(item))
14
+ case type(item)
15
+ when :local
16
+ concat(media_in_local(item))
17
+ when :podcast
18
+ concat(media_in_podcast(item))
19
+ when :url
20
+ push(Media.new(item))
21
+ end
11
22
  self
12
23
  end
13
24
 
@@ -20,10 +31,26 @@ module AirPlayer
20
31
  end
21
32
 
22
33
  private
23
- def media_in(path)
24
- Dir.entries(path).map do |node|
34
+ def type(item)
35
+ if Dir.exists?(File.expand_path(item))
36
+ :local
37
+ elsif Media.playable? item
38
+ :url
39
+ elsif RSS::Parser.parse(open(item))
40
+ :podcast
41
+ end
42
+ end
43
+
44
+ def media_in_local(path)
45
+ Dir.entries(File.expand_path(path)).sort.map do |node|
25
46
  Media.new(File.expand_path(node, path)) if Media.playable? node
26
47
  end.compact
27
48
  end
49
+
50
+ def media_in_podcast(path)
51
+ Nokogiri::XML(open(path)).search('enclosure').map do |node|
52
+ Media.new(node.attributes['url'].text)
53
+ end
54
+ end
28
55
  end
29
56
  end
@@ -6,16 +6,22 @@ module AirPlayer
6
6
  attr_reader :uri
7
7
 
8
8
  def initialize(video_path)
9
- @server = Rack::Server.new(:server => :webrick, :Host => local_ip, :Port => 7070)
10
- @server.instance_variable_set(:@app, Rack::File.new(video_path))
9
+ @server = Rack::Server.new(
10
+ :server => :webrick,
11
+ :Host => local_ip,
12
+ :Port => 7070,
13
+ :app => Rack::File.new(video_path)
14
+ )
11
15
  @uri = "http://#{@server.options[:Host]}:#{@server.options[:Port]}"
12
16
  end
13
17
 
14
18
  def start
15
- # Output WEBrick access log to file
16
- $stderr = File.open(Logger.path, File::WRONLY | File::APPEND | File::CREAT)
17
- @server.start
18
- $stderr = STDERR
19
+ Thread.start do
20
+ # Output WEBrick access log to file
21
+ $stderr = File.open(Logger.path, File::WRONLY | File::APPEND | File::CREAT)
22
+ @server.start
23
+ $stderr = STDERR
24
+ end
19
25
  end
20
26
 
21
27
  def stop
@@ -1,3 +1,3 @@
1
1
  module AirPlayer
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -46,10 +46,16 @@ describe :AirPlayer do
46
46
  expect(playlist.first.path).to match 'http'
47
47
  end
48
48
 
49
+ it 'add Podcast rss to list' do
50
+ playlist.add('http://rss.cnn.com/services/podcasting/cnnnewsroom/rss.xml')
51
+ playlist.entries do |media|
52
+ expect(media).to be_kind_of AirPlayer::Media
53
+ end
54
+ end
55
+
49
56
  it 'add file to list, and that media type is file' do
50
- expect(playlist.add('./LICENSE').size).to eq 1
51
- expect(playlist.add('./Gemfile').size).to eq 2
52
- expect(playlist.first.file?).to be_true
57
+ expect(playlist.add('./video.mp4').size).to eq 1
58
+ expect(playlist.add('./video.m4v').size).to eq 2
53
59
  end
54
60
 
55
61
  it 'has list contains url or file path' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airplayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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: 2012-10-10 00:00:00.000000000 Z
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: nokogiri
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
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
  - !ruby/object:Gem::Dependency
95
111
  name: rake
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
199
  version: '0'
184
200
  segments:
185
201
  - 0
186
- hash: -4077241967162441253
202
+ hash: 3264263706258799017
187
203
  required_rubygems_version: !ruby/object:Gem::Requirement
188
204
  none: false
189
205
  requirements:
@@ -192,10 +208,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
208
  version: '0'
193
209
  segments:
194
210
  - 0
195
- hash: -4077241967162441253
211
+ hash: 3264263706258799017
196
212
  requirements: []
197
213
  rubyforge_project:
198
- rubygems_version: 1.8.23
214
+ rubygems_version: 1.8.24
199
215
  signing_key:
200
216
  specification_version: 3
201
217
  summary: Command-line AirPlay video client for Apple TV